• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Find scenery.cfg

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
34,328
Country
netherlands
Hi all,

I'm working on a new tool that will run when FS starts, using the exe.xml file. I'm wondering what is the best way to find the scenery.cfg file in that case.

The tool can run from FSX or P3D v2, so how do I know which folder to use to find the scenery.cfg file?

The best approach I can think of now is check what exe is in the FS folder (I know that folder because that's the working folder when started by FS). But it feels a bit clumsy to do it like this. Am I missing another approach?
 
I think this is just as clumsy...
Call FindWindow to get a handle to the FS Window.
Call GetWindowThreadProcessID to get the FS process ID.
Call OpenProcess to get a handle to the FS process.
Call GetModuleFileNameEx to get the path qualified name of the FS process.
 
Why not have a choice for the user to select what sim they are using and have it link to the correct location. Or just have a location field that the user can enter the location of their sim.
 
Hi,

The idea is that the tool automatically runs at FS startup and it should be installed as part of addons. So idealy there is no user involvement at all, that's why I prefer to not let the user select things.

Maybe I could let the installer of the tool put some command line arguments in the exe.xml file, that I can use as pointers.
 
...
Maybe I could let the installer of the tool put some command line arguments in the exe.xml file, that I can use as pointers.

That is the advantage of what I suggested. You determine FS location at run time, rather than at install time, and it doesn't matter where the user has installed either FS or your add-on.
 
Hi,

But the idea is that the tool runs automatically when FS starts anyway. So the exe.xml file needs to be edited by the installer to achieve that. So adding some parameter in that file should be OK.

Then it should indeed not matter anymore where FS is installed and where the tool is installed (although the tool will probably go in the FS folder soemwhere to keep things easy).
 
You could establish a SimConnect connection to get the simulator version, then use that information to find the relevant scenery.cfg perhaps?
 
used scenery.cfg for FSX, P3D v.1 and P3D v2/3 place in different folder, if using exe.xml you need to find the folder contain exe.xml

FSX
C:\Users\user account name\AppData\Roaming\Microsoft\FSX
P3D v2
C:\Users\user account name\AppData\Roaming\Lockheed Martin\Prepar3D v2
P3D v3
C:\ProgramData\Lockheed Martin\Prepar3D v3

is this possible if find exe.xml address from registry ?
 
I doubt it's practical to look for a file. Many users will have multiple version installed. In fact I currently hold installations for all 5 relevant versions (MSFSX, FSXSE, P3D 1/2/3).

Runtime detection is the best option. From DLL you can just call the running process itself to identify itself, with .exe it's a bit more complicated.
Probably what I would do.

-Install time, put an argument in exe.xml, just fsx or p3d.

-Runtime, first, try to find a running exe according to argument. If not found, try the alternative.

-Once found, determine version, now there are basically two options.
--if you want to connect to SimConnect anyway, just connect and ask.
--if you potentially don't want to connect, get a major and a build version of the executable

Now, depending on version, you can ascertain:
-an FSX with a build version of less than 62000 is an MS FSX.
-an FSX with a build version of more than 62000 is an FSX Steam. (now you need to see if it's standalone or side-by-side)
-a P3D will have a major version fitting the marketed version. 1/2/3
 
Back
Top