Hello!

Could someone help me to convert this code to VB .NET:
----
[DllImport("Coredll.dll", EntryPoint="CreateProcess")]
public unsafe extern static int CreateProcess(
string imageName,
string cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo *pi
);

public struct ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}

private unsafe static int StartProcess(string name, string parameters)
{
if (File.Exists(name))
{
ProcessInfo pi = new Win32API.ProcessInfo();
if (CreateProcess( name,
parameters,
IntPtr.Zero,
IntPtr.Zero,
0,
0,
IntPtr.Zero,
IntPtr.Zero,
null,
&pi
) != 0)
return 0;
else
{
int ret = Win32API.GetLastError();
return ret;
}
}
else
return 2; // 2 is file not found
}
----

Thanks in advance
Andreas
http://www.ab-archive.com

Re: Convert to VB .NET CF by Chris

Chris
Thu Nov 11 16:51:13 CST 2004

OpenNETCF.Process.Start(...)

--
<ctacke/>
www.OpenNETCF.org
Your CF searches start and end here


"Andreas Breitschopp" <a-breitschopp@ab-tools.de> wrote in message
news:%23AIVSwDyEHA.3808@tk2msftngp13.phx.gbl...
> Hello!
>
> Could someone help me to convert this code to VB .NET:
> ----
> [DllImport("Coredll.dll", EntryPoint="CreateProcess")]
> public unsafe extern static int CreateProcess(
> string imageName,
> string cmdLine,
> IntPtr lpProcessAttributes,
> IntPtr lpThreadAttributes,
> Int32 boolInheritHandles,
> Int32 dwCreationFlags,
> IntPtr lpEnvironment,
> IntPtr lpszCurrentDir,
> byte [] si,
> ProcessInfo *pi
> );
>
> public struct ProcessInfo
> {
> public IntPtr hProcess;
> public IntPtr hThread;
> public Int32 ProcessId;
> public Int32 ThreadId;
> }
>
> private unsafe static int StartProcess(string name, string parameters)
> {
> if (File.Exists(name))
> {
> ProcessInfo pi = new Win32API.ProcessInfo();
> if (CreateProcess( name,
> parameters,
> IntPtr.Zero,
> IntPtr.Zero,
> 0,
> 0,
> IntPtr.Zero,
> IntPtr.Zero,
> null,
> &pi
> ) != 0)
> return 0;
> else
> {
> int ret = Win32API.GetLastError();
> return ret;
> }
> }
> else
> return 2; // 2 is file not found
> }
> ----
>
> Thanks in advance
> Andreas
> http://www.ab-archive.com
>
>



RE: Convert to VB .NET CF by MohitGupta

MohitGupta
Thu Nov 11 17:21:01 CST 2004



"Andreas Breitschopp" wrote:

> Hello!
>
> Could someone help me to convert this code to VB .NET:
> ----
> [DllImport("Coredll.dll", EntryPoint="CreateProcess")]
> public unsafe extern static int CreateProcess(
> string imageName,
> string cmdLine,
> IntPtr lpProcessAttributes,
> IntPtr lpThreadAttributes,
> Int32 boolInheritHandles,
> Int32 dwCreationFlags,
> IntPtr lpEnvironment,
> IntPtr lpszCurrentDir,
> byte [] si,
> ProcessInfo *pi
> );
>

<dllImport("Coredll.dll", EntryPoint="CreateProcess")> _
Public Shared Function CreateProcess(ByVal imageName As String, _
ByVal cmdLine As
String, _
ByVal
lpProcessAttributes As IntPtr, _
ByVal
lpThreadAttributes As IntPtr, _
ByVal
boolInhertiHandles As Int32, _
ByVal dwCreationFlags
As Int32, _
ByVal lpEnvironment
As IntPtr, _
ByVal lpszCurrentDir
As IntPtr, _
ByVal si() As Byte, _
ByRef pi As
ProcessInfo) As Int32
End Function

> public struct ProcessInfo
> {
> public IntPtr hProcess;
> public IntPtr hThread;
> public Int32 ProcessId;
> public Int32 ThreadId;
> }

Public Structure ProcessInfo
Public hProcess As IntPtr
Public hThread As IntPtr
Public processId As Int32
Public threadID As Int32
End Structure

And I think you can convert StartProcess by yourself in VB .NET

> private unsafe static int StartProcess(string name, string parameters)
> {
> if (File.Exists(name))
> {
> ProcessInfo pi = new Win32API.ProcessInfo();
> if (CreateProcess( name,
> parameters,
> IntPtr.Zero,
> IntPtr.Zero,
> 0,
> 0,
> IntPtr.Zero,
> IntPtr.Zero,
> null,
> &pi
> ) != 0)
> return 0;
> else
> {
> int ret = Win32API.GetLastError();
> return ret;
> }
> }
> else
> return 2; // 2 is file not found
> }


Re: Convert to VB .NET CF by Andreas

Andreas
Fri Nov 12 17:34:04 CST 2004

Hello Mohit!

Thank you very much for your help!
It works now...

Andreas
http://www.ab-archive.com


"Mohit Gupta" <MohitGupta@discussions.microsoft.com> schrieb im Newsbeitrag
news:46ADA396-E770-4012-9E22-EF09AE258292@microsoft.com...
>
>
> "Andreas Breitschopp" wrote:
>
> > Hello!
> >
> > Could someone help me to convert this code to VB .NET:
> > ----
> > [DllImport("Coredll.dll", EntryPoint="CreateProcess")]
> > public unsafe extern static int CreateProcess(
> > string imageName,
> > string cmdLine,
> > IntPtr lpProcessAttributes,
> > IntPtr lpThreadAttributes,
> > Int32 boolInheritHandles,
> > Int32 dwCreationFlags,
> > IntPtr lpEnvironment,
> > IntPtr lpszCurrentDir,
> > byte [] si,
> > ProcessInfo *pi
> > );
> >
>
> <dllImport("Coredll.dll", EntryPoint="CreateProcess")> _
> Public Shared Function CreateProcess(ByVal imageName As String, _
> ByVal cmdLine As
> String, _
> ByVal
> lpProcessAttributes As IntPtr, _
> ByVal
> lpThreadAttributes As IntPtr, _
> ByVal
> boolInhertiHandles As Int32, _
> ByVal
dwCreationFlags
> As Int32, _
> ByVal lpEnvironment
> As IntPtr, _
> ByVal
lpszCurrentDir
> As IntPtr, _
> ByVal si() As Byte,
_
> ByRef pi As
> ProcessInfo) As Int32
> End Function
>
> > public struct ProcessInfo
> > {
> > public IntPtr hProcess;
> > public IntPtr hThread;
> > public Int32 ProcessId;
> > public Int32 ThreadId;
> > }
>
> Public Structure ProcessInfo
> Public hProcess As IntPtr
> Public hThread As IntPtr
> Public processId As Int32
> Public threadID As Int32
> End Structure
>
> And I think you can convert StartProcess by yourself in VB .NET
>
> > private unsafe static int StartProcess(string name, string parameters)
> > {
> > if (File.Exists(name))
> > {
> > ProcessInfo pi = new Win32API.ProcessInfo();
> > if (CreateProcess( name,
> > parameters,
> > IntPtr.Zero,
> > IntPtr.Zero,
> > 0,
> > 0,
> > IntPtr.Zero,
> > IntPtr.Zero,
> > null,
> > &pi
> > ) != 0)
> > return 0;
> > else
> > {
> > int ret = Win32API.GetLastError();
> > return ret;
> > }
> > }
> > else
> > return 2; // 2 is file not found
> > }
>