WND g_hwin=NULL;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, // handle to parent window
LPARAM lParam // application-defined value
)
{
DWORD PID;
BOOL Result=TRUE;
GetWindowThreadProcessId(hwnd,&PID);
if (PID==GetCurrentProcessId() && GetWindowLong(hwnd,GWL_STYLE)&SW_SHOW /*&& GetParent(hwnd)==NULL*/)
{
g_hwin = hwnd;//这个g_hwin在你的DLL里定义为一个全局的HWND,也是你想要的句柄
Result = FALSE;
}
return Result;
}