13,825
社区成员
发帖
与我相关
我的任务
分享
TCppShellWindows * pShellWin = new TCppShellWindows(this);
for(int i = 0; i < pShellWin->Count; i++){
IWebBrowser2Ptr pWebBrowser( pShellWin->Item(TVariant(i)));
if( pWebBrowser ){
WideString wsPath;
pWebBrowser->get_LocationURL(&wsPath);
OutputDebugStringW(wsPath);
}
}
delete pShellWin;
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit35.h"
#include <SHDocVw.hpp>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm35 *Form35;
//---------------------------------------------------------------------------
__fastcall TForm35::TForm35(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm35::Button1Click(TObject *Sender)
{
TShellWindows * pShellWin = new TShellWindows(this);
for(int i = 0; i < pShellWin->Count; i++)
{
IWebBrowser2 * pWebBrowser;
pShellWin->Item(i)->QueryInterface(IID_IWebBrowser2, (void **)&pWebBrowser);
if( pWebBrowser )
{
AnsiString S = pWebBrowser->LocationURL;
if (S.UpperCase().Pos("FILE:///") == 1)
{
S.Delete(1,8);
if (S.Pos("%"))
{
for (char C = 0x20; C < 0x7F; C++)
if (C != '%')
S = StringReplace(S, "%" + IntToHex(C, 2), C,
TReplaceFlags() << rfReplaceAll);
S = StringReplace(S, "%25", "%", TReplaceFlags() << rfReplaceAll);
}
S = StringReplace(S, "/", "\\", TReplaceFlags() << rfReplaceAll);
if (DirectoryExists(S))
Memo1->Lines->Add(S.c_str());
}
}
}
delete pShellWin;
}
//---------------------------------------------------------------------------