Imports System.Runtime.InteropServices
Imports System.Security.Permissions
Imports System.Reflection
Module Module1
Sub Main()
StartupNotepad()
Console.ReadLine()
End Sub
Sub StartupNotepad()
Dim retValue As Boolean
Dim pInfo As PROCESS_INFORMATION = New PROCESS_INFORMATION()
Dim sInfo As STARTUPINFO = New STARTUPINFO()
retValue = CreateProcess("c:\\windows\\system32\\NotePad.exe", Nothing, IntPtr.Zero, IntPtr.Zero, False, 0, IntPtr.Zero, Nothing, sInfo, pInfo)
End Sub
<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 'PROCESS_INFORMATION
<StructLayout(LayoutKind.Sequential)> _
Public Structure SECURITY_ATTRIBUTES
Public nLength As Integer
Public lpSecurityDescriptor As IntPtr
Public bInheritHandle As Boolean
End Structure 'SECURITY_ATTRIBUTES
<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 'STARTINFO
<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