July 7, 200718 yr Commercial Member Hi folks,I want to create a simple DLL that gets automatically loaded when FS9 starts and released when FS9 exits. The DLL won't communicate with FS9 directly so I hope I don't have to use the SDK (I have just taken a look at it and I'm not impressed :-) ). Which functions have to be exported by a DLL? I've taken a look at the existing DLL's (with DependencyWalker) and they all seem to export at least two functions, ImportTable and Linkage. The SDK doesn't explain these functions so I guess some type of macro creates those functions for you?Can someone maybe explain how these functions are called and what the prototype is so I can create my DLL?Thanks!Mark Mark Foti Author of aviaworx - https://www.aviaworx.com
July 7, 200718 yr Here is the basic block of code:#include "fs9gauges.h"#include "some_local_header_file.h"#include #include void FSAPI module_init(void){} void FSAPI module_deinit(void){} /* This is the module's import table. */ GAUGESIMPORT ImportTable = { { 0x0000000F, (PPANELS)NULL }, { 0x00000000, NULL } }; /* This is the module's export table. */ GAUGESLINKAGE Linkage = { 0x000002d9, module_init, module_deinit, 0, 0, FS9LINK_VERSION, {0} };The first element in the declaration of Linkage (0x2d9) can be pretty much any number you want.By including the reference to the gauges.h file, you will be able to use FS variables and key events - something that will make your life much easier.Doug
July 8, 200718 yr Author Commercial Member Hi Doug,thanks for the info! That's pretty much exactly what I needed! Although I can't honestly say I truly understand how the constructs work...How come the FS SDK is so "unfriendly"? Does it have to do with FS's ancient programming history (I hear many parts of the core have been carried over from version 4 written in assembler)?I'll give the dll a try tomorrow - thank goodness I can communicate with FS through FSUIPC!Do you also use these constructs or did someone create a more user-friendly wrapper?Kind regards,Mark Mark Foti Author of aviaworx - https://www.aviaworx.com
July 8, 200718 yr Author Commercial Member And one more follow-up question:how can I add a menu entry to say the Modules menu? Mark Foti Author of aviaworx - https://www.aviaworx.com
July 9, 200718 yr I won't pretend to be fully conversant with these things either. The block of code for the Linkage and ImportTable definitions is copied right out of the GaugeTable definition at the bottom of the GAUGES.H file.Check here for an example of code to create a menu item:http://library.avsim.net/esearch.php?DLID=...hor=&CatID=rootDoug
July 10, 200718 yr Author Commercial Member Thanks Doug, that worked! Mark Foti Author of aviaworx - https://www.aviaworx.com
July 11, 200718 yr Author Commercial Member And to everyone who might want to add something to the FS menu, consider using "SetWindowLongPtr" instead of "SetWindowLong" as its safer (considering the jump to 64 bit pointers)Regards,Mark Mark Foti Author of aviaworx - https://www.aviaworx.com
Create an account or sign in to comment