#include long int OldWndProc; LRESULT CALLBACK NewWndProc(HWND Hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_COMMAND: switch(wParam) { case 2000: MessageBox(HWND_DESKTOP, "You pressed our new menu button!", "Yay!", MB_OK); break; } break; } return CallWindowProc((WNDPROC)OldWndProc, Hwnd, Message, wParam, lParam); } DWORD WINAPI Creation(LPVOID) { HWND hWnd = FindWindow(NULL, "Untitled - Notepad"); HMENU hCurrent = GetMenu(hWnd); //Get the CURRENT menu of the window HMENU hNew = CreateMenu(); //Create a new one AppendMenu(hCurrent, MF_STRING | MF_POPUP, (unsigned int)hNew, "Tutorial"); AppendMenu(hNew, MF_STRING, 2000, "Button"); //2000 is the ID of the button DrawMenuBar(hWnd); //redraw the Menu! // OldWndProc = SetWindowLong(hWnd, GWL_WNDPROC, (long)NewWndProc); //subclass the original window procedure //With our new one //So now all messages sent to the notepad window, are sent to OUR window proc..See above! return TRUE; } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { if(fdwReason == DLL_PROCESS_ATTACH){ // CreateThread(0, NULL, (LPTHREAD_START_ROUTINE)&Creation, NULL, NULL, NULL); MessageBox(HWND_DESKTOP, "You pressed our new menu button!", "Yay!", MB_OK); } return TRUE; }