`

CreateProcess Usage

 
阅读更多
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

(*
ADAPTED FROM:http://www.delphicorner.f9.co.uk/articles/wapi4.htm
Using CreateProcess to Execute Programs

How can I properly use CreateProcess to instantiate a new process?

What's a Process

Before I give you the code to execute a program in Windows with CreateProcess,
I feel we should delve a bit into the concept of  what a process is.
With Win32, Microsoft changed nomenclature to help make the distinction of new concepts more clear for developers.
Unfortunately, not everyone understood it - including myself at first.
In Win16 a process was the equivalent to an application.
That was just fine because Windows 3.1 was (and still is) a non-preemptive multitasking system - there's no such thing as threads.

But with the move to Win32 (Win95 and NT),
many people have made the mistake of equating a thread to a process.
It's not an unusual thing considering the familiarity with an older concept.
However, threads and processes are both distinct concepts and entities.
Threads are children of processes;
while processes, on the other hand,
are inert system entities that essentially do absolutely nothing but define a space in memory for threads to run - threads are the execution portion of a process
and a process can have many threads attached to it. That's it. I won't go into the esoteric particulars of memory locations and addressable space and the like.
Suffice it to say that processes are merely memory spaces for threads.

That said, executing a program in Win32 really means loading a process and its child thread(s) in memory.
And the way you do that in Win32 is with CreateProcess.
Mind you, for backward compatibility, the Win16 calls for executing programs,
WinExec and ShellExecute are still supported in the Windows API,
and still work. But for 32-bit programs, they're considered obsolete. Okay, let's dive into some code.

The following code utilizes the CreateProcess API call, and will execute any program, DOS or Windows.

{Supply a fully qualified path name in ProgramName}
procedure ExecNewProcess(ProgramName : String);
var
  StartInfo  : TStartupInfo;
  ProcInfo   : TProcessInformation;
  CreateOK   : Boolean;
begin

  { fill with known state }
  FillChar(StartInfo,SizeOf(TStartupInfo),#0);
  FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
  StartInfo.cb := SizeOf(TStartupInfo);

  CreateOK := CreateProcess(PChar(ProgramName),nil, nil, nil,False,
              CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
              nil, nil, StartInfo, ProcInfo);

  { check to see if successful }
  if CreateOK then
    //may or may not be needed. Usually wait for child processes
    WaitForSingleObject(ProcInfo.hProcess, INFINITE);
end;

Okay, while the code above works just fine for executing an application,
one of my readers pointed out that it doesn't work with programs that include a command line argument.
Why? Because CreateProcess' first parameter expects a fully qualified program name (path\executable) and nothing else!
In fact, if you include a command line in that parameter,
CreateProcess will do nothing. Yikes!
In that case, you have to use the second argument.
In fact, you can use the second parameter even for just executing a program with no command line.
Given that, ExecNewprocess would be changed as follows:

{Supply a fully qualified path name in ProgramName
and any arguments on the command line. As the help file
states: "If lpApplicationName is NULL, the first white space-delimited
token of the command line specifies the module name..." In English,
the characters before the first space encountered (or if no space is
encountered as in a single program call) is interpreted as the
EXE to execute. The rest of the string is the argument line.}
procedure ExecNewProcess(ProgramName : String);
var
  StartInfo  : TStartupInfo;
  ProcInfo   : TProcessInformation;
  CreateOK   : Boolean;
begin

  { fill with known state }
  FillChar(StartInfo,SizeOf(TStartupInfo),#0);
  FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
  StartInfo.cb := SizeOf(TStartupInfo);

  CreateOK := CreateProcess(nil, PChar(ProgramName), nil, nil,False,
              CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
              nil, nil, StartInfo, ProcInfo);

  { check to see if successful }
  if CreateOK then
    //may or may not be needed. Usually wait for child processes
    WaitForSingleObject(ProcInfo.hProcess, INFINITE);
end;

I know, it's a bit of complex call. And the documentation and online help aren't much help in getting information on it.
I think the biggest problem people have working with the WinAPI through Delphi is that
the help topics are directed towards C/C++ programmers, not Delphi programmers.
So on the fly, Delphi programmers have to translate the C/C++ conventions to Delphi.
This has caused a lot of confusion for me and others who have been exploring threads and processes.
With luck, we'll see better documentation emerge from either Borland or a third-party source.

Copyright ?? 1995, 1996, 1997 Brendan V. Delumpa All Rights Reserved
Here is an updated and improved version of the code that allows you to choose in code
whether the calling application (the one you have built) waits until the other program closes before continuing
or just carries on leaving the newly started program to its own devices:

procedure ExecNewProcess(ProgramName : String; Wait: Boolean);
var
  StartInfo : TStartupInfo;
  ProcInfo : TProcessInformation;
  CreateOK : Boolean;
begin
    { fill with known state }
  FillChar(StartInfo,SizeOf(TStartupInfo),#0);
  FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
  StartInfo.cb := SizeOf(TStartupInfo);
  CreateOK := CreateProcess(nil, PChar(ProgramName), nil, nil,False,
              CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
              nil, nil, StartInfo, ProcInfo);
    { check to see if successful }
  if CreateOK then
    begin
        //may or may not be needed. Usually wait for child processes
      if Wait then
        WaitForSingleObject(ProcInfo.hProcess, INFINITE);
    end
  else
    begin
      ShowMessage('Unable to run '+ProgramName);
     end;

  CloseHandle(ProcInfo.hProcess);
  CloseHandle(ProcInfo.hThread);
end;

Modification ?? 2000 Chris Bray

Copyright ?? The Delphi Corner 2001 All Rights Reserved

*)
procedure TForm1.Button1Click(Sender: TObject);
var
   si:Windows.TStartupinfo;//here comes with info
   pi:Windows.TProcessinformation;//here comes with infomation
   createok:boolean;
const
   programname='c:\windows\notepad.exe';
begin
   Fillchar(si,sizeof(TStartupinfo),#0);
   FillChar(pi,sizeof(pi),#0);
   si.cb:=sizeof(TStartupinfo);
   CreateOK := CreateProcess(PChar(ProgramName),nil, nil, nil,False,
              CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
              nil, nil, Si, Pi);
  if CreateOK then
    WaitForSingleObject(pi.hProcess, INFINITE);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
   si:Windows.TStartupinfo;//here comes with info
   pi:Windows.TProcessinformation;//here comes with infomation
   createok:boolean;
const
   programname='c:\windows\notepad.exe c:\1.txt';
begin
   Fillchar(si,sizeof(TStartupinfo),#0);
   FillChar(pi,sizeof(pi),#0);
   si.cb:=sizeof(TStartupinfo);
   CreateOK := CreateProcess(nil,PChar(ProgramName), nil, nil,False,
              CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
              nil, nil, Si, Pi);
  if CreateOK then
    WaitForSingleObject(pi.hProcess, INFINITE);
end;


procedure TForm1.Button3Click(Sender: TObject);
var
   si:Windows.TStartupinfo;//here comes with info
   pi:Windows.TProcessinformation;//here comes with infomation
   createok:boolean;
   wait:boolean;
const
   programname='c:\windows\notepad.exe c:\1.txt';
begin
   Fillchar(si,sizeof(TStartupinfo),#0);
   FillChar(pi,sizeof(pi),#0);
   si.cb:=sizeof(TStartupinfo);
   CreateOK := CreateProcess(nil,PChar(ProgramName), nil, nil,False,
              CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
              nil, nil, Si, Pi);
  wait:=true;
  {
  here you should know the difference between wait's true and false:
  if true, after click this button,
  you main exe will lose mouse control,can not do anything. because it is now waitng for programname...  when close programname,main exe works as before.
  the programname have the ability to do everything...
  but false,you main exe will still run normally,can do anything.because programname is now belong to its own device.
  }
  if CreateOK then
  begin
    if wait then
    WaitForSingleObject(pi.hProcess, INFINITE);
  end
  else
  begin
    showmessage('unable to run the program:'+programname);
  end;
(*
From borland help about CreateProcess:

The CreateProcess function creates a new process and its primary thread. The new process executes the specified executable file.

BOOL CreateProcess(

    LPCTSTR lpApplicationName, // pointer to name of executable module
    LPTSTR lpCommandLine, // pointer to command line string
    LPSECURITY_ATTRIBUTES lpProcessAttributes, // pointer to process security attributes
    LPSECURITY_ATTRIBUTES lpThreadAttributes, // pointer to thread security attributes
    BOOL bInheritHandles, // handle inheritance flag
    DWORD dwCreationFlags, // creation flags
    LPVOID lpEnvironment, // pointer to new environment block
    LPCTSTR lpCurrentDirectory, // pointer to current directory name
    LPSTARTUPINFO lpStartupInfo, // pointer to STARTUPINFO
    LPPROCESS_INFORMATION lpProcessInformation // pointer to PROCESS_INFORMATION 
   );


Parameters

lpApplicationName

Pointer to a null-terminated string that specifies the module to execute.

The string can specify the full path and filename of the module to execute.
The string can specify a partial name. In that case, the function uses the current drive and current directory to complete the specification.
The lpApplicationName parameter can be NULL. In that case, the module name must be the first white space-delimited token in the lpCommandLine string.
The specified module can be a Win32-based application. It can be some other type of module (for example, MS-DOS or OS/2) if the appropriate subsystem is available on the local computer.

Windows NT: If the executable module is a 16-bit application, lpApplicationName should be NULL, and the string pointed to by lpCommandLine should specify the executable module. A 16-bit application is one that executes as a VDM or WOW process. 

lpCommandLine

Pointer to a null-terminated string that specifies the command line to execute.

The lpCommandLine parameter can be NULL. In that case, the function uses the string pointed to by lpApplicationName as the command line.
If both lpApplicationName and lpCommandLine are non-NULL, *lpApplicationName specifies the module to execute, and *lpCommandLine specifies the command line. The new process can use GetCommandLine to retrieve the entire command line. C runtime processes can use the argc and argv arguments.

If lpApplicationName is NULL, the first white space-delimited token of the command line specifies the module name. If the filename does not contain an extension, .EXE is assumed. If the filename ends in a period (.) with no extension, or the filename contains a path, .EXE is not appended. If the filename does not contain a directory path, Windows searches for the executable file in the following sequence:

1. The directory from which the application loaded.
2. The current directory for the parent process.
3. Windows 95: The Windows system directory. Use the GetSystemDirectory function to get the path of this directory.

Windows NT: The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is SYSTEM32.

4. Windows NT: The 16-bit Windows system directory. There is no Win32 function that obtains the path of this directory, but it is searched. The name of this directory is SYSTEM.
5. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
6. The directories that are listed in the PATH environment variable.



If the process to be created is an MS-DOS - based or Windows-based application, lpCommandLine should be a full command line in which the first element is the application name. Because this also works well for Win32-based applications, it is the most robust way to set lpCommandLine.

lpProcessAttributes

Pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If lpProcessAttributes is NULL, the handle cannot be inherited.

Windows NT: The lpSecurityDescriptor member of the structure specifies a security descriptor for the new process. If lpProcessAttributes is NULL, the process gets a default security descriptor.
Windows 95: The lpSecurityDescriptor member of the structure is ignored.

lpThreadAttributes

Pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If lpThreadAttributes is NULL, the handle cannot be inherited.

Windows NT: The lpSecurityDescriptor member of the structure specifies a security descriptor for the main thread. If lpThreadAttributes is NULL, the thread gets a default security descriptor.
Windows 95: The lpSecurityDescriptor member of the structure is ignored.

bInheritHandles

Indicates whether the new process inherits handles from the calling process. If TRUE, each inheritable open handle in the calling process is inherited by the new process. Inherited handles have the same value and access privileges as the original handles.

dwCreationFlags

Specifies additional flags that control the priority class and the creation of the process. The following creation flags can be specified in any combination, except as noted:

Value Meaning
CREATE_DEFAULT_ERROR_MODE
The new process does not inherit the error mode of the calling process. Instead, CreateProcess gives the new process the current default error mode. An application sets the current default error mode by calling SetErrorMode.This flag is particularly useful for multi-threaded shell applications that run with hard errors disabled. The default behavior for CreateProcess is for the new process to inherit the error mode of the caller. Setting this flag changes that default behavior.
CREATE_NEW_CONSOLE
The new process has a new console, instead of inheriting the parent's console. This flag cannot be used with the DETACHED_PROCESS flag.
CREATE_NEW_PROCESS_GROUP
The new process is the root process of a new process group. The process group includes all processes that are descendants of this root process. The process identifier of the new process group is the same as the process identifier, which is returned in the lpProcessInformation parameter. Process groups are used by the GenerateConsoleCtrlEvent function to enable sending a CTRL+C or CTRL+BREAK signal to a group of console processes.
CREATE_SEPARATE_WOW_VDM
Windows NT only: This flag is valid only when starting a 16-bit Windows-based application. If set, the new process is run in a private Virtual DOS Machine (VDM). By default, all 16-bit Windows-based applications are run as threads in a single, shared VDM. The advantage of running separately is that a crash only kills the single VDM; any other programs running in distinct VDMs continue to function normally. Also, 16-bit Windows-based applications that are run in separate VDMs have separate input queues. That means that if one application hangs momentarily, applications in separate VDMs continue to receive input.
CREATE_SHARED_WOW_VDM
Windows NT only: The flag is valid only when starting a 16-bit Windows-based application. If the DefaultSeparateVDM switch in the Windows section of WIN.INI is TRUE, this flag causes the CreateProcess function to override the switch and run the new process in the shared Virtual DOS Machine.
CREATE_SUSPENDED
The primary thread of the new process is created in a suspended state, and does not run until the ResumeThread function is called.
CREATE_UNICODE_ENVIRONMENT
If set, the environment block pointed to by lpEnvironment uses Unicode characters. If clear, the environment block uses ANSI characters.
DEBUG_PROCESS
If this flag is set, the calling process is treated as a debugger, and the new process is a process being debugged. The system notifies the debugger of all debug events that occur in the process being debugged.If you create a process with this flag set, only the calling thread (the thread that called CreateProcess) can call the WaitForDebugEvent function.
DEBUG_ONLY_THIS_PROCESS
If not set and the calling process is being debugged, the new process becomes another process being debugged by the calling process's debugger. If the calling process is not a process being debugged, no debugging-related actions occur.
DETACHED_PROCESS
For console processes, the new process does not have access to the console of the parent process. The new process can call the AllocConsole function at a later time to create a new console. This flag cannot be used with the CREATE_NEW_CONSOLE flag.


The dwCreationFlags parameter also controls the new process's priority class, which is used in determining the scheduling priorities of the process's threads. If none of the following priority class flags is specified, the priority class defaults to NORMAL_PRIORITY_CLASS unless the priority class of the creating process is IDLE_PRIORITY_CLASS. In this case the default priority class of the child process is IDLE_PRIORITY_CLASS. One of the following flags can be specified:

Priority Meaning
HIGH_PRIORITY_CLASS Indicates a process that performs time-critical tasks that must be executed immediately for it to run correctly. The threads of a high-priority class process preempt the threads of normal-priority or idle-priority class processes. An example is Windows Task List, which must respond quickly when called by the user, regardless of the load on the operating system. Use extreme care when using the high-priority class, because a high-priority class CPU-bound application can use nearly all available cycles.
IDLE_PRIORITY_CLASS Indicates a process whose threads run only when the system is idle and are preempted by the threads of any process running in a higher priority class. An example is a screen saver. The idle priority class is inherited by child processes.
NORMAL_PRIORITY_CLASS Indicates a normal process with no special scheduling needs.
REALTIME_PRIORITY_CLASS Indicates a process that has the highest possible priority. The threads of a real-time priority class process preempt the threads of all other processes, including operating system processes performing important tasks. For example, a real-time process that executes for more than a very brief interval can cause disk caches not to flush or cause the mouse to be unresponsive.


lpEnvironment

Points to an environment block for the new process. If this parameter is NULL, the new process uses the environment of the calling process.

An environment block consists of a null-terminated block of null-terminated strings. Each string is in the form:

name=value 


Because the equal sign is used as a separator, it must not be used in the name of an environment variable.
If an application provides an environment block, rather than passing NULL for this parameter, the current directory information of the system drives is not automatically propagated to the new process. For a discussion of this situation and how to handle it, see the following Remarks section.
An environment block can contain Unicode or ANSI characters. If the environment block pointed to by lpEnvironment contains Unicode characters, the dwCreationFlags field's CREATE_UNICODE_ENVIRONMENT flag will be set. If the block contains ANSI characters, that flag will be clear.

Note that an ANSI environment block is terminated by two zero bytes: one for the last string, one more to terminate the block. A Unicode environment block is terminated by four zero bytes: two for the last string, two more to terminate the block.

lpCurrentDirectory

Points to a null-terminated string that specifies the current drive and directory for the child process. The string must be a full path and filename that includes a drive letter. If this parameter is NULL, the new process is created with the same current drive and directory as the calling process. This option is provided primarily for shells that need to start an application and specify its initial drive and working directory.

lpStartupInfo

Points to a STARTUPINFO structure that specifies how the main window for the new process should appear.

lpProcessInformation

Points to a PROCESS_INFORMATION structure that receives identification information about the new process.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The CreateProcess function is used to run a new program. The WinExec and LoadModule functions are still available, but they are implemented as calls to
CreateProcess.
In addition to creating a process, CreateProcess also creates a thread object. The thread is created with an initial stack whose size is described in the image header of the specified program's executable file. The thread begins execution at the image's entry point.

The new process and the new thread handles are created with full access rights. For either handle, if a security descriptor is not provided, the handle can be used in any function that requires an object handle of that type. When a security descriptor is provided, an access check is performed on all subsequent uses of the handle before access is granted. If the access check denies access, the requesting process is not able to use the handle to gain access to the thread.

The process is assigned a 32-bit process identifier. The identifier is valid until the process terminates. It can be used to identify the process, or specified in the
OpenProcess function to open a handle to the process. The initial thread in the process is also assigned a 32-bit thread identifier. The identifier is valid until the thread terminates and can be used to uniquely identify the thread within the system. These identifiers are returned in the PROCESS_INFORMATION structure.

When specifying an application name in the lpApplicationName or lpCommandLine strings, it doesn't matter whether the application name includes the filename extension, with one exception: an MS-DOS - based or Windows-based application whose filename extension is .COM must include the .COM extension.
The calling thread can use the WaitForInputIdle function to wait until the new process has finished its initialization and is waiting for user input with no input pending. This can be useful for synchronization between parent and child processes, because CreateProcess returns without waiting for the new process to finish its initialization. For example, the creating process would use WaitForInputIdle before trying to find a window associated with the new process.

The preferred way to shut down a process is by using the ExitProcess function, because this function notifies all dynamic-link libraries (DLLs) attached to the process of the approaching termination. Other means of shutting down a process do not notify the attached DLLs. Note that when a thread calls ExitProcess, other threads of the process are terminated without an opportunity to execute any additional code (including the thread termination code of attached DLLs).

ExitProcess, ExitThread, CreateThread, CreateRemoteThread, and a process that is starting (as the result of a call by CreateProcess) are serialized between each other within a process. Only one of these events can happen in an address space at a time. This means the following restrictions hold:

?During process startup and DLL initialization routines, new threads can be created, but they do not begin execution until DLL initialization is done for the process.
?Only one thread in a process can be in a DLL initialization or detach routine at a time.
?The ExitProcess function does not return until no threads are in their DLL initialization or detach routines.



The created process remains in the system until all threads within the process have terminated and all handles to the process and any of its threads have been closed through calls to CloseHandle. The handles for both the process and the main thread must be closed through calls to CloseHandle. If these handles are not needed, it is best to close them immediately after the process is created.
When the last thread in a process terminates, the following events occur:

?All objects opened by the process are implicitly closed.
?The process's termination status (which is returned by GetExitCodeProcess) changes from its initial value of STILL_ACTIVE to the termination status of the last thread to terminate.
?The thread object of the main thread is set to the signaled state, satisfying any threads that were waiting on the object.
?The process object is set to the signaled state, satisfying any threads that were waiting on the object.



If the current directory on drive C is \MSVC\MFC, there is an environment variable called =C: whose value is C:\MSVC\MFC. As noted in the previous description of lpEnvironment, such current directory information for a system's drives does not automatically propagate to a new process when the CreateProcess function's lpEnvironment parameter is non-NULL. An application must manually pass the current directory information to the new process. To do so, the application must explicitly create the =X environment variable strings, get them into alphabetical order (because Windows NT and Windows 95 use a sorted environment), and then put them into the environment block specified by lpEnvironment. Typically, they will go at the front of the environment block, due to the previously mentioned environment block sorting.

One way to obtain the current directory variable for a drive X is to call GetFullPathName("X:",. .). That avoids an application having to scan the environment block. If the full path returned is X:\, there is no need to pass that value on as environment data, since the root directory is the default current directory for drive X of a new process.
The handle returned by the CreateProcess function has PROCESS_ALL_ACCESS access to the process object.

The current directory specified by the lpcurrentDirectory parameter is the current directory for the child process. The current directory specified in item 2 under the lpCommandLine parameter is the current directory for the parent process.
Windows NT: When a process is created with CREATE_NEW_PROCESS_GROUP specified, an implicit call to SetConsoleCtrlHandler(NULL,TRUE) is made on behalf of the new process; this means that the new process has CTRL+C disabled. This lets good shells handle CTRL+C themselves, and selectively pass that signal on to sub-processes. CTRL+BREAK is not disabled, and may be used to interrupt the process/process group.

See Also

AllocConsole, CloseHandle, CreateRemoteThread, CreateThread, ExitProcess, ExitThread, GenerateConsoleCtrlEvent, GetCommandLine, GetEnvironmentStrings, GetExitCodeProcess, GetFullPathName, GetStartupInfo, GetSystemDirectory, GetWindowsDirectory, LoadModule, OpenProcess, PROCESS_INFORMATION, ResumeThread, SECURITY_ATTRIBUTES, SetConsoleCtrlHandler, SetErrorMode, STARTUPINFO, TerminateProcess, WaitForInputIdle, WaitForDebugEvent, WinExec end;

*)

end.
分享到:
评论

相关推荐

    CreateProcess

    通过进程打开另一个进程的三种方法:CreateProcess,WinExec,ShellExecute ,给出了调用的实现代码,源码中有CreateProcess,ShellExecute的函数说明,包含一个可执行的演示程序和源码 用VC2008编写的

    一个CREATEPROCESS()的实例

    创建进程实例,使用CreateProcess()函数打开一个程序的实例 CreateProcess()函数是Windows操作系统中用于创建新进程的API函数。该函数可以用来创建一个新的进程实例,并指定其执行的命令行参数、安全性设置、...

    以CreateProcess为例运行系统程序并输出结果

    在Windows操作系统中,创建一个新的进程并执行一个系统程序通常是通过API函数`CreateProcess`来实现的。`CreateProcess`是Windows API提供的一种低级进程创建方法,它允许开发者具有较高的控制权,例如设置进程和...

    CreateProcess调用后,获得主窗口句柄

    用CreateProcess创建进程后,得到主窗口句柄。

    新建程序进程CreateProcess

    标题中的“新建程序进程CreateProcess”指的是在编程中创建新的操作系统进程的过程,这通常涉及到操作系统级别的操作,如在Windows系统中使用API函数`CreateProcess`。`CreateProcess`是Windows API提供的一种机制,...

    解决createprocess error code 740

    标题 "解决createprocess error code 740" 指的是在尝试运行一个应用程序时遇到的一个特定错误,其中 `CreateProcess` 是 Windows API 中用于创建新进程的函数。错误代码 740 表示 "请求的操作需要提升的权限",意味...

    用CreateProcess创建进程

    在Windows操作系统中,`CreateProcess`函数是用于创建新进程和其主线程的关键API。它提供了灵活的方式来启动和控制一个程序,包括指定命令行参数、环境变量、工作目录以及进程和线程的安全属性。本篇文章将深入探讨`...

    CreateProcess函数 详细使用说明

    **CreateProcess函数详解** 在Windows操作系统中,`CreateProcess`函数是用于创建新进程和其初始主线程的关键API。这个函数允许程序员启动新的应用程序,并控制它们的执行环境。`CreateProcess`不仅创建新进程,还...

    createprocess创建进程并获取进程窗口HWND

    createprocess创建进程并获取进程窗口HWND,不管窗口是否在显示状态都可以获取。

    CreateProcess拦截exe程序

    在这个场景中,"CreateProcess拦截exe程序"指的是通过API Hook来拦截`CreateProcess`函数,这是一种Windows API,用于创建新的进程和其初始线程。下面我们将深入探讨`CreateProcess`、API Hook的基本概念以及如何...

    一个简单的可以Debug用CreateProcess创建的进程例子

    本篇文章将探讨如何使用`CreateProcess`函数在Windows环境中创建进程,并通过Visual Studio(VS)的调试器对其进行附加调试。`CreateProcess`是Windows API提供的一种功能,用于启动新的进程或线程。这个例子特别...

    CreateProcess创建暂停进程进行DLL注入-[VC.Dll+VB.Code]

    本教程将深入讲解如何使用`CreateProcess`函数在VC++中创建一个新的进程,并在VB环境下编写代码进行DLL注入。 `CreateProcess`是Windows API中的一个关键函数,它负责启动新的进程并可选地创建新的线程。这个函数...

    父子进程,createprocess

    在IT领域,特别是操作系统设计和进程管理中,"父子进程,createprocess" 是一个关键的概念。这个主题涉及到操作系统如何创建新的进程以及它们如何并发执行。本文将深入探讨这个主题,结合给定的描述,我们将专注于...

    vs2010下hook_createprocess

    "hook_createprocess"这个主题涉及的是在Visual Studio 2010环境下,通过编写DLL动态链接库来实现对`CreateProcess`函数的钩子,以便在创建新进程时进行干预。`CreateProcess`是Windows API中用于启动新进程的关键...

    API_HOOK_CreateProcess进程监视:知道你运行了哪些程序.zip

    在这个特定的案例中,"API_HOOK_CreateProcess进程监视"指的是利用API钩子来监控系统的CreateProcess函数。CreateProcess是Windows操作系统中的一个关键API,它负责创建新的进程和执行新的可执行文件。 当我们谈论...

    ShellExecute和CreateProcess打开指定程序

    本文将深入探讨两种常见的方法:ShellExecute和CreateProcess。这两种方法都是Windows API提供的功能,用于执行应用程序,但它们在使用场景和特性上有所不同。 **ShellExecute** ShellExecute是Windows Shell服务...

    pipe-CMD.rar_CMD回显_CreateProcess_c++ cmd pipe_windows管道cmd_管道 c

    利用管道执行cmd,显示回显内容,管道加createprocess实现该功能

    windows下eclipse跑junit报错:CreateProcess error=206

    windows下eclipse跑junit报错:CreateProcess error=206后面跟着乱码。 把这个jar替换掉就好了,放在:eclipse/plugins/下面。 参考:https://bugs.eclipse.org/bugs/show_bug.cgi?id=327193

Global site tag (gtag.js) - Google Analytics