c++ dll创建及使用 rundll32 测试

来源:互联网 发布:网络游戏排行榜 知乎 编辑:程序博客网 时间:2024/05/02 02:36

使用vs2010 直接创建dll工程

// dllmain.cpp : Defines the entry point for the DLL application.

#include "stdafx.h"
#include <stdio.h>
#include "fun.h"
extern "C" _declspec(dllexport) void __cdecl dllfun(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);
BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
extern "C" _declspec(dllexport) void __cdecl dllfun(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)


{


// MessageBox(NULL,L"lll",L"lllkk",MB_OK);
StartWork(NULL);


return;


}


在命令行中  rundll32.exe projectname.dll,dllfun 即可


当然也可以在项目属性中配置动态调试

0 0
原创粉丝点击