if LowerCase(PE.szExeFile) = LowerCase(ExeName) then
//其他情况如1楼所示,条件未变,只增加几个ShowMessage,以显示必中的疑惑 function GetPID(sExeName: string): HWND; var PE: TProcessEntry32; bFound: Boolean; handle: THandle; begin Result := 0; hwnd:= CreateToolhelp32Snapshot(TH32CS_SNAPALL , 0); bFound := Process32First(handle, PE); {调试语句} //使其有效:LsbLog.Items.Add(PE.szExeFile) ,ShowMessage显示为True, //无效时,ShowMessage为False, //Why????????Who can tell me????????? ShowMessage(BoolToStr(bFound,True)); while bFound do begin // LsbLog.Items.Add(PE.szExeFile); // ShowMessage(PE.szExeFile); if LowerCase(PE.szExeFile) = LowerCase(sExeName) then begin Result := PE.th32ProcessID; Break; end; bFound := Process32Next(handle, PE); end; end;
这句
//其他情况如1楼所示,条件未变,只增加几个ShowMessage,以显示必中的疑惑
function GetPID(sExeName: string): HWND;
var
PE: TProcessEntry32;
bFound: Boolean;
handle: THandle;
begin
Result := 0;
hwnd:= CreateToolhelp32Snapshot(TH32CS_SNAPALL , 0);
bFound := Process32First(handle, PE);
{调试语句}
//使其有效:LsbLog.Items.Add(PE.szExeFile) ,ShowMessage显示为True,
//无效时,ShowMessage为False,
//Why????????Who can tell me?????????
ShowMessage(BoolToStr(bFound,True));
while bFound do
begin
// LsbLog.Items.Add(PE.szExeFile);
// ShowMessage(PE.szExeFile);
if LowerCase(PE.szExeFile) = LowerCase(sExeName) then
begin
Result := PE.th32ProcessID;
Break;
end;
bFound := Process32Next(handle, PE);
end;
end;