Jump to content
The simFlight Network Forums
Danto

Starting FSX from VB.NET etc

Recommended Posts

Hi guys,

 

I am a complete newb to FSUIPC and want to congratulate firstly on the DLL for .NET.

 

Now, my questions maybe a bit vague but I will try my best.

 

1. Is it possible to click a button in Visual Basic and open FSX using FSUIPC?

 

2. Can I, for example, edit the fsx.cfg file in VB by connecting to FSUIPC?

 

I may have more questions later but for now, any help would be appreciated.

 

Thanks,

Dan

Share this post


Link to post
Share on other sites

Hi Dan,

 

 

1. Is it possible to click a button in Visual Basic and open FSX using FSUIPC?

 

 

 

FSUIPC doesn't allow you to open FSX because FSUIPC is loaded by FSX. So FSX needs to be running for FSUIPC to be running.

 

You can however use normal Visual Basic to open any program on the computer. This example shows opening FSX using a hard-coded path. In your application you would get the path using one of two methods which I will explain below:

 

You need to add the following line to the top of the file:

Imports System.IO

This is the code that will launch FSX:

        Dim fsxFilePath As String = "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\FSX.exe"
        Dim processInfo As ProcessStartInfo = New ProcessStartInfo()
        processInfo.FileName = fsxFilePath
        processInfo.WorkingDirectory = Path.GetDirectoryName(fsxFilePath)
        Dim fsx As Process = Process.Start(processInfo)

If you don't want to hard-code the path (e.g. because your program will be used by other people), the easiest way is to ask the user to enter the path (or find it using an OpenFileDialog control that you add to the form). There are many resources on the internet and YouTube showing how to use this dialog control. It's beyond the scope of the support I can offer on this forum.

 

You could also get the path from the registry but there seems to be many places you need to look as each version of Flight Sim seems to use a different registry key. There is a discussion about it here:

 

http://www.fsdeveloper.com/forum/threads/registry-keys-fsx-fsx-se-p3dv1-p3dv2.432633/

 

If you want to go this route, you'll need to lookup how to access the registry from Visual Basic.NET. Again there are lot of resources out there.

 

 

2. Can I, for example, edit the fsx.cfg file in VB by connecting to FSUIPC?

 

 

 

No, this is not something FSUIPC was designed to do.

 

You can edit files using plain Visual Basic; there are lots of resources on how to do this. However, the .CFG file is formatted like an .INI file. There are .NET libraries available that make editing .INI files easier (it's quite a lot of code to write yourself otherwise). Here is one I found that has examples (and source code I think) in VB.NET, but there may be better ones out there.

 

http://www.codeproject.com/Articles/21896/INI-Reader-Writer-Class-for-C-VB-NET-and-VBScript

 

 

If you have any more questions just ask. I can't teach VB.NET or do general programming support here, but I will point you in the right direction as I've done here. I do however give detailed help and code examples regarding the use of my DLL.

 

If you have general FSUIPC questions (not .NET related) then it's best to post those up in the main support forum for Pete to answer.

 

Paul

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.