给计算器添加一个新菜单
Posted 墨鱼菜鸡 苹果园
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了给计算器添加一个新菜单相关的知识,希望对你有一定的参考价值。
#include <windows.h>
#include <tchar.h>
#include <shellapi.h>
#define IDM_TEST 12345
WNDPROC lpfnOldProc = 0;
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
return CallWindowProc(lpfnOldProc, hWnd, message, wParam, lParam);
}
DWORD WINAPI ThreadProc(PVOID pParam)
{
HWND hwnd = FindWindow(NULL, _T("计算器"));
HMENU hMenu = GetMenu(hwnd);
AppendMenu(hMenu, MF_STRING, IDM_TEST, _T("注入菜单"));
SetMenu(hwnd, hMenu);
lpfnOldProc = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (LONG)WndProc);
return 0;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
CreateThread(NULL,0,ThreadProc,NULL,0,NULL);
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
以上是关于给计算器添加一个新菜单的主要内容,如果未能解决你的问题,请参考以下文章