Hi Potsang,
Thinathayalan's reply has shown how to enumerate all the running processes
to find your "Windows Service" and get its full path. I think it should
meet your need. I want to provide some more information to you.
If you want to retrieve the full path to the "Windows Service" when it is
not running, you can not use System.Diagnost ics.Process class solution. In
this requirement, you have to use QueryServiceCon fig Win32 API to obtain
the installed service binary full path. However, .Net did not expose this
QueryServiceCon fig API from class library, so you have to p/invoke to call
it. You may use the logic below:
1. Use ServiceControll er.GetServices method to retrieve all the services
installed on your system.
2. Enumerate through this services list and compare
ServiceControll er.ServiceName property to find your service
ServiceControll er reference.
3. Then p/invoke QueryServiceCon fig win32 API by passing
ServiceControll erServiceHandle .handle to it. The retrieved
QUERY_SERVICE_C ONFIG structure has a field of lpBinaryPathNam e, which
contains the full binary path of the service.
My original reply below contains some more information:
http://groups.google.com/group/micro...es.vb/msg/6452
aa87e538615f?hl =zh-CN&
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.