Error in your CreateProcess page

Announcements and discussion for PInvoke

Error in your CreateProcess page

Postby Anadrol » Fri Jun 18, 2010 1:09 am

Hello,

There are errors in this page:
http://www.pinvoke.net/default.aspx/ker ... ocess.html

It should be:

[DllImport("kernel32.dll")]
static extern bool CreateProcess(
string lpApplicationName,
string lpCommandLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
bool bInheritHandles,
uint dwCreationFlags,
IntPtr lpEnvironment,
string lpCurrentDirectory,
[In] ref STARTUPINFO lpStartupInfo,
out PROCESS_INFORMATION lpProcessInformation);

And not:

[DllImport("kernel32.dll")]
static extern bool CreateProcess(
string lpApplicationName,
string lpCommandLine,
ref SECURITY_ATTRIBUTES lpProcessAttributes,
ref SECURITY_ATTRIBUTES lpThreadAttributes,
bool bInheritHandles,
uint dwCreationFlags,
IntPtr lpEnvironment,
string lpCurrentDirectory,
[In] ref STARTUPINFO lpStartupInfo,
out PROCESS_INFORMATION lpProcessInformation);

Errors in lines 5 and 6.


It should be:

//Open Notepad
retValue = CreateProcess(
Application,
CommandLine,
IntPtr.Zero,
IntPtr.Zero,
false,
NORMAL_PRIORITY_CLASS,
IntPtr.Zero,
null,
ref sInfo,
out pInfo);

And not :

//Open Notepad
retValue = CreateProcess(
Application,
CommandLine,
ref pSec,
ref tSec,
false,
NORMAL_PRIORITY_CLASS,
IntPtr.Zero,
null,
ref sInfo,
out pInfo);

Error in lines 5 and 6 as well.

Without these changes the target application doesn't launch.
Hope that you will correct the page.



Also in the SECURITY_ATTRIBUTES

It may be better to use:
public IntPtr lpSecurityDescriptor;

instead of:

public unsafe byte* lpSecurityDescriptor;

This way you don't have to compile with the Unsafe option.



More info here:
http://blogs.msdn.com/b/thottams/archiv ... 96013.aspx
Anadrol
 
Posts: 1
Joined: Fri Jun 18, 2010 1:02 am

Postby Paul.Martin » Fri Jun 18, 2010 5:01 pm

Thank you very much for the corrections.

PInvoke.Net is a wiki site so you are free to correct and add any information on the site. On each of the pages there is a "Edit this page" link (on the right hand menu), you don't need to register or anything like that to do the update.
Paul.Martin
 
Posts: 83
Joined: Wed Feb 03, 2010 11:20 am
Location: Cambridgeshire


Return to PInvoke.Net

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests

cron