直接建立窗口版:<br><br>// ------- HelloWin.dpr -------<br><br>program HelloWin;<br><br>uses Windows, Messages;<br><br>function WndProc(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;<br>begin<br> case Msg of<br> WM_SYSCOMMAND:<br> if (wParam <> SC_MINIMIZE) then<br> Result := DefWindowProc(hWnd, Msg, wParam, lParam)<br> else<br> Result := 0; // 不作处理<br><br> WM_DESTROY:<br> begin<br> PostQuitMessage(0);<br> Result := 0;<br> end;<br><br> else Result := DefWindowProc(hWnd, Msg, wParam, lParam);<br> end;<br>end;<br><br>const<br> AppName = 'HelloWin';<br><br>var<br> Msg: TMsg;<br> WndClass: TWndClass;<br><br>begin<br> WndClass.style := CS_HREDRAW or CS_VREDRAW;<br> WndClass.lpfnWndProc := @WndProc;<br> WndClass.cbClsExtra := 0;<br> WndClass.cbWndExtra := 0;<br> WndClass.hInstance := HInstance;<br> WndClass.hIcon := LoadIcon(0, IDI_APPLICATION);<br> WndClass.hCursor := LoadCursor(0, IDC_ARROW);<br> WndClass.hbrBackground := GetStockObject(BLACK_BRUSH);<br> WndClass.lpszMenuName := nil;<br> WndClass.lpszClassName := AppName;<br> RegisterClass(WndClass);<br><br> CreateWindow(AppName, 'The Hello Program',<br> WS_OVERLAPPEDWINDOW or WS_VISIBLE,<br> Integer(CW_USEDEFAULT), SW_SHOW,<br> Integer(CW_USEDEFAULT), 0,<br> 0, 0, HInstance, nil);<br><br> while GetMessage(Msg, 0, 0, 0) do<br> begin<br> TranslateMessage(Msg);<br> DispatchMessage(Msg);<br> end;<br>end.