I am revising this answer because there is a method that does not require bringing in old VB6 libraies.
Your time may well be better spent learning .NET System.IO.Pipes.
System.IO.Pipes Namespace[
^]
There is an example here:
NamedPipeClientStream Class[
^]
If you insist on attempting to force the method you have now, you may experiment with the SECURITY_ATTRIBUTES member types. You are likely getting hung on the
lpSecurityDescriptor
attribute.
I have seen C++ code that sets all the attributes to a long type. I've also read a suggestion to use the
variant
type as well. (The only time I use
variant
is to find which way VB.NET will cast a type to determine which type I could use and change it to that type if it works.)
A C++ version sets the sa attributes thus: (Converted to VB)
With sa
.nLength = Len(sa)
.bInheritHandle = True
.lpSecurityDescriptor = vbNull
End With
Good luck.
You need to create the structures yourself.
Try adding a module to your project and place the following code into it.
Imports System.Runtime.InteropServices
Imports System.Security.Permissions
Imports System.Reflection
Module Module1
<StructLayout(LayoutKind.Sequential)> _
Public Structure PROCESS_INFORMATION
Public hProcess As IntPtr
Public hThread As IntPtr
Public dwProcessID As UInteger
Public dwThreadID As UInteger
End Structure
<StructLayout(LayoutKind.Sequential)> _
Public Structure SECURITY_ATTRIBUTES
Public nLength As Integer
Public lpSecurityDescriptor As IntPtr
Public bInheritHandle As Boolean
End Structure
<StructLayout(LayoutKind.Sequential)> _
Public Structure STARTUPINFO
Public cb As UInteger
Public lpReserved As String
Public lpDesktop As String
Public lpTitle As String
Public dwX As UInteger
Public dwY As UInteger
Public dwXSize As UInteger
Public dwYSize As UInteger
Public dwXCountChars As UInteger
Public dwYCountChars As UInteger
Public dwFillAttribute As UInteger
Public dwFlags As UInteger
Public wShowWindow As Short
Public cbReserved2 As Short
Public lpReserved2 As IntPtr
Public hStdInput As IntPtr
Public hStdOutput As IntPtr
Public hStdError As IntPtr
End Structure
<DllImport("kernel32.dll")> _
Function CreateProcess( _
ByVal lpApplicationName As String, _
ByVal lpCommandLine As String, _
ByVal lpProcessAttributes As IntPtr, _
ByVal lpThreadAttributes As IntPtr, _
ByVal bInheritHandles As Boolean, _
ByVal dwCreationFlags As UInteger, _
ByVal lpEnvironment As IntPtr, _
ByVal lpCurrentDirectory As String, _
ByRef lpStartupInfo As STARTUPINFO, _
ByRef lpProcessInformation As PROCESS_INFORMATION) As Boolean
End Function
End Module
I assume you have all the API function calls generted for your code above.
Good luck.