Article View: borland.public.cppbuilder.nativeapi
Article #4776CreateProcess lpEnvironment
From: davidgorena
Date: Thu, 01 Dec 2005 04:03
Date: Thu, 01 Dec 2005 04:03
32 lines
2220 bytes
2220 bytes
Hi, I'm trying to create a block of Environment variables to use inside CreateProcess() function that I'm working with in a C# application, but it is certainly not working. If i pass NULL everything will work fine, and the process will inherit the parent's environment variables. BUT if I am trying to create a new block, it won't work. Im doing something like this: using System.Runtime.InteropServices; ... //Create a block of unicode bytes. I just create a stringbuilder with all evironment names and values, and return the Encoding.Default.GetBytes(stringbuilder.ToString()) value byte[] environmentBytes = EnvironmentBlock.ToByteArray(environment); environmentHandle = GCHandle.Alloc(environmentBytes, GCHandleType.Pinned); environmentPtr = environmentHandle.AddrOfPinnedObject(); Then I just pass environmentPtr to CreateProcess(...) But this won't work... if I create a simple process such as a command prompt, I can see that the environment was not set up. If I pass null, I can certainly see that it is being set. Any help?? Thanks, David
Technical Details
Message-ID:
<1133409797.397125.243460@g44g2000cwa.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!g44g2000cwa.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,c43a153254e0c93f,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!g44g2000cwa.googlegroups.com!not-for-mail From: davidgorena@gmail.com Newsgroups: borland.public.cppbuilder.nativeapi Subject: CreateProcess lpEnvironment Date: 30 Nov 2005 20:03:17 -0800 Organization: http://groups.google.com Lines: 33 Message-ID: <1133409797.397125.243460@g44g2000cwa.googlegroups.com> NNTP-Posting-Host: 131.107.0.103 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1133409802 28349 127.0.0.1 (1 Dec 2005 04:03:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 1 Dec 2005 04:03:22 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.0 RED-PRXY-05 Complaints-To: groups-abuse@google.com Injection-Info: g44g2000cwa.googlegroups.com; posting-host=131.107.0.103; posting-account=GBfZpQ0AAACfZoNHsLYhcmCvK6FOpoOO