我来我网
https://5come5.cn
 
您尚未 登录  注册 | 菠菜 | 软件站 | 音乐站 | 邮箱1 | 邮箱2 | 风格选择 | 更多 » 
 

蓝鲸



性别: 帅哥 状态: 该用户目前不在线
等级: 栋梁之材
家族: 低调一族
发贴: 578
威望: 0
浮云: 1116
在线等级:
注册时间: 2007-09-05
最后登陆: 2012-02-25

5come5帮你背单词 [ trigger /'trigə/ n. 扳机;vt. 引起,激发起 ]


懂C++的请进

有谁知道creatprocess()函数的基本用法?它的头文件是什么?
下午在图书馆找了一下午没找到.明天急用.谢谢!
顶端 Posted: 2007-12-23 22:29 | [楼 主]
870630456





性别: 保密 状态: 该用户目前不在线
等级: 初出茅庐
发贴: 18
威望: 0
浮云: 1111
在线等级:
注册时间: 2006-11-03
最后登陆: 2009-10-26

5come5帮你背单词 [ blanket /'blæŋkit/ n. 毯子,厚厚一层 ]


是不是CreateProcess()函数呢
在头文件winbase.h里声明,具体用法参照MSDN
BOOL CreateProcess(
  LPCTSTR lpApplicationName,
                        // pointer to name of executable module
  LPTSTR lpCommandLine,  // pointer to command line string
  LPSECURITY_ATTRIBUTES lpProcessAttributes,  // process security attributes
  LPSECURITY_ATTRIBUTES lpThreadAttributes,  // 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
);
顶端 Posted: 2007-12-24 13:05 | [1 楼]
蓝鲸



性别: 帅哥 状态: 该用户目前不在线
等级: 栋梁之材
家族: 低调一族
发贴: 578
威望: 0
浮云: 1116
在线等级:
注册时间: 2007-09-05
最后登陆: 2012-02-25

5come5帮你背单词 [ loop /lu:p/ n. 圈,环状物;vt. 打环,使成圈 ]


非常感谢~~~~
顶端 Posted: 2007-12-24 13:41 | [2 楼]
路客与刀客



性别: 帅哥 状态: 该用户目前不在线
等级: 希望之光
家族: 梦魇图腾
发贴: 1980
威望: 0
浮云: 1186
在线等级:
注册时间: 2007-01-02
最后登陆: 2008-06-29

5come5帮你背单词 [ parachute /'pærəu:t/ n. 降落伞;v. 用降落伞投送/降落 ]


Quote:

This function is used to run a new program. It creates a new process and its primary thread. The new process executes the specified executable file.

A remote application interface (RAPI) version of this function exists, and it is named CeCreateProcess.

CreateProcess(
LPCWSTR lpszImageName,
LPCWSTR lpszCmdLine,
LPSECURITY_ATTRIBUTES lpsaProcess,
LPSECURITY_ATTRIBUTES lpsaThread,
BOOL fInheritHandles,
DWORD fdwCreate,
LPVOID lpvEnvironment,
LPWSTR lpszCurDir,
LPSTARTUPINFOW lpsiStartInfo,
LPPROCESS_INFORMATION lppiProcInfo);
Parameters

lpszImageName
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 or it can specify a partial path and filename.

The lpszImageName parameter must be non-NULL and must include the module name.

lpszCmdLine
Pointer to a null-terminated string that specifies the command line to execute. The system adds a null character to the command line, trimming the string if necessary, to indicate which file was actually used.
The lpszCmdLine parameter can be NULL. In that case, the function uses the string pointed to by lpszImageName as the command line.

If both lpszImageName and lpszCmdLine are non-NULL, * lpszImageName specifies the module to execute, and * lpszCmdLine specifies the command line. C runtime processes can use the argc and argv arguments.

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.

Windows CE versions 2.10 and later search the directories indicated by the lpszImageName parameter in the following order:

The windows (\windows) directory
The root (\) directory of the device
An OEM-dependent directory
The OEM-defined shell (\ceshell) directory — Platform Builder users only
Windows CE versions 1.0 through 2.01 search the directories indicated by the lpszImageName parameter in the following order:

The root of the PC Card, if it exists
The windows (\windows) directory
The root (\ ) directory of the device
lpsaProcess
Not supported; set to NULL.
lpsaThread
Not supported; set to NULL.
fInheritHandles
Not supported; set to NULL.
fdwCreate
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 Description
CREATE_DEFAULT_ERROR_MODE Not supported.
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 Not supported.
CREATE_SEPARATE_WOW_VDM Not supported.
CREATE_SHARED_WOW_VDM Not supported.
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 Not supported.
DEBUG_PROCESS If this flag is set, the calling process is treated as a debugger, and the new process is a process being debugged. Child processes of the new process are also 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 this flag is set, the calling process is treated as a debugger, and the new process is a process being debugged. No child processes of the new process are debugged. The system notifies the debugger of all debug events that occur in the process being debugged.
DETACHED_PROCESS Not supported.

Windows CE does not support the concept of a priority class. The priority of a thread is the only parameter that determines a thread's scheduling priority.

For Windows CE version 1.0 and 1.01, the fdwCreate parameter only supports the following values: CREATE_SUSPENDED and zero.

lpvEnvironment
Not supported; set to NULL.
lpszCurDir
Not supported; set to NULL.
lpsiStartInfo
Not supported; set to NULL.
lppiProcInfo
Pointer to a PROCESS_INFORMATION structure that receives identification information about the new process.
Return Values

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

The CreateProcess function is used to run a new program. 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, the handle can be used in any function that requires an object handle to that type.

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 lpszImageName string, it doesn’t matter whether the application name includes the filename extension.

Do not call CreateProcess from a DllMain function. This causes the application to stop responding.

The following registry subkey specifies a search path to use with the LoadLibrary function and CreateProcess:

\HKEY_LOCAL_MACHINE\Loader
  "SystemPath"=multi_sz:"\\path1\\"
                  "\\path2\\"

For efficiency, the path is searched before CESH but after the ROM and built in file systems. Note also that the path is only searched if path of the file being looked for is not explicitly specified.

The total length of the SystemPath value cannot exceed 260 characters, or the path will be completely ignored. A change to the SystemPath key does not take effect until a Windows CE-based device is reset.

ExitThread, CreateThread, 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 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.
The handle returned by the CreateProcess function has PROCESS_ALL_ACCESS access to the process object.

Thread names are logged. The name of the primary thread for a process is the process name. The names for other threads are the names of the functions they were started with. Windows CE also logs a module handle, which is used to distinguish cases where different modules start threads with the same name. Process and thread names are resolved using the TOC, so thread names will not be logged unless the module is built into the image.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winbase.h  Coredll.lib, Nk.lib

Note  This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.


以上是MSDN的内容。以下给出一个简单例子,这个例子只是打开C:\wu.txt记事本文档,其中NORMAL_PRIORITY_CLASS表示新建进程的优先级为普通优先级。
Quote:

STARTUPINFO si;
::ZeroMemory(&si,sizeof(STARTUPINFO));
si.cb=sizeof(STARTUPINFO);
PROCESS_INFORMATION pi;
if (::CrateProcess(NULL,_T("c:\\Windows\\Notepad.exe/*这里有个空格,后面为命令行参数 */C:\\wu.txt"),NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi))
{
        ::CloseHandle(pi.hThread);
        ::CloseHandle(pi.hProcess);
}


男人,千万不能让别人看到自己脆弱的一面.
顶端 Posted: 2007-12-24 18:43 | [3 楼]
路客与刀客



性别: 帅哥 状态: 该用户目前不在线
等级: 希望之光
家族: 梦魇图腾
发贴: 1980
威望: 0
浮云: 1186
在线等级:
注册时间: 2007-01-02
最后登陆: 2008-06-29

5come5帮你背单词 [ remember /ri'membə/ vt. 记起,想起,牢记,记住;vi. 记得,记起 ]


对了,楼主只需建立一个MFC工程,里面的Stdafx.h头文件里面就包含了定义::CteateProcess()函数的头文件了。


男人,千万不能让别人看到自己脆弱的一面.
顶端 Posted: 2007-12-24 18:51 | [4 楼]
wan520





性别: 帅哥 状态: 该用户目前不在线
等级: 希望之光
发贴: 1724
威望: 0
浮云: 1125
在线等级:
注册时间: 2006-02-20
最后登陆: 2010-11-04

5come5帮你背单词 [ engine /'end3əin/ n. 发动机,机车,火车头 ]


在MSDN上查,还有也可以百度一下哈!
顶端 Posted: 2007-12-24 23:14 | [5 楼]
蓝鲸



性别: 帅哥 状态: 该用户目前不在线
等级: 栋梁之材
家族: 低调一族
发贴: 578
威望: 0
浮云: 1116
在线等级:
注册时间: 2007-09-05
最后登陆: 2012-02-25

5come5帮你背单词 [ billion /'biljən/ num. (美)十亿,(英)亿万,兆 ]


Quote:
引用第5楼wan520于2007-12-24 23:14发表的  :
在MSDN上查,还有也可以百度一下哈!

试过,没找到详细的说明。
顶端 Posted: 2007-12-25 13:19 | [6 楼]
musant



性别: 帅哥 状态: 该用户目前不在线
等级: 品行端正
发贴: 104
威望: 0
浮云: 1122
在线等级:
注册时间: 2006-07-30
最后登陆: 2008-06-19

5come5帮你背单词 [ result /ri'zΛlt/ n. 结果,效果,成果,计算结果,答案 ]


内网兄弟很热心,不过我推荐看<windows核心编程>,理解会深些
顶端 Posted: 2007-12-25 18:24 | [7 楼]
我来我网·5come5 Forum » 程序员之家

Total 0.013600(s) query 5, Time now is:11-22 15:17, Gzip enabled
Powered by PHPWind v5.3, Localized by 5come5 Tech Team, 黔ICP备16009856号