Is there a way to set the environment (specifically the PATH) for acreated process?My current application was created using the correct path and I wantto "pass" this path to the newly created process which will be anindependent 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 ifpossible.ThanksElly 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.comfrom MSDN/Platform SDK: DLLs, Processes, and Threads:BOOLCreateProcess(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-terminatedstrings. Each string is in the form:name=valueBecause 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 Unicodecharacters, 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 PolatovMetaCommunications EngineeringOn 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 tostandard portable C++ content and avoid proprietary API discussions.See the welcome message posted twice per week in comp.lang.c++ oravailable 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.txtWhen /is/ it posted? I''ve never actually seen it except for going to thesite...- Pete 这篇关于CreateProcess的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-22 15:41