+ Reply to Thread
Results 1 to 2 of 2

Thread: How to identify whether process is running as windows service or not?

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    38

    How to identify whether process is running as windows service or not?

    I want to know whether process is running as a Windows service or not. How can I do this? Any idea would be very helpful.

  2. #2
    Junior Member
    Join Date
    Apr 2012
    Posts
    43
    1. For, Windows XP and older version:
    You can look for the user of the process and can identify whether process is running under Windows service account or not.
    2. For Windows Vista and later, you can use:

    Code:
    BOOL IsProcessWindowsService(DWORD dwProcessID)
    {
    	BOOL bIsProcessWindowsService = FALSE ;
    
    	DWORD dwSessionId = -1 ;
    	if (ProcessIdToSessionId(dwProcessID, &dwSessionId))
    	{
    		bIsProcessWindowsService = (0 == dwSessionId) ;
    	}
    
    	return bIsProcessWindowsService ;
    }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts