August 20, 201411 yr Commercial Member I think it was Bill who originally came up with this module waybackwhen. It worked fine for donkey's years, but since I added a check for Prepar3D it now always returns 'FS9' even if running in FSX or Prepar3D. I've checked and re-checked the definition of FindFirstFile and it's still my understanding that it runs as a child of the calling executable and not the entire system; however, checking the entire system is what it now seems to be doing. -Dai //************************************************************************** //Get simulator version //************************************************************************** void getSimVer() { WIN32_FIND_DATA ffd; // file information struct HANDLE sh; char searchPath[512]; // no need for a directory qualifier because all DLL's run within // the simulator's main folder since they run as children of the main simulator executable. strncpy(searchPath,"fs9.exe\0",8); sh=FindFirstFile(searchPath,&ffd); if(sh==INVALID_HANDLE_VALUE) { strncpy(searchPath,"fsx.exe\0",8); sh=FindFirstFile(searchPath,&ffd); if(sh==INVALID_HANDLE_VALUE) { strncpy(searchPath,"prepar3d.exe\0",13); sh=FindFirstFile(searchPath,&ffd); if(sh==INVALID_HANDLE_VALUE)simVer=-1; else simVer=8; // Random designator for Prepar3D } else simVer=10; } else simVer=9; return; }
August 20, 201411 yr Commercial Member It's all backwards. Check for newer sims first... because if you go look in their folder... you might find FS9.exe, FSX.exe, etc. Especially with users who are 'cheating' to run addons that only work with FS9 or FSX and aren't supposed to work with Prepar3D. Estonia Migration Tool I believe makes a fake FS9/FSX file as well. Lots of cheating going on. :wink: Ed Wilson Mindstar AviationMy Playland - I69
August 20, 201411 yr Commercial Member Have a look at GetFileVersionInfo on MSDN. That's what that API is all about. That is overkill for what one's attempting to do with this code which is to decide if you're in FS9, or FSX or Prepar3D. Kinda like using a flamethrower to kill a fly when a flyswatter will do. :smile: Ed Wilson Mindstar AviationMy Playland - I69
August 20, 201411 yr Author Commercial Member It's all backwards. Check for newer sims first... because if you go look in their folder... you might find FS9.exe, FSX.exe, etc. Especially with users who are 'cheating' to run addons that only work with FS9 or FSX and aren't supposed to work with Prepar3D. Estonia Migration Tool I believe makes a fake FS9/FSX file as well. Lots of cheating going on. :wink: Thanks Ed... that will really, really teach me NOT to re-arrange perfectly working code. It was written that way for a reason. -Dai
August 21, 201411 yr Depending on exactly what you want to do char ExecPath[MAX_PATH]; GetModuleFileNameA(NULL, ExecPath, MAX_PATH); will retrieve the path of the executable file of the current process in ExecPath.. Gerry Howard
August 21, 201411 yr Commercial Member Depending on exactly what you want to do char ExecPath[MAX_PATH]; GetModuleFileNameA(NULL, ExecPath, MAX_PATH); will retrieve the path of the executable file of the current process in ExecPath.. Still not what is needed. Why do people always think code needs total replacement simply because someone borked what was already written? Ed Wilson Mindstar AviationMy Playland - I69
August 22, 201411 yr Still not what is needed. If you want to decide if you're running FS9, or FSX or Prepar3D, then the code does that when called in a .dll.. Gerry Howard
Create an account or sign in to comment