martinboecskoer
2008-08-07 13:10:09 UTC
hi,
first of all, thanx for the advice.
i tried to write the dll, that passes the procaddress to the funtion that needs it. i made a dll with the appbuilder that matches the prototype of the callbackfunctio (expet that the returnvalue isnt bool but an uint).
the next thing i have done is to write a dll in visual c++. as i am no programmer at all, i tried to get this done with some books and the internet, but i fail.
i wrote following code:
#include "stdafx.h"
#include <windows.h>
HINSTANCE h = 0;
const char* lib ="MeineDLL.dll";
const char* proc="DLL Funktion";
extern "C" __declspec( dllexport) int myDLLload(LPCWSTR lib)
{
if(h == 0)
{
LPCWSTR lib = libinput;
h = LoadLibrary(lib);
return 0; // ok
}
return 1; // error
}
// übergib addr in LabView der anderen DLL-Funktion
extern "C" __declspec( dllexport) int myDLLgetprocaddr(LPCSTR proc, int* addr)
{
if(h != 0)
{
*addr = (int)GetProcAddress(h, proc);
return *addr != 0; // ok
}
return 1; // error
}
extern "C" __declspec( dllexport) void myDLLFree()
{
FreeLibrary(h);
}
the problem is, that the myDLLload function returns 0 all the time, no mather how i define "lib". and i think that is the reason why the myDLLgetprocaddress funktion fails to deliver me the address...
i know that you surely know much more about visual c++ than i do, so i would be very thankfull for any advice how i can solve this problem.
thank you a lot
martin
first of all, thanx for the advice.
i tried to write the dll, that passes the procaddress to the funtion that needs it. i made a dll with the appbuilder that matches the prototype of the callbackfunctio (expet that the returnvalue isnt bool but an uint).
the next thing i have done is to write a dll in visual c++. as i am no programmer at all, i tried to get this done with some books and the internet, but i fail.
i wrote following code:
#include "stdafx.h"
#include <windows.h>
HINSTANCE h = 0;
const char* lib ="MeineDLL.dll";
const char* proc="DLL Funktion";
extern "C" __declspec( dllexport) int myDLLload(LPCWSTR lib)
{
if(h == 0)
{
LPCWSTR lib = libinput;
h = LoadLibrary(lib);
return 0; // ok
}
return 1; // error
}
// übergib addr in LabView der anderen DLL-Funktion
extern "C" __declspec( dllexport) int myDLLgetprocaddr(LPCSTR proc, int* addr)
{
if(h != 0)
{
*addr = (int)GetProcAddress(h, proc);
return *addr != 0; // ok
}
return 1; // error
}
extern "C" __declspec( dllexport) void myDLLFree()
{
FreeLibrary(h);
}
the problem is, that the myDLLload function returns 0 all the time, no mather how i define "lib". and i think that is the reason why the myDLLgetprocaddress funktion fails to deliver me the address...
i know that you surely know much more about visual c++ than i do, so i would be very thankfull for any advice how i can solve this problem.
thank you a lot
martin