窗口本来是隐藏的,我想遍历出窗口然后将它显示出来
procedure findprocessName;
var
lppe: TProcessEntry32;
sshandle: THandle;
found: BOOL;
baseman, num: cardinal;
DD:Byte;
begin
baseman:=FindWindow(nil,'Element Client');
ShowMessage('find '+inttostr(baseman));
sshandle := CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
found := Process32First(sshandle, lppe);
while found do
begin
if AnsiCompareText(ExtractFileName(lppe.szExeFile), '123.exe') = 0 then //123是隐藏窗口
begin
//如何把123显示出来?
Break;
end;
found := Process32Next(sshandle, lppe);
end;
CloseHandle(sshandle);
end;
procedure findprocessName;
var
lppe: TProcessEntry32;
sshandle: THandle;
found: BOOL;
baseman, num: cardinal;
DD:Byte;
begin
baseman:=FindWindow(nil,'Element Client');
ShowMessage('find '+inttostr(baseman));
sshandle := CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
found := Process32First(sshandle, lppe);
while found do
begin
if AnsiCompareText(ExtractFileName(lppe.szExeFile), '123.exe') = 0 then //123是隐藏窗口
begin
//如何把123显示出来?
Break;
end;
found := Process32Next(sshandle, lppe);
end;
CloseHandle(sshandle);
end;
procedure findprocessName;
var
lppe: TProcessEntry32;
sshandle: THandle;
found: BOOL;
baseman, num: cardinal;
DD:Byte;
begin
baseman:=FindWindow(nil,'Element Client');
ShowMessage('find '+inttostr(baseman));
sshandle := CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
found := Process32First(sshandle, lppe);
while found do
begin
if AnsiCompareText(ExtractFileName(lppe.szExeFile), '123.exe') = 0 then //123是隐藏窗口
begin
//lppe.th32processid; 这可以得到程序pid, 我想用showwindow将这个窗口显示出来,但是不知道如何由pid获得hwnd
Break;
end;
found := Process32Next(sshandle, lppe);
end;
CloseHandle(sshandle);
end;
其次,你的代码有问题TProcessEntry32结构的dwSize必须要有个初值: lppe.dwSize := SizeOf(TProcessEntry32);
最后,你可以EnumWindows来找所有窗体,找到窗口的句柄用GetWindowThreadProcessId来得到pid来比较, IsWindowVisible来判断是否处于隐藏状态...
确定找到了就用ShowWindow显示出来