首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

请问大侠们一个 DLL中 MessageBox的有关问题,十分感谢

2012-03-19 
请教大侠们一个 DLL中 MessageBox的问题,十分感谢!各位大侠,我仿照别人的代码,写了一个 DLL调用的工程。可

请教大侠们一个 DLL中 MessageBox的问题,十分感谢!
各位大侠,

我仿照别人的代码,写了一个 DLL调用的工程。

可是执行总得不到结果。请帮忙赐教一下。万分感谢!

我已经把我写的工程文件放在了附件里。

http://download.csdn.net/detail/blackkettle/4070318

希望大侠们有空能帮忙改正一下。万分感谢!


C/C++ code
// 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);    }    }





[解决办法]
if (HelloWorld != NULL)
HelloWorld();//调用dll内函数
[解决办法]
HelloWorld()

热点排行