I'm very new to C++. I am trying to use functions from a DLL to communicate to a device serially. The DLL supplied had instructions for communicating via Delphi, VB6 or VB.NET but not C++ (which I'm trying to learn/write my project in).
For instance, for VB6 the for one of the functions, the instructions say:
Declare Function HOPPER_OPENCOM Lib "CASH.DLL" (ByVal HOPPER_COMPORT As Long) As Long
Through following tutorials I have managed to successfully create a .lib from the cash.dll and then import the dll and lib into my solution.
I have also gleaned from a helpful member here that I can "simply" use __stdcall in order to access/use the functions in the DLL.
In my project I just wanted to test call the HOPPER_OPENCOM function to see if I could communicate with it (if it returns a 1 then it's working). I put some code at the top of my function to test it but it's not working...
#define WINAPI __stdcall
typedef int(__stdcall *HOPPER_OPENCOM)(int);
BOOL CALLBACK SearchProc(HWND hWnd, LPARAM lParam)
{
HOPPER_OPENCOM myFuncPtr;
int test = myFuncPtr(1); // This doesn't work
myFuncPtr(1); // This doesn't work either
... // rest of code
My understanding was that HOPPER_OPENCOM was a 'pointer' to the function of the same name in the DLL and that myFuncPtr
would somehow point to the start of that function in the DLL?
I'm getting myself tied up in knots here and worried that I've got completely the wrong end of the stick. I've looked at MSDN and other resources but can't find anything written simplistically/clear enough for me to understand.
Anyone clarify this for me please?