• 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 SimConnect & Borland C++ Builder problems

Messages
14
Country
russia
Hi, guys...
My simple dll example is failed when inserting SimConnect_Open function.
I inserted logging operators into definitions of DLLMain, DLLStart and DLLStop functions.
Logging is failed when SimConnect_Open function is presented in the code. I have an impression that my dll is bypassed at all.
After comment-out SimConnect_Open function my dll works as usual and logging performs. Of course, I can't connect to SimConnect :(
What wrong I do?

In MSVC++ 2010 Express all works perfectly.
Code:
#pragma argsused
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
	// log we're here
	FS_Log("DLLMain_in");

	// first call?
	if (fwdreason!=DLL_PROCESS_ATTACH)
		return FALSE;
	
	// done
	FS_Log("DLLMain_out");
	return TRUE;
}

int __stdcall _export DLLStart()
{
	FS_Log("DLLStart");
	// open connection to local SimConnect server
	HRESULT hr;
	[COLOR="Red"]hr = SimConnect_Open(&hSimConnect, "Dll4Fsx", NULL, 0, NULL, SIMCONNECT_OPEN_CONFIGINDEX_LOCAL);[/COLOR]	if (hr == S_OK)
	FS_Log("Connect success");
	else FS_Log("Connect failed");

	// register callback routine for message processing
//	SimConnect_CallDispatch(hSimConnect, SimConnectProcess, NULL);
  
	return 0;
}

int __stdcall _export DLLStop()
{
	FS_Log("DLLStop");
	return 0;
}
 
The following Borland C++ builder 4 code works for me in an .exe file:
Code:
//---------------------------------------------------------------------------
// Constructor
__fastcall TfrmMain::TfrmMain(TComponent* Owner)
   : TForm(Owner)
{
// Set menu status
mnuSimConnectConnect->Enabled = true;
mnuSimConnectDisconnect->Enabled = false;
mnuSimConnectExit->Enabled = true;

// Initialise
hSimConnect = NULL;
Connected = false;
sbMain->SimpleText = "Not connected to FSX"; 
}

//---------------------------------------------------------------------------
// Respond to button Menu|Connect click
void __fastcall TfrmMain::btnConnectClick(TObject *Sender)
{
// Don't try to connect if already conected
if (!Connected)
   {
   if (SUCCEEDED(SimConnect_Open(&hSimConnect,
                                  "Open and Close",
                                  NULL,
                                  0,
                                  0,
                                  0)))
        {
        sbMain->SimpleText = "Connected to Flight Simulator"; 
        Connected = true;
        mnuSimConnectConnect->Enabled = false;
        mnuSimConnectDisconnect->Enabled = true;
        }
    else 
        {
        sbMain->SimpleText = "Error: Can't connect to FSX";
        }        
    }            
}

Have you included the appropriate library file (.lib) and manifest in your your project?
 
Last edited:
Alas...
I have exe example works too, but not dll...
I found when SimConnect.dll and fsx.exe are placed togerther one works perfectly.
SimConnect.h, SimConnect.lib and manifest file are included of course...
 
Last edited:
Ok, I have rewrote manifest file and dll works perfectly now...
But one big question appears:
My Borland's lib and h files are downloaded from Internet (Borland_SimConnect.zip) and these for SimConnect 10.0.60905.0 version (RTM). Now SimConnect 10.0.61259.0 is more urgent and modern.
How can I get them? I have tried to convert SimConnect.lib build 61259 by using coff2omf.exe and IMPLIB.EXE but it was unsuccessful. The Dll becomes unworking. (Of course, I replaced 61259 number in manifest file).
What else can I do?

