CreateProcess的 [英] CreateProcess

查看:53
本文介绍了CreateProcess的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法为

创建的进程设置环境(特别是PATH)?


我当前的应用程序是使用正确的路径创建的我希望

来通过这个新创建过程的路径将是我当前的一个独立的过程。


任何想法都会有所帮助。


如果您也可以通过电子邮件将回复发送到
es **** @ cerner,我将不胜感激。 com 除了在这个新闻组中发布,如果

可能。


谢谢

Elly Sokol es****@cerner.com

解决方案

es****@jetbiz.com (Elly Sokol)写道:

有没有办法为
创建的进程设置环境(特别是PATH)?

我当前的应用程序是使用正确的路径创建的,我想要
到 ;通过"通往新创建过程的这条路径将是我现有过程的独立过程。

任何想法都会有所帮助。

我会很感激如果您还可以通过电子邮件将回复发送到
es****@cerner.com 除了在此发布新闻组如果可能的话。

谢谢
Elly Sokol
es ****来自MSDN / Platform SDK的
:DLL,进程和线程:


BOOL

CreateProcess(

LPCTSTR lpApplicationName

,LPTSTR lpCommandLine

,LPSECURITY_ATTRIBUTES lpProcessAttributes

,LPSECURITY_ATTRIBUTES lpThreadAttributes

,BOOL bInheritHandles

,DWORD dwCreationFlags

,LPVOID lpEnvironment

,LPCTSTR lpCurrentDirectory
,L PSTARTUPINFO lpStartupInfo

,LPPROCESS_INFORMATION lpProcessInformation

);


其中lpEnvironment:

指向环境的指针阻止新进程。如果此参数为NULL,则

新进程使用调用进程的环境。

环境块由以null结尾的空终止块

字符串。每个字符串的形式如下:


name = value


因为等号用作分隔符,

它不能在环境变量的名称中使用。


环境块可以包含Unicode或ANSI字符。

如果环境块由lpEnvironment指向包含Unicode

字符,请确保dwCreationFlags包含CREATE_UNICODE_ENVIRONMENT。


请注意,ANSI环境块由两个零字节终止:

一个用于最后一个字符串,另外一个用于终止块。

Unicode环境块以四个零字节终止:

最后一个字符串字符串,另外两个终止块。


-

问候,

Misha Polatov

MetaCommunications Engineering


2004年6月17日星期四16:51:57 -0500 comp.lang.c ++,Misha Polatov< mp ****** @ meta-comm.com>从MSDN / Platform SDK写道,

:DLL,进程和线程:




这个评论在comp.lang.c ++中是OFF TOPIC 。请保留您的答案

标准的可移植C ++内容并避免专有的API讨论。


请参阅comp.lang.c ++中每周发布两次的欢迎消息或

可在
http://www.slack获取.net / ~shiva / welcome.txt


David Harmon写道:

< snip>

请参阅每周两次在comp.lang.c ++中发布的欢迎消息或
http://www.slack.net/~shiva/welcome.txt




当/是/它发布了吗?除了去

网站之外,我从未见过它......


- Pete

Is there a way to set the environment (specifically the PATH) for a
created process?

My current application was created using the correct path and I want
to "pass" this path to the newly created process which will be an
independent process of my current one.

Any ideas would be helpful.

I''d appreciate it if you could also email the reply to
es****@cerner.com in addition to posting it in this newsgroup if
possible.

Thanks
Elly Sokol
es****@cerner.com

解决方案

es****@jetbiz.com (Elly Sokol) writes:

Is there a way to set the environment (specifically the PATH) for a
created process?

My current application was created using the correct path and I want
to "pass" this path to the newly created process which will be an
independent process of my current one.

Any ideas would be helpful.

I''d appreciate it if you could also email the reply to
es****@cerner.com in addition to posting it in this newsgroup if
possible.

Thanks
Elly Sokol
es****@cerner.com



from MSDN/Platform SDK: DLLs, Processes, and Threads:

BOOL
CreateProcess(
LPCTSTR lpApplicationName
, LPTSTR lpCommandLine
, LPSECURITY_ATTRIBUTES lpProcessAttributes
, LPSECURITY_ATTRIBUTES lpThreadAttributes
, BOOL bInheritHandles
, DWORD dwCreationFlags
, LPVOID lpEnvironment
, LPCTSTR lpCurrentDirectory
, LPSTARTUPINFO lpStartupInfo
, LPPROCESS_INFORMATION lpProcessInformation
);

where lpEnvironment:
Pointer 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.

An environment block can contain either Unicode or ANSI characters.
If the environment block pointed to by lpEnvironment contains Unicode
characters, be sure that dwCreationFlags includes CREATE_UNICODE_ENVIRONMENT.

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.

--
Regards,
Misha Polatov
MetaCommunications Engineering


On Thu, 17 Jun 2004 16:51:57 -0500 in comp.lang.c++, Misha Polatov <mp******@meta-comm.com> wrote,

from MSDN/Platform SDK: DLLs, Processes, and Threads:



This comment is OFF TOPIC in comp.lang.c++. Please keep your answers to
standard portable C++ content and avoid proprietary API discussions.

See the welcome message posted twice per week in comp.lang.c++ or
available at http://www.slack.net/~shiva/welcome.txt


David Harmon wrote:
<snip>

See the welcome message posted twice per week in comp.lang.c++ or
available at http://www.slack.net/~shiva/welcome.txt



When /is/ it posted? I''ve never actually seen it except for going to the
site...

- Pete


这篇关于CreateProcess的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