Startupinfo Si = {sizeof (SI )};
Process_information PI;
Char * szcommandline = "cmd ";
Si. dwflags = startf_useshowwindow;
Si. wshowwindow = true;
Bool Bret =: CreateProcess (
Null,
Szcommandline,
Null,
Null,
0,
Create_new_console,
Null,
Null,
& Si,
& PI );
If (BRET)
{
: Closehandle (PI. hprocess );
: Closehandle (PI. hthread );
Printf ("the new process ID is % d \ n", Pi. dwprocessid );
Printf ("the thread ID of the new thread is % d \ n", Pi. dwthreadid );
}
Int Index = 0;
Processentry32 pe32;
Pe32.dwsize = sizeof (pe32 );
Handle hprocesssnap =: createconlhelp32snapshot (th32cs_snapprocess, 0 );
If (hprocesssnap = invalid_handle_value)
{
Printf ("createconlhelp32snapshow error! ");
Return-1;
}
Bool bmore =: process32first (hprocesssnap, & pe32 );
//: Exitprocess (0 );
While (bmore)
{
Printf ("***************** % d *************** \ n ", ++ index );
Printf ("process name: % s \ n", pe32.szexefile );
Printf ("process ID: % d \ n", pe32.th32processid );
Printf ("thread Nums: % d \ n", pe32.cntthreads );
If (! Strcmp (pe32.szexefile, "qq.exe "))
{
//: Enumprocesses (
DWORD dexitcode;
Handle hprocess =: OpenProcess (process_all_access, false, pe32.th32processid );
: Getexitcodeprocess (hprocess, & dexitcode );
If (still_active = dexitcode)
{
Printf ("% s exist! \ N ", pe32.szexefile );
}
Else
{
Printf ("% s does not exist! \ N ", pe32.szexefile );
}
If (hprocess! = NULL)
{
Terminateprocess (hprocess, 0 );
Printf ("###### % s ended successfully! ######## \ N ", pe32.szexefile );
}
: Getexitcodeprocess (hprocess, & dexitcode );
If (still_active = dexitcode)
{
Printf ("% s exist! \ N ", pe32.szexefile );
}
Else
{
Printf ("% s does not exist! \ N ", pe32.szexefile );
}
: Closehandle (hprocess );
}
Printf ("basic priority of the Process Creation thread % d \ n", pe32.pcpriclassbase );
Bmore =: process32next (hprocesssnap, & pe32 );
}
: Closehandle (hprocesssnap );