Jeg vil gerne have et Patch system til mit program:
#define WINVER 0x0500
#define _WIN32_IE 0x0500
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <string.h>
#include <stdlib.h>
#define TRAY_MESSAGE (WM_APP + 123)
#define IDC_BUTTON1 1001
#define IDC_STATIC 1002
#define IDM_TIMER 1003
HHOOK KeyboardHook;
HINSTANCE InstanceHandle;
void Minimize(HWND hwndDlg);
void UnMinimize(HWND hwndDlg);
void SetBaloonTip(HWND hwndDlg);
HICON HIcon;
LRESULT LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode == HC_ACTION)
{
KBDLLHOOKSTRUCT *HookStruct = (KBDLLHOOKSTRUCT *)lParam;
if(HookStruct->vkCode == VK_LWIN || HookStruct->vkCode == VK_RWIN)
{
return TRUE;
}
}
return CallNextHookEx(KeyboardHook, nCode, wParam, lParam);
}
LRESULT CALLBACK DialogProc(HWND hwndDlg,
UINT msg,
WPARAM wParam,
LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
CreateWindow("BUTTON",
"Activate!",
WS_CHILD | WS_VISIBLE,
5, 22, 160, 34,
hwndDlg,
(HMENU)(IDC_BUTTON1),
InstanceHandle,
0);
CreateWindow("STATIC",
"Version 1.0",
WS_CHILD | WS_VISIBLE,
5, 5, 75, 16,
hwndDlg,
(HMENU)(IDC_STATIC),
InstanceHandle,
0);
break;
case TRAY_MESSAGE:
if(lParam == WM_LBUTTONDOWN)
{
UnMinimize(hwndDlg);
}
break;
case WM_TIMER:
KillTimer(hwndDlg, IDM_TIMER);
SetBaloonTip(hwndDlg);
break;
case WM_COMMAND:
if(HIWORD(wParam) == BN_CLICKED &&
LOWORD(wParam) == IDC_BUTTON1)
{
Minimize(hwndDlg);
}
break;
}
return DefWindowProc(hwndDlg, msg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, INT)
{
InstanceHandle = hInstance;
HIcon = LoadIcon(0, IDI_WINLOGO);
HIcon = (HICON )LoadImage(0, "KeyIcon.ico", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
WNDCLASS wc;
memset(&wc, 0, sizeof(WNDCLASS));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = DialogProc;
wc.hInstance = InstanceHandle;
wc.hbrBackground = (HBRUSH )(COLOR_BTNFACE + 1);
wc.lpszClassName = "WhateverClass";
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
if(!RegisterClass(&wc))
return FALSE;
HWND WindowHandle = CreateWindow("WhateverClass",
"Windows KeyKiller", // Caption text
WS_VISIBLE | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN | WS_CAPTION |
WS_BORDER | WS_SYSMENU,
100, 100, 175, 90, // Position
0,
0,
InstanceHandle,
0);
MSG Msg;
while(GetMessage(&Msg, WindowHandle, 0, 0xFFFF) > 0)
{
if(!IsDialogMessage(WindowHandle, &Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
return 0;
}
void InstallHook(void)
{
if(KeyboardHook)
return;
KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC )LowLevelKeyboardProc, GetModuleHandle(0), 0);
if(!KeyboardHook)
{
}
}
void UnInstallHook(void)
{
if(KeyboardHook)
UnhookWindowsHookEx(KeyboardHook);
KeyboardHook = 0;
}
void Minimize(HWND hwndDlg)
{
NOTIFYICONDATA NotifyIconData;
ShowWindow(hwndDlg, SW_HIDE);
memset(&NotifyIconData, 0, sizeof(NotifyIconData));
NotifyIconData.cbSize = sizeof(NotifyIconData);
NotifyIconData.uID = 123;
NotifyIconData.hWnd = hwndDlg;
NotifyIconData.hIcon = HIcon;
NotifyIconData.uFlags = NIF_ICON | NIF_MESSAGE;
NotifyIconData.uCallbackMessage = WM_APP + 123;
strcpy(NotifyIconData.szTip, "TrayTip");
Shell_NotifyIcon(NIM_ADD, &NotifyIconData);
SetTimer(hwndDlg, IDM_TIMER, 2000, 0);
InstallHook();
}
void UnMinimize(HWND hwndDlg)
{
NOTIFYICONDATA NotifyIconData;
ShowWindow(hwndDlg, SW_SHOW);
memset(&NotifyIconData, 0, sizeof(NotifyIconData));
NotifyIconData.cbSize = sizeof(NotifyIconData);
NotifyIconData.uID = 123;
NotifyIconData.hWnd = hwndDlg;
NotifyIconData.hIcon = HIcon;
NotifyIconData.uFlags = NIF_ICON | NIF_MESSAGE;
NotifyIconData.uCallbackMessage = TRAY_MESSAGE;
strcpy(NotifyIconData.szTip, "TrayTip");
Shell_NotifyIcon(NIM_DELETE, &NotifyIconData);
UnInstallHook();
}
void SetBaloonTip(HWND hwndDlg)
{
NOTIFYICONDATA NotifyIconData;
memset(&NotifyIconData, 0, sizeof(NOTIFYICONDATA));
NotifyIconData.cbSize = sizeof(NOTIFYICONDATA);
NotifyIconData.uID = 123;
NotifyIconData.hWnd = hwndDlg;
NotifyIconData.hIcon = HIcon;
NotifyIconData.uFlags = 0x10;
NotifyIconData.uTimeout = 15000;
NotifyIconData.uCallbackMessage = TRAY_MESSAGE;
strcpy(NotifyIconData.szInfoTitle, "KeyKiller");
strcpy(NotifyIconData.szInfo, "Your windows keys shouldn't work!");
strcpy(NotifyIconData.szTip, "TrayTip");
Shell_NotifyIcon(NIM_MODIFY, (NOTIFYICONDATA *)&NotifyIconData);
}