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.

Getting the absolute path to the STN folder in any language

Featured Replies

  • Commercial Member

We had an earlier thread regarding getting the name of the folder that holds the Flight Simulator saves files (thanks Ed!). While this thread did return the correct name, it didn't give the absolute path. The following code will give you the absolute path - I'm certain that there are easier ways of doing it than this but each function returns information that is useful in its own right. I'm also aware that there are safer ways of copying the strings (e.g. strcpy_s etc.), so if you use this code feel free to update/upgrade it. Finally (just for Beatle (Tim)!) I'm also aware that there's a loose handle still floating around in getSimVer() which I really should do something about.Two other people contributed to this: n4gix (Bill) and WarpD (Ed). -Dai

#include <string.h>#include <windows.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <shlobj.h>int simVer=-1;char simPath[MAX_PATH]="";char dll_path[MAX_PATH]="";char FSFilesPath[MAX_PATH]="";char docPath[MAX_PATH]="";char stnPath[MAX_PATH]="";//**************************************************************************//Get simulator version//**************************************************************************void getSimVer(){	WIN32_FIND_DATA ffd; // file information struct  HANDLE sh;  char searchPath[MAX_PATH];// No need for a directory qualifier because all DLL's run within// the simulator's main folder as they run as children of the main simulator executable.  strncpy(searchPath,"fsx.exe\0",8);  sh=FindFirstFile(searchPath,&ffd);  if(sh==INVALID_HANDLE_VALUE)  {	strncpy(searchPath,"fs9.exe\0",8);	sh=FindFirstFile(searchPath,&ffd);	if(sh==INVALID_HANDLE_VALUE)simVer=-1;	else simVer=9;  }  else simVer=10;	return;}//**************************************************************************//Get simulator path - must be preceeded by getSimVer()//**************************************************************************void getSimPath(){	HKEY hkey;	DWORD dwKeytype;	DWORD dwLenPath=200;// Get the FS version if we don't already have it	if(simVer==-1)getSimVer();// Read the installation path from the registry	if(simVer==9)	{		RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Microsoft Games\\Flight Simulator\\9.0",0,KEY_QUERY_VALUE,&hkey );		RegQueryValueEx(hkey,"EXE Path",NULL,&dwKeytype,(BYTE*)&simPath,&dwLenPath);		RegCloseKey(hkey);	}	else	if(simVer==10)	{		RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0",0,KEY_QUERY_VALUE,&hkey );		RegQueryValueEx(hkey,"SetupPath",NULL,&dwKeytype,(BYTE*)&simPath,&dwLenPath);		RegCloseKey(hkey);	}	return;}//**************************************************************************//Get saved FS stn files path//**************************************************************************void getSTN(){// Get the localised name of the personal folder (e.g. English is 'My Documents')	if(SUCCEEDED(SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,0,docPath)))	{// Get the path to the sim if we don't already have it		if(strlen(simPath)<2)getSimPath();// Get the name of the FS STN folder from the language.dll		strncpy(dll_path,simPath,sizeof(simPath));		strncat(dll_path,"\\language.dll\0",15);		HINSTANCE hInstLang = LoadLibrary(dll_path);		if (hInstLang)		{			LoadStringA(hInstLang, 36864, &FSFilesPath[0], 128);// FSFilesPath now contains the value of 'Flight Simulator Files" based on language installation			FreeLibrary(hInstLang);// Concatenate all of the information to get the absolute path to the STN folder			strncpy(stnPath,docPath,sizeof(docPath));			strncat(stnPath,"\\",1);			strncat(stnPath,FSFilesPath,sizeof(FSFilesPath));// Ensure the string is terminated properly			stnPath[sizeof(stnPath)-1]=0;// For some reason the above method occasionally fails to terminate a string// correctly. If so, the following crude method has never been known to fail.// Don't quote me because when you try it, it won't work :P// stnPath[strlen(stnPath)-1]=0;		}  }}

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.