Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6176267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:04:13+00:00 2026-05-24T00:04:13+00:00

I have created this function to get the path of various network processes, like

  • 0

I have created this function to get the path of various network processes, like svchost, Firefox, etc. Here is the code:

function GetProcessPath(var pId:Integer):String;
var
    Handle: THandle;

begin
    Result := '';
    try
        Handle := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, pID);
        if Handle <> 0 then
        begin
            try
               SetLength(Result, MAX_PATH);
               if GetModuleFileNameEx(Handle, 0, PChar(Result), MAX_PATH) > 0 then
                   SetLength(Result, StrLen(PChar(Result)))
               else
                  Result := '';
            finally
                CloseHandle(Handle);
        end;
    end;

    except
       on E:Exception do
           ShowMessage(E.ClassName + ':' + E.Message);
    end;
end;

My problem is that I do not get the path of all the processes. It works fine for getting the path of Firefox, and other similar user level processes. But for processes like alg, Svchost, I cannot get the path by this method. My guess is I must use some different API. How can I fix this problem?

I am using Windows XP, 32 bits.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:04:13+00:00Added an answer on May 24, 2026 at 12:04 am

    You need to set debug privileges. Here is how it is done:

    function NTSetPrivilege(sPrivilege: string; bEnabled: Boolean): Boolean;
    var
      hToken: THandle;
      TokenPriv: TOKEN_PRIVILEGES;
      PrevTokenPriv: TOKEN_PRIVILEGES;
      ReturnLength: Cardinal;
    begin
      Result := True;
    
      // Only for Windows NT/2000/XP and later.
      if not (Win32Platform = VER_PLATFORM_WIN32_NT) then Exit;
    
      Result := False;
    
      // Obtain the processes token
      if OpenProcessToken(GetCurrentProcess(),
        TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then
      begin
        try
          // Get the locally unique identifier (LUID) .
          if LookupPrivilegeValue(nil, PChar(sPrivilege),
            TokenPriv.Privileges[0].Luid) then
          begin
            TokenPriv.PrivilegeCount := 1; // One privilege to set
    
            case bEnabled of
              True: TokenPriv.Privileges[0].Attributes  := SE_PRIVILEGE_ENABLED;
              False: TokenPriv.Privileges[0].Attributes := 0;
            end;
    
            ReturnLength := 0; // Replaces a var parameter
            PrevTokenPriv := TokenPriv;
    
            // Enable or disable the privilege
    
            AdjustTokenPrivileges(hToken, False, TokenPriv, SizeOf(PrevTokenPriv),
              PrevTokenPriv, ReturnLength);
          end;
        finally
          CloseHandle(hToken);
        end;
      end;
    end;
    
    NtSetPrivilege('SeDebugPrivilege', TRUE); // Call this on form create
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have dialog created like this $('#add_error').click(function(e) { $('<div>') .load('/someaction/format/html/') .dialog({ title: 'Some title',
I have created this code, and when I run it, don't get any errors
i have created a module with this among others this function in it: <?php
I have a loop created with each, check this example: $('.foo').each(function(i){ //do stuff });
Ok, I have one JavaScript that creates rows in a table like this: function
I have created something like this and this . In effect I have a
I have this function: CREATE OR REPLACE FUNCTION CREATE_AIRSPACE_AVAILABILITY_RECORD (cur_user VARCHAR, start_time VARCHAR, start_date
How would I create a nested list, I currently have this public function getNav($cat,$subcat){
I have this class that have a function to load other classes and create
I have created this report using BIRT and phpjavabridge <?php header(Content-type: application/pdf); header(Content-Disposition: inline;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.