November 12, 200817 yr HiI'm trying to figure out how to use the gauges.h functions outside of a cgauge. I've been looking at the cabincomfort.dll as an example. I can get my program to compile but it crashes at runtime. Here is the outline of my .exe program:// application.cpp#include "GAUGES.H"PPANELS Panels = NULL;GAUGESIMPORT ImportTable = { 0x0000000F, (PPANELS)NULL }, { 0x00000000, NULL } }; void FSAPI module_init(void){ if (NULL != Panels) { ImportTable.PANELSentry.fnptr = (PPANELS)Panels; }} void FSAPI module_deinit(void){}// This is the module's export table.GAUGESLINKAGE Linkage = { 0x00000013, module_init, module_deinit, 0, 0, FS9LINK_VERSION, { 0 }};int main(){ check_named_variable("my_named_variable");}//////////////////////////////////////////////////////////////////////////////This code will at least compile, but crashes at runtime. When I get to check_named_variable(), I get an access error.I basically just copied everything before main() from the cabincomfort.cpp. if I comment out all the definitions before main() I get this error: unresolved external symbol _ImportTableCan anybody tell me what I'm missing here?Thanks
November 12, 200817 yr Author Commercial Member You can't do that.The function addresses you're wanting to use are filled in by FS when it loads the gauge header. Ed Wilson Mindstar AviationMy Playland - I69
November 12, 200817 yr But I can call the check_named_variable() from the cabincomfort.cpp and it works. Is it because that is a dll and I'm trying to do it from a .exe?
November 12, 200817 yr Moderator >But I can call the check_named_variable() from the>cabincomfort.cpp and it works. Is it because that is a dll>and I'm trying to do it from a .exe?In a word, yes. A .dll is loaded by the sim and still runs "in process" unlike an external app running as an .exe "out of process."You will need to use FSX SimConnect if you wish to interface an .exe and the sim. Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
November 12, 200817 yr Thanks Bill I'm trying to read/write to a user defined gauge variable from outside the gauge itself. So it looks like I can do this using the gauge functions only from within a dll. I was hoping to be able to do this from an exe too. I tried something like this:SimConnect_AddToDataDefinition(hSimConnect, DEFINITION__NUMBER,"my_number", "int"); my_number being a gauge variable I defined. I get a simconnect exception 'name_unrecognized' by doing this. So my question is, is there any way to write directly to a user defined gauge variable from an exe? Thanks againBobby
November 12, 200817 yr Author Commercial Member SimConnect only understands FS variables. User defined variables are not part of FS.There is another forum for SimConnect discussions, because SimConnect is not normally used inside a gauge. Ed Wilson Mindstar AviationMy Playland - I69
Create an account or sign in to comment