472,782 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,782 software developers and data experts.

Getting the handle of a running service.

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?

Nov 21 '05 #1
1 1792
Patrick Dugan wrote:
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?



I'm a little confused as to what your trying to do... But, you can get
the system process handle from Process class.

Dim procId As Integer = Process.GetCurrentProcess ().Id

Console.WriteLine (procId)

HTH

--
Tom Shelton [MVP]
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Simon Niederberger | last post by:
Hi I've written a Windows Service which has - several (0-100) listeners threads which spawn worker threads based on events, timers etc - several (0-300) worker threads which handle data...
1
by: Tom J | last post by:
What do I have to do to get System.ServiceProcess.ServiceController.ExecuteCommand(int) to work? I have written a service that overrides OnCustomCommand to handle commands sent to it. If I...
2
by: David Hearn | last post by:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Description: An unhandled exception occurred during the execution of the current...
5
by: MrBewsher | last post by:
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...
3
by: Grant Schenck | last post by:
Hello, I have a Windows Service developed in C# .NET. I'm making it a remote server and I can, via an IPC Channel, expose methods and call them from a client. However, I now want my remoted...
33
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
0
by: monishch | last post by:
Hi!, I am developing a windows service using vb.net in VB 2005.Through the service I am trying to run a exe.While starting service I am getting the following error: ...
2
by: siddharthkhare | last post by:
Hi All, I am launching a IE using following code. ======================================================================= m_IeProcess = new Process(); m_IeProcess.StartInfo.WindowStyle =...
0
by: =?Utf-8?B?UmF2aQ==?= | last post by:
Hi, I have WCF service and integrated with STS (WS-Federation). The Service exposes 5 endpoints Win, UNT and Federated Windows, Federated UNT and Mex endpoint. My STS Service exposes 3 endpoints...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.