Jump to content
Sign in to follow this  
dragonflightdesign

Get simulator version

Recommended Posts

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;
}

Share this post


Link to post
Share on other sites

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 Aviation
My Playland - I69

Share this post


Link to post
Share on other sites

Have a look at GetFileVersionInfo on MSDN. That's what that API is all about.

Share this post


Link to post
Share on other sites

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 Aviation
My Playland - I69

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 Aviation
My Playland - I69

Share this post


Link to post
Share on other sites

 

 


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

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