In-Process DLL SimConnect Client Sample

Hey All,

In my last blog post, I mentioned we had a new download area with some new samples and that I had a couple of samples that needed some minor cleaning up and then they would be posted there.  Well one of those has been posted there, the In-Process DLL SimConnect Client sample (actually, it was posted almost 2 months ago, I’m just now getting around to blogging about it :-> ).

I wrote this sample because I noticed we didn’t have any in-proc DLL samples in the SDK. 

First off, what does that mean, In-Process?  It means that the DLL SimConnect client is loaded within the ESP/FSX process space instead of within its own process space like an external .EXE based SimConnect client.  This has some good points and some bad points (depending on what you are trying to do). 

The good points are that you register a callback function once, right after the SimConnect_Open call, and that callback will get called directly by the Server Side SimConnect code when messages are available for your client.  This bypasses all of the networking layer (ie no TCP/IP, no Named Pipes, you get a direct function call into your code from the Sim side code).  This also means you don’t have to run your own HWND based message pump, you don’t need to use a background thread with an Event Handle, you don’t need to use a timer based query scheme, etc – in other words, it makes life much easier.

The bad points are that you can’t really do standard windows based UI this way – well, you can but its not guaranteed to work (DirectX and GDI get into fights with each other sometimes, especially in full screen mode) unless you put the Sim into Dialog Mode first.  You can still add menu items, use the SimConnect_Text function to display both scrolling text and simple "select one of the below" style dialog boxes.  Another bad point, in some folks eyes anyway, is you can only use C++ to write an In-Proc DLL client.  Also, since your client is running within the ESP/FSX process space, if your client code goes nuts (causes a fault of some sort, or goes into an infinite loop) you can take down the entire Sim.

So, if you want to write a client with lots of UI and/or you want to use managed code, stick with an out-of-proc EXE style client, but if you can live within the above restrictions, then an in-proc DLL style client may be the way to go.

Things that would make a good in-proc DLL style client:

  • adding Custom Action support for missions
  • transferring data between the Sim and some external app
  • interfacing custom hardware to the Sim

 

What the sample does

The sample is fairly simple in what it does.  It adds a couple of menu items to the AddOn menu (Show Weather Menu and Show Time Menu).  Selecting one of these menu items will use SimConnect_Text to show a "Select on of these options" dialogs, the weather dialog allows you to query the dialog from either the current location or from SeaTac, the time dialog lets you set the time to either 12:00 Local or 00:00 Zulu.  Selecting one of the weather reporting options will query for the Metar string at the requested location, and then use SimConnect_Text to display the Metar string as a scrolling message across the top of the screen.  Selecting one of the time set options will, surprisingly enough, set the time accordingly :->

Hopefully a few of you will find the sample useful.  If you do, or you have any questions about it, drop by the Microsoft ESP Forum to discuss it/ask questions.

Tim "Beatle" Gregson

Advertisements

5 Comments on “In-Process DLL SimConnect Client Sample”

  1. Simon says:

    Hi Tim,Thanks for the in-process sample.  Concerning the pros and cons, one thing I wonder if I can get on someone\’s radar for the future is the loss of sound when FSX does not have application focus.  This happens for out of process managed C# applications.  So I have a sophisticated UI in C# (Super Traffic Board) that wants to run simultaneously beside FSX running in window mode.  As soon as the user clicks my UI, it gets focus and off goes the sound from FSX.  This seems a shame since it is possible to configure the simulator not to pause on a task switch.So this does not become an obstacle for c# applications in the future (and otherwise it was a real pleasure to develop STB in c#), perhaps this could get some attention in Train Sim or FS11?Many thanksSimon


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s