punky
2009-08-29 04:49:28 UTC
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?
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?