Jump to content

getting a callback function pointer


Recommended Posts

Hi, i trie to im get a pointer to a dll function to pass it as a callback function pointer to another one. i wrote following dll in visual c++ code\#include <windows.h>

HINSTANCE h = 0;

extern "C" __declspec(dllexport) int myDLLload(LPCWSTR lib)

{

if(h == 0)

{

h = LoadLibrary(lib);

return 0; // ok

}

return 1; // error

}

extern "C" __declspec(dllexport) int myDLLgetprocaddr(const char* proc, int* addr, DWORD* err)

{

if(h != 0)

{

*addr = (int)GetProcAddress(h, proc);

return *addr == 0; // ok

}

*err = GetLastError();

return 1; // error

}

extern "C" __declspec(dllexport) void myDLLFree()

{

FreeLibrary(h);

h = 0;

}

/code

i passed the parameters for the loadlibary (lib) and getproc... (proc) as a c-string, (addr) als int32* but it doesnot work. i am not good in writing dlls at all (fortunately there are a lot of nice people in some forums that help a lot :) ) and i just dont know why that doesnot work.

anyone has a clue?

thanx

martin

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.