M
MrBewsher
Hi,
I'm using VB.Net and writing an NT service that runs in the system
account in the background with no interaction with the desktop.
I'm running it on XP Pro.
I'd like to get the URL of any Internet Explorer process a logged in
user is running.
I can get a list of process IDs and from that use
System.Diagnostics.Process.GetProcessById to get information about the
processes.
What I had planned to do was get the hWnd from the process with
process.MainWindowHandle, but this seems to always return 0. I'm
guessing that this is something to do with the service running in the
background.
So then I tried a different approach with the following code:
objShell = CreateObject("Shell.Application")
If Not objShell Is Nothing Then
For Each objIE In objShell.Windows
If Microsoft.VisualBasic.Left(objIE.LocationURL, 4)
= "http" Then
URLString &= objIE.LocationURL & " "
End If
Next
End If
This works from a standard desktop app and gets a list of the URLs in
all open IEs, but when I run it as part of the service, the first line
fails with "Class Not Registered". Again I'm guessing that this is
because I'm running in the background.
So now I'm at a dead end. I can get the processID of the iexplore
process, but can't get the windows handle and therefore I can't get any
further... but... well it's there somewhere! There has to be a way
to get it!
I would really appreciate any light that could be shed on this problem.
Mr B.
I'm using VB.Net and writing an NT service that runs in the system
account in the background with no interaction with the desktop.
I'm running it on XP Pro.
I'd like to get the URL of any Internet Explorer process a logged in
user is running.
I can get a list of process IDs and from that use
System.Diagnostics.Process.GetProcessById to get information about the
processes.
What I had planned to do was get the hWnd from the process with
process.MainWindowHandle, but this seems to always return 0. I'm
guessing that this is something to do with the service running in the
background.
So then I tried a different approach with the following code:
objShell = CreateObject("Shell.Application")
If Not objShell Is Nothing Then
For Each objIE In objShell.Windows
If Microsoft.VisualBasic.Left(objIE.LocationURL, 4)
= "http" Then
URLString &= objIE.LocationURL & " "
End If
Next
End If
This works from a standard desktop app and gets a list of the URLs in
all open IEs, but when I run it as part of the service, the first line
fails with "Class Not Registered". Again I'm guessing that this is
because I'm running in the background.
So now I'm at a dead end. I can get the processID of the iexplore
process, but can't get the windows handle and therefore I can't get any
further... but... well it's there somewhere! There has to be a way
to get it!
I would really appreciate any light that could be shed on this problem.
Mr B.