下面的代碼顯示了關窗的一般方法。這個例子適用於Internet Explorer;你將不得不調整它有點對Windows資源管理器..
program Sample;
function CloseIEs(Wnd : HWnd; Form : TForm1) : Boolean; export; stdcall;
var
sCap : array [0..255] of char;
begin
GetWindowText (Wnd, sCap, sizeof(sCap));
if pos ('Microsoft Internet Explorer', sCap) > 0 then
begin
PostMessage (Wnd, WM_CLOSE, 0, 0);
end
else
begin
// check by class name!
GetClassName (Wnd, sCap, sizeof(sCap));
if sCap = 'IEFrame' then
PostMessage (Wnd, WM_CLOSE, 0, 0);
end;
CloseIEs := true; { next window, please }
end;
begin
// close all hidden instances
EnumWindows(@CloseIEs, 0);
end.
我認爲這是Windows鎖定文件夾的問題。 – 2009-07-05 16:59:28