I have a dll generated from a vb project, that i want to use in Cpp project, my question is that's possible, and how? I tried to Load my dll and call my function as i do with Cpp dll but it doesn't word , here is the code i tried :
#ifdef __cplusplus
extern "C" {
#endif
typedef short (CALLBACK* GetMotor1Position)();
#ifdef __cplusplus
}
#endif
int main(int argc, char *argv[])
BOOL freeResult, runTimeLinkSuccess = FALSE;
GetMotor1Position MotorPosPtr = NULL;
HINSTANCE hGetProcIDDLL = LoadLibrary(_T("C:/Users/Downloads/Vb/Vb-DLL/bin/Debug/Mydll.dll"));
if (hGetProcIDDLL == NULL) {
qDebug() << "Library MyLibrary.dll not found";
}
if (NULL != hGetProcIDDLL) {
MotorPosPtr = (GetMotor1Position)GetProcAddress(hGetProcIDDLL,
"GetMotor1Speed");
if (runTimeLinkSuccess = (NULL != MotorPosPtr))
{
short a = GetMotor1Position () ; // he never get access here, bcs MotorPosPtr still NULL
}
freeResult = FreeLibrary(hGetProcIDDLL);
}
}