Results 1 to 1 of 1
-
07-10-2009, 08:33 PM #1
- Join Date
- Jul 2009
- Location
- Australia
- Posts
- 19
SimConnect Open/Close server code C++
Here is the code I have got working for opening and closing the server after a pause, import it into MS VS C++ after creating and setting up the project.
Code:// SimConnectServer.cpp : Defines the entry point for the console application. //Opens a connection to the server for 9000 ms, reports that the connection is alive //and then closes the connection again. //Written by MechDave using SDK Samples Open and Close as a code base. #include
#include #include #include #include "SimConnect.h" HANDLE hSimConnect = NULL; void Connect() { HRESULT hr; if (hSimConnect == NULL) { printf("Requesting a SimConnect connection"); hr = SimConnect_Open(&hSimConnect,"Connect to Server for 9000 ms",NULL,0,0,SIMCONNECT_OPEN_CONFIGINDEX_LOCAL ); if (hr != S_OK) { //FSX may be inactive printf("\nError %d", hr); } else { //Connection with FSX initialised printf("\nConnection request being processed (%d)", hSimConnect); //When connection process complete, an OPEN message will be recieved. } } } void Disconnect() { HRESULT hr; hr = SimConnect_Close(hSimConnect); printf("\nDisconnected from Flight Simulator"); if (hr != S_OK) { printf("\nFailed to connect to Flight Simulator"); } else { printf("Disconnection Sucessful"); } } int __cdecl _tmain(int argc, _TCHAR* argv[]) { Connect(); Sleep(9000); Disconnect(); return 0; }
Similar Threads
-
Can't close throttle
By Barrykensett in forum General Microsoft Flight Simulator 10 (FSX)Replies: 0Last Post: 12-17-2010, 05:34 PM -
Overhead close ups
By Clive in forum My Cockpit UpdateReplies: 4Last Post: 07-12-2010, 01:13 PM -
simconnect ?
By Mr. Midnight in forum General Builder Questions All Aircraft TypesReplies: 1Last Post: 11-01-2009, 12:04 AM -
SimConnect GetPlaneHeading
By MechDave in forum I/O Interfacing Hardware and SoftwareReplies: 13Last Post: 10-04-2009, 04:04 AM -
C# programming and Simconnect
By kranky in forum I/O Interfacing Hardware and SoftwareReplies: 2Last Post: 05-14-2009, 06:51 PM
Hi...realize this has been a long time, but I'm heading down the path of building my own 777...
B777 Overhead Panel Design