На VB 6 все работает, а вот на vb net не хочет... точнее функция возращает 1, а новый процесс не запускается.
Код модуля:
- Код: Выделить всё
Public Const NORMAL_PRIORITY_CLASS As Short = &H20S
Public Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, ByRef lpProcessAttributes As SECURITY_ATTRIBUTES, ByRef lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Integer, ByVal dwCreationFlags As Integer, ByRef lpEnvironment As String, ByVal lpCurrentDriectory As String, ByRef lpStartupInfo As STARTUPINFO, ByRef lpProcessInformation As PROCESS_INFORMATION) As Integer
Public Structure SECURITY_ATTRIBUTES
Dim nLength As Integer
Dim lpSecurityDescriptor As Integer
Dim bInheritHandle As Integer
End Structure
Public Structure PROCESS_INFORMATION
Dim hProcess As Integer
Dim hThread As Integer
Dim dwProcessId As Integer
Dim dwThreadId As Integer
End Structure
Public Structure STARTUPINFO
Dim cb As Integer
Dim lpReserved As String
Dim lpDesktop As String
Dim lpTitle As String
Dim dwX As Integer
Dim dwY As Integer
Dim dwXSize As Integer
Dim dwYSize As Integer
Dim dwXCountChars As Integer
Dim dwYCountChars As Integer
Dim dwFillAttribute As Integer
Dim dwFlags As Integer
Dim wShowWindow As Short
Dim cbReserved2 As Short
Dim lpReserved2 As Integer
Dim hStdInput As Integer
Dim hStdOutput As Integer
Dim hStdError As Integer
End Structure
Код кнопки:
Dim pInfo As PROCESS_INFORMATION
Dim d As Модуль1.SECURITY_ATTRIBUTES
Dim sInfo As STARTUPINFO
Dim sNull As String
Dim lSuccess As Integer
Dim lRet As Integer
sInfo.cb = Len(sInfo)
lSuccess = CreateProcess(Nothing, "regedit.exe", d, d, 0, NORMAL_PRIORITY_CLASS, 0, Nothing, sInfo, pInfo)
MsgBox(lSuccess)