Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DLL Creation

3 views
Skip to first unread message

punky

unread,
Aug 29, 2009, 12:49:28 AM8/29/09
to
I'm trying to use my own dll's but i can't load the function of my dll
from my exe file don't know why:

//---- THE DLL
//---------------------------------------------------------------------------

#include <vcl.h>
#include <windows.h>
#include <stdio.h>

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID
lpvReserved)
{
BOOL bResult = TRUE;

// Dispatch this main call based on the reason it was called.
switch (fwdreason)
{
case DLL_PROCESS_ATTACH:
printf("<DLL> Attached \n");

break;

case DLL_PROCESS_DETACH:
printf("<DLL> Detached\n");
break;

default:
break;
}

return (bResult);

}

void __declspec(dllexport) __stdcall myfunct(void){
printf("<DI> TEST");

}

///--- THE EXE
#pragma hdrstop
#include <windows.h>
#include <stdio.h>
//---------------------------------------------------------------------------

#pragma argsused

typedef void (__stdcall *myfunctPtr)(void);
myfunctPtr myfunct;
int main(int argc, char* argv[])
{
HANDLE hDLL;
hDLL=LoadLibrary("project1.dll");
if(!hDLL){
printf("<EF> Cant Find [myfunction.dll] %08X!\n",GetLastError());

}

myfunct=(myfunctPtr)GetProcAddress(hDLL,"myfunct");
if(!myfunct){
printf("<EF> Cant do myfunction [project1.dll]!\n");
return(FALSE);
} else {
myfunct(); }
getc(stdin);
return 0;
}

/// ************ END EXE

MY process(exe) the DLL get Loaded without problems... but it cant
Load myfunct with GetProcAddress..
what i do wrong, any suggestions?

punky

unread,
Aug 30, 2009, 12:50:15 AM8/30/09
to
i got it, this was missing :
extern "C" {
void __declspec(dllexport) __stdcall myfunct(void);
0 new messages