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

FSX Scenery Config Program

If you want, instead of asking the user to define the FSX location, you can query the registry for the location.

32 bit key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\microsoft games\flight simulator\10.0
64 bit key: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\microsoft games\flight simulator\10.0

And to get your string, check the value of SetupPath.

There's also a registry entry under HKCU that has the FSX path, but I can't quite remember exactly where right now.
 
If you want, instead of asking the user to define the FSX location, you can query the registry for the location.

32 bit key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\microsoft games\flight simulator\10.0
64 bit key: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\microsoft games\flight simulator\10.0

And to get your string, check the value of SetupPath.

There's also a registry entry under HKCU that has the FSX path, but I can't quite remember exactly where right now.

How exactly would I get the info from the registry back into the string?
 
This is how ADE does it in C#. This is for FSX - there is another for FS9 that I will leave you to figure out if you need it ;)

It is set up as a static read only property but you could change it to a method of course...

Code:
/// <summary>
        /// Accessed the registry to find the current path to FSX
        /// </summary>
        /// <returns>Returns path to FSX or empty string if not found</returns>
        public static string FsxPath {
            get {
                //return string.Empty;
                string path = string.Empty;

                RegistryKey key =
                    Registry.LocalMachine.OpenSubKey(
                        @"Software\Wow6432Node\Microsoft\Microsoft Games\Flight Simulator\10.0");
                if (key != null) {
                    if (key.GetValue("SetupPath") != null) path = (string)key.GetValue("SetupPath");
                }

                key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Microsoft Games\flight simulator\10.0");
                if (key != null) {
                    if (key.GetValue("SetupPath") != null) path = (string)key.GetValue("SetupPath");
                }

                return path;
            }
        }
 
Jon- I really appreciate you showing me how to access the registry values, however this was coded in Visual Basic.net :o

If you know how this could be done in VB, I'd love to know, if not, thanks for the help above :)
 
Jon- I really appreciate you showing me how to access the registry values, however this was coded in Visual Basic.net :o

If you know how this could be done in VB, I'd love to know, if not, thanks for the help above :)

Google C# to VB. I found this one:

http://www.developerfusion.com/tools/convert/csharp-to-vb/


Code:
Public Shared ReadOnly Property FsxPath() As String
	Get
		'return string.Empty;
		Dim path As String = String.Empty

		Dim key As RegistryKey = Registry.LocalMachine.OpenSubKey("Software\Wow6432Node\Microsoft\Microsoft Games\Flight Simulator\10.0")
		If key IsNot Nothing Then
			If key.GetValue("SetupPath") IsNot Nothing Then
				path = DirectCast(key.GetValue("SetupPath"), String)
			End If
		End If

		key = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Microsoft Games\flight simulator\10.0")
		If key IsNot Nothing Then
			If key.GetValue("SetupPath") IsNot Nothing Then
				path = DirectCast(key.GetValue("SetupPath"), String)
			End If
		End If

		Return path
	End Get
End Property

I don't know how good it is since I lost my VB skills rather a long time ago :o

There are several free on-line converters that should work for small code snippets like this :)
 
Last edited:
No problem Michael. Converters can be your friend :) The online ones generally work for small snippets. Converting whole projects is another matter :eek:
 
I believe it! :rotfl:

note: At first that code above didn't want to work, but I found out that you have to put Imports Win.32 above the code :)

Well it is always good to have something to learn Michael ;)
 
using namespace System;
using namespace Microsoft::Win32;

int main( )
{
array<String^>^ key = Registry::CurrentUser->GetSubKeyNames( );

Console::WriteLine("Subkeys within CurrentUser root key:");
for (int i=0; i<key->Length; i++)
{
Console::WriteLine(" {0}", key);
}

Console::WriteLine("Opening subkey 'Identities'...");
RegistryKey^ rk = nullptr;
rk = Registry::CurrentUser->OpenSubKey("Identities");
if (rk==nullptr)
{
Console::WriteLine("Registry key not found - aborting");
return -1;
}

Console::WriteLine("Key/value pairs within 'Identities' key:");
array<String^>^ name = rk->GetValueNames( );
for (int i=0; i<name->Length; i++)
{
String^ value = rk->GetValue(name)->ToString();
Console::WriteLine(" {0} = {1}", name, value);
}

return 0;
}


But oops, your using VB ... I stopped using that a long time ago.
 
Back
Top