Into the world of Windows programming-----Windows process

Source: Internet
Author: User

Windows process

1 Windows process
A process is a container that contains a variety of resources for an application instance. Windows multitasking operating system, so you can execute multiple processes at the same time.

2 Some features of the Windows process
2.1 The process contains resources such as execution code.
The 2.2 process has a private address space.
2.3 Each process has an ID that identifies the process.
2.4 Each process has its own security attributes
2.5 include at least one thread that can be executed.

Environment of the two processes

1 Access to environmental information
Get:
LPVOID getenvironmentstrings (VOID)
The return value is all the environment information obtained
Release:

    BOOL freeenvironmentstrings (       LPTSTR lpszenvironmentblock)

2 Getting and setting of environment variables
Get:

 DWORD GetEnvironmentVariable (LPCTSTR lpName, //  variable name  LPTSTR lpbuffer, / /  data buff  DWORD NSize // buff ); 

The return value is the length of the obtained string
Set up:

  BOOL setenvironmentvariable (     / / variable name     lpctstr lpvalue  //  Value of the variable    );


Three process information
   1 Process ID and handle
      GetCurrentProcess Gets the handle to the process,
       The    return value is-1, which is the pseudo-handle of the current process and is always-1. If you want to get the actual handle of the current process, you need to use the OpenProcess function.
   2 open process

 HANDLE OpenProcess (DWORD dwdesiredaccess,  Span style= "margin:0px; padding:0px; line-height:1.5; Color:rgb (0, 128, 0); " >//  access mode  BOOL bInheritHandle, // Span style= "margin:0px; padding:0px; line-height:1.5; Color:rgb (0, 128, 0); " > Inherit the identity  DWORD dwprocessid    process id ); 

Returns a handle to a process
3 gets all the modules used by the process (EXE or DLL)
Use the PSAPI function.

BOOL EnumProcessModules (HANDLE hprocess,//Process HandleHmodule * Lphmodule,//Array of modulesDWORD CB,//the length of the arrayLpdword lpcbneeded//Gets the number of bytes to the data);


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.