Азбука программирования в Win32 API


Азбука программирования в Win32 API - стр. 191


if( !RegisterClass(&WndClass)) {

MessageBox(NULL,"Cannot register class","Error",MB_OK); return 0;

hWnd = CrcateWindow(szClassName, "Processes Demo",

WS^OVERLAPPEDWINDOW, CWJJSEDEFAULT, CWJJSEDEFAULT, CWJJSEDEFAULT, CWJJSEDEFAULT, NULL, NULL, hlnstance.NULL);

if(!hWnd)

t t

MessageBox(NULL,"Cannot create window", "Error",MB_OK); relurn 0;

/* Show our window */

ShowWindow(hWnd,nCmdShow);

UpdateWindow(hWnd);

/* Beginning of messages cycle */

while(GetMessage(&Msg, NULL, 0, 0))

{

TranslateMessage(&Msg);

DispatchMessage(&Msg); i return Msg.wParam;

LRESULT CALLBACK ProcessesWndProc (HWND hWnd, UINT Message,

UINT wParam, LONG IParam )

const Max ~ 10;

STARTUP1NFO Startuplnfo;

static int ProccssNumber = 0;

static PROCESS INFORMATION ProccssInformationfMax];

static char cMyMessage[80]; static HMENU hSubMcnu;

switch(Message)

i

case WM CREATE: hSubMemi = GetSubMenu(GetMcnu(hWnd).0);

229

return 0;

case WM_COMMAND: switch( LOWORD(wParam))

case IDM_New_Process: if(ProcessNumber < Max)

t

Startuplnfo.cb = sizeof(STARTUPINFO);

StartupInfo.lpReservcd = NULL;

StartupInfo.lpDesktop = NULL;

StartupInfo.lpTitlc - NULL;

StartupInfo.dwFlags = STARTFJJSESHOWWINDOW;

StartupInfo.wShowWindow = SW_SHOWNORMAL;

StartiipInfo.cbReserved2 = 0;

StartupInfo.lpReserved2 = NULL;

if(CreateProcess(NULL."Notepad.exe",

NULL, NULL, FALSE, 0,

NULL, NULL, &StartupInfo,

&(ProcessInformation[ProcessNumber])))

ProcessNumber—;

wsprintffcMyMessage,"hProcess is %x.\nhThread is

%x.\ndwProcess!d is %x.\ndwThrcad!d is %x.", ProcessInformation[ProcessNumber - Ij.hProcess, ProcessInrormation[ProcessNumber - IJ.hThread, ProcessInformation[ProcessNumber - IJ.dwProcessId, ProcessInformation[ProccssNumber - IJ.dwThrcadld);

MessageBox(hWnd, cMyMessage, "Process is created", MB_OK);

EnableMenuItem(hSubMenu, IDMJCill_Process,

MF_BYCOMMAND | MF_ENABLED);

else

MessageBox(hWnd, "Cannot create process", "Process creation", MB_OK);




Начало  Назад  Вперед



Книжный магазин