Obtain the absolute path of the process through the file handle

Source: Internet
Author: User

If you are not familiar with underlying APIs, struct, and pointers, we do not recommend that you use APIs.
The AAuto Standard Library provides more stable and convenient methods to solve common programming problems. You should try your best to use standard library functions.

Import winex; // supports importing external window control Libraries
Import process; // import the external process control support library

Io. open () // open the Console

Process.exe cute ("notepad.exe") // run notepad

Var hwnd = winex. waitActive (, "Notepad"); // wait for Notepad to activate and obtain the handle
Var tid, pid = win. getThreadProcessId (hwnd); // obtain the thread ID
Var prcs = process (pid); // open the process

Var exePath = prcs. getPath ()
Io. print ("complete path of execution program obtained", exePath)

// Use the following code to list all DLL paths loaded by the program
For moduleEntry in prcs. eachModule (){
Io. print ("loading module path", moduleEntry. szExePath)
}


Other methods

Import process; import win; hwnd = 199492; // handle tid, pid = win. getThreadProcessId (hwnd); // obtain the process IDpath = process according to the handle. getPath (pid); // obtain the path win based on the process ID. msgbox (path, "AAuto ");


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.