使用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 即可
当然也可以在项目属性中配置动态调试