Added:
sxstracer.exe writes in log (for exe project which does not work too with 61259 SimConnect):
INFO: Parsing Manifest File C:\Users\Dmitry\Documents\Borland Studio Projects\FSDeveloperCode\Release_Build\Project1.exe.
INFO: Manifest Definition Identity is (null).
INFO: Reference: Microsoft.FlightSimulator.SimConnect ,processorArchitecture="x86",publicKeyToken="67c7c14424d61b5b",type="win32",version="10.0.61259.0"
INFO: Resolving reference Microsoft.FlightSimulator.SimConnect ,processorArchitecture="x86",publicKeyToken="67c7c14424d61b5b",type="win32",version="10.0.61259.0".
INFO: Resolving reference for ProcessorArchitecture WOW64.
INFO: Resolving reference for culture Neutral.
INFO: Applying Binding Policy.
INFO: No publisher policy found.
INFO: No binding policy redirect found.
INFO: Begin assembly probing.
INFO: Did not find the assembly in WinSxS.
INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.FlightSimulator.SimConnect \10.0.61259.0__67c7c14424d61b5b\Microsoft.FlightSimulator.SimConnect .DLL.
INFO: Did not find manifest for culture Neutral.
INFO: End assembly probing.
INFO: Resolving reference for ProcessorArchitecture x86.
INFO: Resolving reference for culture Neutral.
INFO: Applying Binding Policy.
INFO: No publisher policy found.
INFO: No binding policy redirect found.
INFO: Begin assembly probing.
INFO: Did not find the assembly in WinSxS.
INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.FlightSimulator.SimConnect \10.0.61259.0__67c7c14424d61b5b\Microsoft.FlightSimulator.SimConnect .DLL.
INFO: Attempt to probe manifest at C:\Users\Dmitry\Documents\Borland Studio Projects\FSDeveloperCode\Release_Build\Microsoft.FlightSimulator.SimConnect .DLL.
INFO: Attempt to probe manifest at C:\Users\Dmitry\Documents\Borland Studio Projects\FSDeveloperCode\Release_Build\Microsoft.FlightSimulator.SimConnect .MANIFEST.
INFO: Attempt to probe manifest at C:\Users\Dmitry\Documents\Borland Studio Projects\FSDeveloperCode\Release_Build\Microsoft.FlightSimulator.SimConnect \Microsoft.FlightSimulator.SimConnect .DLL.
INFO: Attempt to probe manifest at C:\Users\Dmitry\Documents\Borland Studio Projects\FSDeveloperCode\Release_Build\Microsoft.FlightSimulator.SimConnect \Microsoft.FlightSimulator.SimConnect .MANIFEST.
INFO: Did not find manifest for culture Neutral.
INFO: End assembly probing.
ERROR: Cannot resolve reference Microsoft.FlightSimulator.SimConnect ,processorArchitecture="x86",publicKeyToken="67c7c14424d61b5b",type="win32",version="10.0.61259.0".
ERROR: Activation Context generation failed.
End Activation Context Generation.
May be manifest file needs in additional information?
Now it looks as:

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect ' version='10.0.61259.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' />
</dependentAssembly>
</dependency>
</assembly>
 
Last edited:
For what it's worth, here the manifest I used for my .exe file. It works with both XP and Win7. I have C++Builder installed in C:\Borland, not C:\|Program Files. Mine has an additional <dependency> but not a <trustinfo> secvtion.

Code:
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect' version='10.0.61259.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' />
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
</assembly>

Probably a silly question, but you did compile the manifest into a .res file and added that to your project?
 
I've always used the following calling convention for DLL functions in Borland C++ Builder

Code:
extern "C" bool __export __pascal SC_Connect(void)

"C" to avoid C++ name mangling to enable the dl to be used with other compilers

__pascal to enforce the WIn32 API method of calling functions, again for compatibility.
 
Last edited:
Dear sir mgh, thank you for your participation...

Hmmm, now I have approached to be crazy :D
So, I have my Borland IDE (BDS2006 Turbo) in C:\Borland too (I use Windows 7, UAC is off).
I will say about behavior of your exe-example only (see 2nd message here):
1) exe-example (compiled for using with SimConnect RTM, 10.0.60905.0)works perfectly in my main working OS (where IDE and sims are installed) and in my clean virtual OS (WinXPsp3, sims are installed only). In both cases manifest file looks as I shown above in my post.
2) exe-example (compiled for using with SimConnect SP2, 10.0.61259.0)
works perfectly in my virtual OS only (clean WinXPsp3 and sims (9&X) are installed only). Oh, by the way, in virtual OS dll-example works perfectly too. In both these cases manifest file looks as I shown above in my post.
In my main working OS exe-example (and dll) does not work at all. Various logs contains this information:
Activation context generation failed for "C:\Users\Dmitry\Documents\Borland Studio Projects\FSDeveloperCode\Release_Build\Project1.exe.Manifest". Dependent Assembly Microsoft.FlightSimulator.SimConnect ,processorArchitecture="x86",publicKeyToken="67c7c14424d61b5b",type="win32",version="10.0.61259.0" could not be found. Please use sxstrace.exe for detailed diagnosis.
ERROR: Cannot resolve reference Microsoft.FlightSimulator.SimConnect ,processorArchitecture="x86",publicKeyToken="67c7c14424d61b5b",type="win32",version="10.0.61259.0".
Most probably SimConnect SP2's DLL not found by executable borland files.
At the same time dll compiled in Visual Studio 2008 Express edition (for using with SimConnect SP2) works well...

Of course, I tried to use your manifest file also, but it was unsuccessfully, with same results...
 
Wow! It's works! :)
The reason of incorrect work was my inattention. I left oldest manifest file (with incorrect code) in a folder where released build exe was placed.

mgh, thanks you for hint about manifest file.
 
What libraries are needed for proper functioning borland' dll-projects on end systems?
I again encounter a similar problem - dispatch (callback) function in my dll is not processed on clean system (where sims are only installed without IDE).
SimConnect_CallDispatch function perfoms with S_OK results, but code in dispatch (callback) function (for example, "dispatch" in SimConnect_CallDispatch(hSimConnect, dispatch, NULL) don't perfoms at all. I build my project with "Use dynamic RTL" option unchecked and with "Build with runtime packages" unchecked too.
On working system (where IDE is installed) all works well... I sure this is not SimConnect problem...
 
Last edited:
Back
Top