Here's a simple C++ example that calls ListDevices from the DLL:
- Code: Select all
#include <stdio.h>
#include <windows.h>
typedef int (*ListDevicesFP)(int*);
int main() {
// load the UC100 DLL
HINSTANCE hGetProcLib = LoadLibrary(".\\UC100.dll");
if (!hGetProcLib) {
printf("could not load the dynamic library\n");
return 1;
}
// get the function we want, ListDevices in this example
ListDevicesFP func = (ListDevicesFP)GetProcAddress(hGetProcLib, "ListDevices");
if (!func) {
printf("could not locate the function\n");
return 1;
}
// call the DLL function
int x = 0;
int r = func(&x);
printf("%d\n", r);
return 0;
}
If you're running on a 32bit system, make sure you use the 32bit C++ compiler, and vice versa for a 64bit system.
Hope this helps