主题:大家帮帮看看这玩意儿什么地方没有对啊?
我学着写DLL可是老是是无法找到其中的函数,以下是代码,望大哥哥大姐姐们帮忙看下。谢谢先
EXE文件代码:
#include <windows.h>
typedef void (*showbox)(char*);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrev,LPSTR CmdLine,int nCmd)
{
HINSTANCE hDll;
hDll=LoadLibrary(TEXT("madll.dll"));
showbox al;
al=(showbox)GetProcAddress(hDll,TEXT("show"));
if (al)
{
(*al)(TEXT("sdlfij"));
}
else
{
MessageBox(NULL,TEXT("无法加载函数show"),TEXT("错误"),MB_OK|MB_ICONERROR);
}
free(hDll);
return 0;
}
DLL文件代码:
#include <windows.h>
extern "C" __declspec(dllexport) void show(char *abc)
{
MessageBox(NULL,abc,TEXT("show()"),MB_OK|MB_ICONWARNING);
}
int WINAPI DllMain(HINSTANCE hModule,DWORD dwReason,PVOID pv)
{
if (dwReason==DLL_PROCESS_ATTACH)
{
MessageBox(NULL,TEXT("DLL已被加载!"),TEXT("MaDLL"),MB_OK|MB_ICONINFORMATION);
}
return 0;
}
-------------------------------------
al老是等于0
EXE文件代码:
#include <windows.h>
typedef void (*showbox)(char*);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrev,LPSTR CmdLine,int nCmd)
{
HINSTANCE hDll;
hDll=LoadLibrary(TEXT("madll.dll"));
showbox al;
al=(showbox)GetProcAddress(hDll,TEXT("show"));
if (al)
{
(*al)(TEXT("sdlfij"));
}
else
{
MessageBox(NULL,TEXT("无法加载函数show"),TEXT("错误"),MB_OK|MB_ICONERROR);
}
free(hDll);
return 0;
}
DLL文件代码:
#include <windows.h>
extern "C" __declspec(dllexport) void show(char *abc)
{
MessageBox(NULL,abc,TEXT("show()"),MB_OK|MB_ICONWARNING);
}
int WINAPI DllMain(HINSTANCE hModule,DWORD dwReason,PVOID pv)
{
if (dwReason==DLL_PROCESS_ATTACH)
{
MessageBox(NULL,TEXT("DLL已被加载!"),TEXT("MaDLL"),MB_OK|MB_ICONINFORMATION);
}
return 0;
}
-------------------------------------
al老是等于0