⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 26.1.txt

📁 《Microsoft Visual C# .NET 2003开发技巧大全》源代码
💻 TXT
字号:
Listing 26.1 Enumerating Windows with C++
#include “stdafx.h”
#include “MessageWindowNative.h”
#ifdef MESSAGEWINDOWNATIVE_EXPORTS
#define MESSAGEWINDOWNATIVE_API __declspec(dllexport)
#else
#define MESSAGEWINDOWNATIVE_API __declspec(dllimport)
#endif
// entry point method for DLL’s
BOOL APIENTRY DllMain( HANDLE 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;
}
// Window message value to send
#define WM_USER_ADDWINDOW WM_USER + 1
BOOL CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam )
{
WPARAM wParam = 0;
if( GetParent( hwnd ) != NULL )
wParam = 1;
// post message to C# application
PostMessage( (HWND) lParam, WM_USER_ADDWINDOW, wParam, (LPARAM) hwnd );
return TRUE;
}
extern “C”
{
MESSAGEWINDOWNATIVE_API void EnumerateDeviceWindows( HWND hCallbackWnd )
{
EnumWindows( EnumWindowsProc, (LPARAM) hCallbackWnd );
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -