Jump to content
Sign in to follow this  
ddawson

Path to panel.cfg file

Recommended Posts

Is it possible to determine through a gauge callback the location of the current panel.cfg file? If so, how does one do that?Thanks,Doug

Share this post


Link to post
Share on other sites
Guest bartels

No direct way I think. Maybe an indirect way, if the gauge is placed in the panel folder, not in the gauge folder, you can try to get the gauges full pathname and therefore the panel path and therfore the panel.cfg path. It might be possible with GetModuleFileName anywhere in the code, if you first get the handle to the DLL first (not tried), or you introduce a DllMain function that looks like this:static char gauname[MAX_PATH+1] = "";...BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved) { GetModuleFileName(hDLL,gauname,MAX_PATH); return TRUE; } You have to throw out the definition of DllMain from GAUGE_TABLE_BEGIN macro. BTW you can remove DllMain,module_init,module_deinit from GAUGE_TABLE_BEGIN in any case, they do nothing, their absence doesn't do any harm.Arne Bartels

Share this post


Link to post
Share on other sites
Guest bartels

Another indirect way would be to read some aircraft.cfg data via the XML interface execute_calculator_code.namely:ATC TYPE ATC MODEL ATC ID ATC AIRLINE ATC FLIGHT_NUMBER TITLE And then scan through all aircrafts to find the right one, can be time cosuming and not leads not necessarily to unambigous results. Also FSUIPC has a possibility to read the path to the aircraft.cfg, with the aircrafts title you should find the right panel.cfg.Presumably the path to the aircraft.cfg (panel.cfg also?) is somewhere buried in the data of "globals.dll". You could dump chunks of count bytes to a binary file pchBinName from the loaded DLL pchDllName with this function:#include #include ...void DumpDll(PCHAR pchDllName,PCHAR pchBinName,size_t count){ FILE *fiDataFile=NULL; size_t num_written; PCHAR pchTestLinkage=NULL; HMODULE hGlob=NULL; if((fiDataFile=fopen(pchBinName,"wb"))==NULL) return ; if((hGlob=GetModuleHandle(pchDllName))==NULL) return; if((pchTestLinkage=(PCHAR)GetProcAddress( hGlob,"Linkage"))==NULL) return; num_written=fwrite( pchTestLinkage, sizeof(char), count, fiDataFile ); fclose(fiDataFile);}If count is too big it will crash FS! A close inspection with a hexeditor should give you the necessary offset soon (pathnames are easily recognizeable). Obtained offsets are only valid for one FS version.Arne Bartels

Share this post


Link to post
Share on other sites
Guest bartels

OK not in global.dll, I just checked.Arne Bartels

Share this post


Link to post
Share on other sites

Wow. Function pasted to text file for future reference. Thanks Arne. Don't spend too much time on this - all I was hoping to achieve was to have a gauge look for an initialization file in the aircraft's panel folder, as well as in the main Gauges folder. It would be a nice feature, but it's not critical.Thanks again!Doug

Share this post


Link to post
Share on other sites
Guest bartels

I tried the approach to check (A:TITLE,string) -> title(A:ATC ID,string) -> atc_id(A:ATC TYPE,string) -> ui_manufacturer(A:ATC AIRLINE,string)-> atc_airline (if exists)Usage:add findcfg.c to your workspace (or include it)add:#include "findcfg.h"static char cfgname[MAX_PATH+1] = "", section[MAX_PATH+1] = "";void FSAPI gauge_cb( PGAUGEHDR pgauge, SINT32 service_id, UINT32 extra_data ){ BOOL result=FALSE; switch(service_id) { case PANEL_SERVICE_CONNECT_TO_WINDOW: result=FindAircraft(cfgname,MAX_PATH,section,MAX_PATH); break; }}to your gaugeIf FindAircraft finds the aircraft.cfg, it returns TRUE and "cfgname" contains the full pathname,"section" the section associated with the current aircraft("fltsim.x"). There is NO check if there more than one aircraft matching to this parameter combination. It might also take some time, if there are really a lot of aircraft installed.Arne Bartels

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...