1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86:
| program AutoUpdate;
uses Windows, Messages, ShellApi;
const ClassName = 'WndClass'; AppName = 'Geheim';
WM_SHELLNOTIFY = WM_USER + 1;
var TrayIcon: TNotifyIconData = ( cbSize : SizeOf(TNotifyIconData); uID : 0; uFlags : NIF_MESSAGE + NIF_ICON + NIF_TIP; uCallbackMessage: WM_SHELLNOTIFY; hIcon : 0; szTip : 'Updates suchen...'; );
function WndProc(hWnd: HWND; uMsg: UINT; wParam: wParam; lParam: LParam): lresult; stdcall; begin Result := 0; case uMsg of WM_CREATE: begin TrayIcon.Wnd := hWnd; TrayIcon.hIcon := LoadImage(hInstance, MAKEINTRESOURCE(IDI_APPLICATION), IMAGE_ICON, 0, 0, 0); Shell_NotifyIcon(NIM_ADD, @TrayIcon);
end; WM_DESTROY: begin Shell_NotifyIcon(NIM_DELETE, @TrayIcon); PostQuitMessage(0); end; WM_SHELLNOTIFY: begin end; else Result := DefWindowProc(hWnd, uMsg, wParam, lParam); end; end;
var WindowClass: TWndClassEx = ( cbSize : SizeOf(TWndClassEx); Style : CS_HREDRAW or CS_VREDRAW; lpfnWndProc : @WndProc; cbClsExtra : 0; cbWndExtra : 0; hbrBackground : COLOR_APPWORKSPACE; lpszMenuName : nil; lpszClassName : ClassName; hIconSm : 0; ); Msg: TMsg;
begin WindowClass.hInstance := hInstance; RegisterClassEx(WindowClass); CreateWindowEx(0, ClassName, AppName, WS_CAPTION or WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0, 0, hInstance, nil); while True do begin if not GetMessage(Msg, 0, 0, 0) then Break; TranslateMessage(Msg); DispatchMessage(Msg); end; ExitCode := Msg.wParam; end. |