主要原因:CreateWindow 返回总是 0!!!!!!!!
#include <windows.h>
#include <stdio.h>
#include <string>
#include "Winsvc.h"
using namespace std;
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS WndClass;
//HACCEL hAccel;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hbrBackground =(HBRUSH) GetStockObject(BLACK_BRUSH);
WndClass.hCursor = LoadCursor(hInstance, IDC_ARROW);
WndClass.hIcon = LoadIcon(hInstance, IDI_WINLOGO);
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WindowProc;
WndClass.lpszClassName = "kagayaki";
WndClass.lpszMenuName = NULL;
WndClass.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&WndClass);
HWND hwnd;
hwnd = CreateWindow("kagayaki", "kagayaki",
WS_OVERLAPPEDWINDOW /* WS_BORDER | WS_CAPTION | WS_VISIBLE */, 320, 240,
320, 240,
NULL, NULL,
hInstance,
NULL);
ShowWindow(hwnd, nCmdShow); // hwnd = 0 ???????
//UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
//return (TRUE);
default : DefWindowProc(hwnd, msg, wParam, lParam);
}
return (FALSE);
}
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)