Hi,
I'm trying to call a LV DLL from a VC++ application
by using the LoadLibrary and GetProcAddress functions.
The DLL contains a simple sum function. The Library is
loaded correctly, but the result is always 0.0000.
I have loaded a VC++ DLL in a similar way and it works
correctly. Also, I have tested the DLL by loading it in LV,
and it works correctly. The calling convention is defined
to be stdcall in LV Application Builder.
I have also tried
this solution, but I will get a compiler error
from one the header files that are created by the LV when
the DLL is made. The error comes from this line
typedef char int8;and the error states that
..\fundtypes.h(107) : error C2371: 'int8' : redefinition; different basic typesIf someone knows of newer tutorial(for LV 8.2) or knows how to use those
LoadLibrary and GetProcAddress function for LV DLLs, I will appreciate the
information greatly.
Below is the code that I'm using for loading the LV DLL.
Thanks
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
HINSTANCE LVLib = LoadLibrary(TEXT("Testdll"));
typedef double (__stdcall *MYPROC)(double, double);
if (LVLib != NULL)
{
MYPROC ProcAdd = (MYPROC) GetProcAddress(LVLib, "Add");
if (ProcAdd != NULL)
{
double d = (ProcAdd)(5.5, 6.6);
printf("sum = %f\n", d);
}
else
printf("Invalid function pointer\n");
}
else
printf("Failed to load the library\n");
return 0;
}