Discussion:
Pointer to a function (C .dll files)
(too old to reply)
martinboecskoer
2008-08-07 13:10:09 UTC
Permalink
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
 
jpaul
2008-08-08 15:10:12 UTC
Permalink
Hi Martin,
There is a Microsoft example on how to implement the LoadLibrary function at <a>this link</a>. I would try to modified your code, specifically the datatype of your lib variable, to match their implementation and see if this solves&nbsp;your issue.
Cheers,
JonahApplications EngineerNational Instruments
Wiebe@CARYA
2008-08-11 10:34:31 UTC
Permalink
duplicate post :
http://forums.ni.com/ni/board/message?board.id=170&thread.id=347882
Loading...