请教大侠们一个 DLL中 MessageBox的问题,十分感谢!
各位大侠,
我仿照别人的代码,写了一个 DLL调用的工程。
可是执行总得不到结果。请帮忙赐教一下。万分感谢!
我已经把我写的工程文件放在了附件里。
http://download.csdn.net/detail/blackkettle/4070318
希望大侠们有空能帮忙改正一下。万分感谢!
// SampleDLL.cpp : Defines the entry point for the DLL application.//#include "StdAfx.h"BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ){ return TRUE;}extern "C" __declspec(dllexport) void HelloWorld(){ MessageBox( NULL, TEXT("Hello World"), TEXT("In a DLL"), MB_OK);}// File: SampleDLL.h//#ifndef INDLL_H#define INDLL_H#ifdef EXPORTING_DLLextern __declspec(dllexport) void HelloWorld() ;#elseextern __declspec(dllimport) void HelloWorld() ;#endif#endif// SampleDLLEx4.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <windows.h>#include <winbase.h> typedef VOID (*DLLPROC)();void main(){ HINSTANCE hinstDLL; DLLPROC HelloWorld; BOOL fFreeDLL; hinstDLL = LoadLibrary("..\\Debug\\SampleDLL.dll"); if (hinstDLL != NULL) { HelloWorld = (DLLPROC) GetProcAddress(hinstDLL, "HelloWorld"); if (HelloWorld != NULL) (HelloWorld); fFreeDLL = FreeLibrary(hinstDLL); } }