P
Patrick Dugan
Is it possible to get the handle of a running service? I have a program
(ActiveX program) running in memory.
When I start my service I need to pass the service's handle to that program
in order to attach to it.
I cannot use Me.Handle because there is no such information within a service
application.
I have tried this small routine:
Dim PID1 As Integer
Dim PID2 As Integer
Dim proc As Process
Dim processes() As Process
processes = Diagnostics.Process.GetProcessesByName("MyService")
For Each proc In processes
PID1 = proc.Handle.ToInt32
PID2 = proc.MainWindowHandle.ToInt32
Next
If I loop through that routine both PID1 and PID2 give constantly changing
values. I thought the handle for the process
would always be the same. How can I get the correct handle of this service
so I can pass that
to another program?
(ActiveX program) running in memory.
When I start my service I need to pass the service's handle to that program
in order to attach to it.
I cannot use Me.Handle because there is no such information within a service
application.
I have tried this small routine:
Dim PID1 As Integer
Dim PID2 As Integer
Dim proc As Process
Dim processes() As Process
processes = Diagnostics.Process.GetProcessesByName("MyService")
For Each proc In processes
PID1 = proc.Handle.ToInt32
PID2 = proc.MainWindowHandle.ToInt32
Next
If I loop through that routine both PID1 and PID2 give constantly changing
values. I thought the handle for the process
would always be the same. How can I get the correct handle of this service
so I can pass that
to another program?