I am trying to compile a simple CLR C++ using WinForms that displays live information on the screen in a small window. RequestData.cpp was used as an example, and I have had good success with that, but it sends the data to the console rather than a window. I have also been able to successfully compile a CLR C++ WinForm that draws a simple window.
There are issues trying to combine the two. The SimConnect_Open(&BFC, "Request Data", NULL, 0, 0, 1) call at the end is where the problems start. If I comment out this line, the code compiles no problem. It could be a linking problem, but I have triple-checked all the SDK setup steps. Does anyone have experience with C++ WinForms and SimConnect?
Thanks
Code: Select all
Code Description
LNK2019 unresolved external symbol __imp_SendMessageW referenced in function "enum CC_RESULT __cdecl CommClient_Open(void * *,unsigned long)" (?CommClient_Open@@YA?AW4CC_RESULT@@PEAPEAXK@Z)
LNK2019 unresolved external symbol __imp_PostMessageW referenced in function "public: virtual void __cdecl ClientClient::Close(enum CLIENTERROR,unsigned long)" (?Close@ClientClient@@UEAAXW4CLIENTERROR@@K@Z)
LNK2019 unresolved external symbol __imp_FindWindowW referenced in function "enum CC_RESULT __cdecl CommClient_Open(void * *,unsigned long)" (?CommClient_Open@@YA?AW4CC_RESULT@@PEAPEAXK@Z)
LNK2019 unresolved external symbol __imp_GetWindowThreadProcessId referenced in function "enum CC_RESULT __cdecl CommClient_Open(void * *,unsigned long)" (?CommClient_Open@@YA?AW4CC_RESULT@@PEAPEAXK@Z)
LNK2019 unresolved external symbol __imp_RegCloseKey referenced in function "bool __cdecl GetRegistryPort(bool,wchar_t *)" (?GetRegistryPort@@YA_N_NPEA_W@Z)
LNK2019 unresolved external symbol __imp_RegOpenKeyExW referenced in function "bool __cdecl GetRegistryPort(bool,wchar_t *)" (?GetRegistryPort@@YA_N_NPEA_W@Z)
LNK2019 unresolved external symbol __imp_RegQueryValueExW referenced in function "bool __cdecl GetRegistryPort(bool,wchar_t *)" (?GetRegistryPort@@YA_N_NPEA_W@Z)
LNK2019 unresolved external symbol __imp_CoTaskMemFree referenced in function "enum CC_RESULT __cdecl CommClient_Open(void * *,unsigned long)" (?CommClient_Open@@YA?AW4CC_RESULT@@PEAPEAXK@Z)
LNK2019 unresolved external symbol SHGetKnownFolderPath referenced in function "enum CC_RESULT __cdecl CommClient_Open(void * *,unsigned long)" (?CommClient_Open@@YA?AW4CC_RESULT@@PEAPEAXK@Z)
LNK1120 9 unresolved externals
Code: Select all
#include "MyForm.h"
#include <Windows.h>
#include <tchar.h>
#include <stdio.h>
#include "SimConnect.h"
#include <strsafe.h>
using namespace System;
using namespace System::Windows::Forms;
int quit = 0;
HANDLE hSurface = NULL;
HANDLE BFC = NULL;
struct Struct1
{
char title[256];
double kohlsmann;
double altitude;
double latitude;
double longitude;
};
enum EVENT_ID {
EVENT_SIM_START,
};
enum DATA_DEFINE_ID {
DEFINITION_1,
};
enum DATA_REQUEST_ID {
REQUEST_1,
};
void CALLBACK MyDispatchProcRD(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)
{
switch (pData->dwID)
{
case SIMCONNECT_RECV_ID_EVENT:
default:
{
SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE*)pData;
switch (pObjData->dwRequestID)
{
//default:
case REQUEST_1:
{
DWORD ObjectID = pObjData->dwObjectID;
Struct1 *pS = (Struct1*)&pObjData->dwData;
if (SUCCEEDED(StringCbLengthA(&pS->title[0], sizeof(pS->title), NULL))) // security check
{
printf("\nObjectID=%d title=\"%s\"\nLat=%f Lon=%f Alt=%f Kohlsman=%.2f", ObjectID, pS->title, pS->latitude, pS->longitude, pS->altitude, pS->kohlsmann);
}
break;
}
}
break;
}
case SIMCONNECT_RECV_ID_QUIT:
{
quit = 1;
break;
}
}
}
void testDataRequest()
{
HRESULT hr;
SimConnect_Open(&BFC, "Request Data", NULL, 0, 0, 1);
{
}
}