Thread View: borland.public.cppbuilder.nativeapi
10 messages
10 total messages
Started by Thorsten Meyer
Wed, 19 Apr 2006 15:56
API to detect which URL is open in Internet Explorer
Author: Thorsten Meyer
Date: Wed, 19 Apr 2006 15:56
Date: Wed, 19 Apr 2006 15:56
15 lines
1195 bytes
1195 bytes
Hi, is there any way to detect with Windows API or VCL Komponent 1. if one or more Instances of Internet Explorer (IEXPLORE.EXE) is running and 2. which URL's is actualy open (used) in the possible Instances of the Internet Explorer I'am using the Builder 5 thanks for answers Thorsten Meyer
Re: API to detect which URL is open in Internet Explorer
Author: Remy Lebeau (TeamB)
Date: Wed, 19 Apr 2006 17:30
Date: Wed, 19 Apr 2006 17:30
38 lines
2357 bytes
2357 bytes
"Thorsten Meyer" <meyer.t@hhb.bonn.de> wrote in message
news:44465d36@newsgroups.borland.com...
> is there any way to detect with Windows API or VCL Komponent
> 1. if one or more Instances of Internet Explorer (IEXPLORE.EXE) is running
There is nothing available for querying that directly. You will have to
track the instances manually.
> 2. which URL's is actualy open (used) in the possible Instances of the
Internet Explorer
For that, you have to actually connect to each IE browser window and query
its current URL from its DOM interfaces directly. Specifically from the
IWebBrowser2 interface, which has a LocationURL property.
For both of these, I would suggest writing a Browse Helper Object. Then you
can install it into IE, and IE will load it automatically. When loaded, it
can communicate back to your main application as needed so that it knows
when IE is running, how many times the BHO is loaded, and to receive
notifications whenever the URL changes in a browser instance.
Refer to MSDN for more details:
Browser Helper Objects: The Browser the Way You Want It
http://msdn.microsoft.com/library/en-us/dnwebgen/html/bho.asp
WebBrowser Control
http://msdn.microsoft.com/workshop/browser/webbrowser/browser_control_node_entry.asp
Interfaces and Scripting Objects
http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/interface.asp
Gambit
Re: API to detect which URL is open in Internet Explorer
Author: Thorsten Meyer
Date: Thu, 20 Apr 2006 07:22
Date: Thu, 20 Apr 2006 07:22
52 lines
2625 bytes
2625 bytes
Thanks i will try regards Thorsten Meyer "Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag news:4446769f$1@newsgroups.borland.com... > > "Thorsten Meyer" <meyer.t@hhb.bonn.de> wrote in message > news:44465d36@newsgroups.borland.com... > > > is there any way to detect with Windows API or VCL Komponent > > 1. if one or more Instances of Internet Explorer (IEXPLORE.EXE) is running > > There is nothing available for querying that directly. You will have to > track the instances manually. > > > 2. which URL's is actualy open (used) in the possible Instances of the > Internet Explorer > > For that, you have to actually connect to each IE browser window and query > its current URL from its DOM interfaces directly. Specifically from the > IWebBrowser2 interface, which has a LocationURL property. > > For both of these, I would suggest writing a Browse Helper Object. Then you > can install it into IE, and IE will load it automatically. When loaded, it > can communicate back to your main application as needed so that it knows > when IE is running, how many times the BHO is loaded, and to receive > notifications whenever the URL changes in a browser instance. > > Refer to MSDN for more details: > > Browser Helper Objects: The Browser the Way You Want It > http://msdn.microsoft.com/library/en-us/dnwebgen/html/bho.asp > > WebBrowser Control > > http://msdn.microsoft.com/workshop/browser/webbrowser/browser_control_node_entry.asp > > Interfaces and Scripting Objects > > http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/interface.asp > > > Gambit > >
Re: API to detect which URL is open in Internet Explorer
Author: Thorsten Meyer
Date: Thu, 20 Apr 2006 07:27
Date: Thu, 20 Apr 2006 07:27
57 lines
2850 bytes
2850 bytes
Is another Way possible? Can i readout the Information of the Taskmanager. It shows the name of the Instance and in the Taskline you see the actual Site it is open in the browser. Don't know a possible class or function which can do this. Regards Thorsten Meyer "Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag news:4446769f$1@newsgroups.borland.com... > > "Thorsten Meyer" <meyer.t@hhb.bonn.de> wrote in message > news:44465d36@newsgroups.borland.com... > > > is there any way to detect with Windows API or VCL Komponent > > 1. if one or more Instances of Internet Explorer (IEXPLORE.EXE) is running > > There is nothing available for querying that directly. You will have to > track the instances manually. > > > 2. which URL's is actualy open (used) in the possible Instances of the > Internet Explorer > > For that, you have to actually connect to each IE browser window and query > its current URL from its DOM interfaces directly. Specifically from the > IWebBrowser2 interface, which has a LocationURL property. > > For both of these, I would suggest writing a Browse Helper Object. Then you > can install it into IE, and IE will load it automatically. When loaded, it > can communicate back to your main application as needed so that it knows > when IE is running, how many times the BHO is loaded, and to receive > notifications whenever the URL changes in a browser instance. > > Refer to MSDN for more details: > > Browser Helper Objects: The Browser the Way You Want It > http://msdn.microsoft.com/library/en-us/dnwebgen/html/bho.asp > > WebBrowser Control > > http://msdn.microsoft.com/workshop/browser/webbrowser/browser_control_node_entry.asp > > Interfaces and Scripting Objects > > http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/interface.asp > > > Gambit > >
Re: API to detect which URL is open in Internet Explorer
Author: Remy Lebeau (TeamB)
Date: Thu, 20 Apr 2006 07:52
Date: Thu, 20 Apr 2006 07:52
12 lines
1311 bytes
1311 bytes
"Thorsten Meyer" <meyer.t@hhb.bonn.de> wrote in message news:4447373c@newsgroups.borland.com... > Can i readout the Information of the Taskmanager. Not reliably, no. There are many third-party programs that wrap the IE browser (I personally use Crazy Browser, http://www.crazybrowser.com), so IE would not appear in the Task Manager at all under that condition. Gambit
Re: API to detect which URL is open in Internet Explorer
Author: Thorsten Meyer
Date: Thu, 20 Apr 2006 09:15
Date: Thu, 20 Apr 2006 09:15
18 lines
1637 bytes
1637 bytes
Hi > For that, you have to actually connect to each IE browser window and query > its current URL from its DOM interfaces directly. Specifically from the > IWebBrowser2 interface, which has a LocationURL property. how it is possible in Builder 5 to connect to am IE Browser window with a DOM interface, i don't find any way to implement such an interface. Does anyone know a link to code examples or Tutorials who explain this technique . With VS it is no Problem to generate an apppliaction with such an interface to get an IE Browser like application but no remote connection to a browser instance. Regards for an answer Thorsten Meyer
Re: API to detect which URL is open in Internet Explorer
Author: Remy Lebeau (TeamB)
Date: Thu, 20 Apr 2006 16:40
Date: Thu, 20 Apr 2006 16:40
12 lines
1298 bytes
1298 bytes
"Thorsten Meyer" <meyer.t@hhb.bonn.de> wrote in message news:4447509e@newsgroups.borland.com... > how it is possible in Builder 5 to connect to am IE > Browser window with a DOM interface I already told you how. You need to write a BOH. Did you read the articles I pointed you to? Gambit
Re: API to detect which URL is open in Internet Explorer
Author: Thorsten Meyer
Date: Thu, 20 Apr 2006 17:31
Date: Thu, 20 Apr 2006 17:31
162 lines
5285 bytes
5285 bytes
Hi,
i found another solution in the Internet, it works at first only for the
last Instance of the Internet Explorer an discover the number of all other
instances:
It works fine and is a Solution for my Problem!
Code Example:
Form Application with one Button and some Labels to show the values:
unit1.h:
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComObj.hpp>
#include <OleCtrls.hpp>
//--------------------------------------------------------------------------
-
class TForm1 : public TForm
{
__published: // Von der IDE verwaltete Komponenten
TButton *Button1;
TLabel *Label1;
TLabel *Label2;
TLabel *Label3;
TLabel *Label4;
void __fastcall Button1Click(TObject *Sender);
private: // Anwender-Deklarationen
Variant App;
public: // Anwender-Deklarationen
__fastcall TForm1(TComponent* Owner);
AnsiString GetReg(AnsiString Key, AnsiString Name, HKEY RootKey);
long GetProcessList( );
};
//--------------------------------------------------------------------------
-
extern PACKAGE TForm1 *Form1;
//--------------------------------------------------------------------------
-
#endif
unit1.cpp:
//--------------------------------------------------------------------------
-
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>
#include <Registry.hpp>
#include <DdeMan.hpp>
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//--------------------------------------------------------------------------
-
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------------
-
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int anzahl = GetProcessList();
Label3->Caption = anzahl;
if(anzahl <= 0)
return;
AnsiString Url;
AnsiString Browser = "IExplore";
TDdeClientConv *dde1 = new TDdeClientConv(this);
AnsiString RegPath =
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" +
Browser;
dde1->ServiceApplication = GetReg( RegPath , "" , HKEY_LOCAL_MACHINE );
if(dde1->SetLink( Browser, "WWW_GetWindowInfo" )==true)
{
char *str = dde1->RequestData( "0xFFFFFFFF" );
Url = str;
Label1->Caption = Url;
StrDispose(str);
}
delete dde1;
}
//--------------------------------------------------------------------------
-
AnsiString TForm1::GetReg(AnsiString Key, AnsiString Name, HKEY RootKey)
{
AnsiString Value;
TRegistry *Reg = new TRegistry();
Reg->RootKey = RootKey;
if(Reg->OpenKey(Key,false)){
if(Reg->ValueExists(Name))
Value = Reg->ReadString(Name);
Reg->CloseKey();
}
Reg->Free();
return Value;
}
//--------------------------------------------------------------------------
-
long TForm1::GetProcessList( )
{
HANDLE hProcessSnap;
HANDLE hProcess;
PROCESSENTRY32 pe32;
DWORD dwPriorityClass;
// Take a snapshot of all processes in the system.
hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if( hProcessSnap == INVALID_HANDLE_VALUE )
{
return -1;
}
// Set the size of the structure before using it.
pe32.dwSize = sizeof( PROCESSENTRY32 );
// Retrieve information about the first process,
// and exit if unsuccessful
if( !Process32First( hProcessSnap, &pe32 ) )
{
CloseHandle( hProcessSnap ); // Must clean up the snapshot object!
return -1;
}
// Now walk the snapshot of processes, and
// display information about each process in turn
AnsiString strings[1000]; //1000 for test only
int index = 0;
long counter = 0;
do
{
if(index > 1000)
break;
strings[index] = pe32.szExeFile;
if(strings[index] == "IEXPLORE.EXE")
{
counter++;
}
index++;
long processID = pe32.th32ProcessID;
long threadcount = pe32.cntThreads;
long parentprocessID = pe32.th32ParentProcessID;
long PriorityBase = pe32.pcPriClassBase;
} while( Process32Next( hProcessSnap, &pe32 ) );
CloseHandle( hProcessSnap );
return counter;
}
Re: API to detect which URL is open in Internet Explorer
Author: Thorsten Meyer
Date: Thu, 20 Apr 2006 17:36
Date: Thu, 20 Apr 2006 17:36
30 lines
1966 bytes
1966 bytes
Thanks for the answer, as you see above i found another solution! The whole COM and DOM "Shit" is so much complicated to use and you could not find any probably information in books or other sides, so i believe in API Programming in the future it is much more usefull for me! And so it works, without installing any other Software as ActiveX, Libraries or so. I think the easest way is in the most cases the best one. Regards for your informations Thorsten Meyer "Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag news:4447ba32$3@newsgroups.borland.com... > > "Thorsten Meyer" <meyer.t@hhb.bonn.de> wrote in message > news:4447509e@newsgroups.borland.com... > > > how it is possible in Builder 5 to connect to am IE > > Browser window with a DOM interface > > I already told you how. You need to write a BOH. Did you read the articles > I pointed you to? > > > Gambit > >
Re: API to detect which URL is open in Internet Explorer
Author: Remy Lebeau (TeamB)
Date: Thu, 20 Apr 2006 22:28
Date: Thu, 20 Apr 2006 22:28
22 lines
1750 bytes
1750 bytes
"Thorsten Meyer" <meyer.t@hhb.bonn.de> wrote in message news:4447c621$1@newsgroups.borland.com... > The whole COM and DOM "Shit" is so much complicated to use No, it is not. COM is very easy to use. It is no more difficult then using classes and objects in general. > you could not find any probably information in books or other sides Then you are not looking very hard, because that information is out there. I even pointed you to several articles. > And so it works, without installing any other Software as ActiveX, > Libraries or so. There is nothing to install that isn't already installed by the OS, other than your own DLL file that IE can then load directly. Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads