Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Get simulator version

Featured Replies

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

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

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

  • 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

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

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

 

 


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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.