关于IShellWindows在Vista下的问题
我需要判断现在的机器是否打开了某个特定的网站,使用代码如下:
function CheckWindinWebOpen(FindStr : string):boolean;
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i: integer;
vi: OleVariant;
IE1: IWebBrowser2;
begin
Result := false;
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
if pos(FindStr,IE1.LocationName)<>0 then
Result := true;
end;
end;
end;
end;
此代码在XP下是OK的,但是在Vista下就取不出来IE了,网上搜索了一下是UAC配置的问题.忽略了IE.
在不修改UAC配置的情况下如何能够解决此问题呢?
或者不使用IShellWindows,能实现我说得那个功能也可以.