如何判断IE窗口全部关闭(或者没有打开.........)(50分)

  • 主题发起人 主题发起人 dafu2
  • 开始时间 开始时间
D

dafu2

Unregistered / Unconfirmed
GUEST, unregistred user!
有谁知道"如何判断IE窗口全部关闭(或者没有打开.........)"
希望此题有解啊!有DEMO的发份给我吧!

Email:gxhuangna@126.com
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, shellapi, ddeman, shdocvw,registry;

type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
Button2: TButton;
procedure ListBox1DblClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
IEXPLORE:string;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
WinExec(PChar(IEXPLORE+' "'+listbox1.items[listbox1.itemindex]+'"'),SW_NORMAL);
end;

procedure TForm1.Button1Click(Sender: TObject);
const
maxx = 30;
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i: integer;
vi: OleVariant;
IE1: IWebBrowser2;
begin
listbox1.clear;
ShellWindow := CoShellWindows.Create;
nCount := ShellWindow.Count;
for i := 0 to nCount - 1 do
begin
vi := i;
try
spDisp := ShellWindow.Item(vi);
except
exit
end;
if (spDisp <> nil) then
begin
try
spDisp.QueryInterface(iWebBrowser2, IE1);
except
on EAccessViolation do
begin
exit
end;
end;
if (IE1 <> nil) then
begin
listbox1.items.add(IE1.Get_LocationURL());
end;
end;
end;
deletefile(extractfilepath(paramstr(0)) + 'Address.d' + inttostr(maxx));
for i := maxx - 1 downto 0 do
renamefile(extractfilepath(paramstr(0)) + 'Address.d' + format('%.2d', ), 'Address.d' + format('%.2d', [i + 1]));
listbox1.items.savetofile(extractfilepath(paramstr(0)) + 'Address.d00');
end;

procedure TForm1.Button2Click(Sender: TObject);
var
i: integer;
begin
for i := 0 to listbox1.items.count - 1 do
begin
WinExec(PChar(IEXPLORE+' &quot;'+listbox1.items+'&quot;'),SW_NORMAL);
end;
end;

procedure TForm1.FormShow(Sender: TObject);
var
s: string;
reg:TRegistry;
begin
s := extractfilepath(paramstr(0)) + 'Address.d00';
if fileexists(s) then
listbox1.items.loadfromfile(s);
reg:=TRegistry.create;
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.openkey('Software/Microsoft/Windows/CurrentVersion/App Paths/IEXPLORE.EXE',true);
IEXPLORE:=reg.ReadString('');
reg.closekey;
reg.free;
end;

end.
 
达不到目的啊......


这样也不稳定:
iehandle := findwindow('IEFrame', nil);
//sendmessage(IEhandle, WM_SYSCOMMAND, $F060, $1)
if iehandle = 0 then
frm_main.Caption := 'IE关闭'
else
frm_main.Caption := 'IE打开'+inttostr(iehandle);
 
遍历iexplore.exe行不行?
 
to wealsh:
&quot;遍历iexplore.exe&quot;是咋搞的呢?
发个DEMO让小弟学习学习吧!

Email:gxhuangna@126.com
 
uses TlHelp32

function F(ExeFileName:string): integer;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
Find:integer;
begin
try
result := -1;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while integer(ContinueLoop) <> 0 do
begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
UpperCase(ExeFileName))
or (UpperCase(FProcessEntry32.szExeFile) = UpperCase(ExeFileName))) then
begin
Result:=1;
{ Result := Integer(TerminateProcess(OpenProcess(PROCESS_TERMINATE, BOOL (0),FProcessEntry32.th32ProcessID), 0));}
end;
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
except
end;
end;
 
DEMO是什么吗?
不要笑我
请告诉我
 
就是例子.
 
多人接受答案了。
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部