Archived

This topic is now archived and is closed to further replies.

WarpD

gauges.h outside of cgauge

Recommended Posts

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

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

You can't do that.The function addresses you're wanting to use are filled in by FS when it loads the gauge header.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

>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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites