|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
API CreateProcess
I am using the Api Function CreateProcess but I have no Idea what to do with the "lpEnvironment As Any" Value
the simple version of this code is as follows: Option Explicit Private Const NORMAL_PRIORITY_CLASS As Long = &H20 Private Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadId As Long End Type Private Type STARTUPINFO cb As Long lpReserved As Long lpDesktop As Long lpTitle As Long dwX As Long dwY As Long dwXSize As Long dwYSize As Long dwXCountChars As Long dwYCountChars As Long dwFillAttribute As Long dwFlags As Long wShowWindow As Integer cbReserved2 As Integer lpReserved2 As Byte hStdInput As Long hStdOutput As Long hStdError As Long End Type Private Type SECURITY_ATTRIBUTES nLength As Long lpSecurityDescriptor As Long bInheritHandle As Long End Type Private Declare Function CreateProcess Lib "kernel32.dll" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long Sub Main() Dim spud As Long Dim SNfo As STARTUPINFO Dim PNfo As PROCESS_INFORMATION Dim SAtt As SECURITY_ATTRIBUTES With SNfo .cb = 1753357 ' .cbReserved2 = Null ' .dwFillAttribute ' .dwFlags .dwX = 100 ' .dwXCountChars .dwXSize = 100 .dwY = 100 ' .dwYCountChars .dwYSize = 100 ' .hStdError ' .hStdInput ' .hStdOutput ' .lpDesktop = Null ' .lpReserved = Null ' .lpReserved2 = Null .lpTitle = 1 .wShowWindow = 1 End With With SAtt .bInheritHandle = 1753357 .lpSecurityDescriptor = 1 .nLength = False End With spud = CreateProcess(vbNullString, "c:\one", SAtt, SAtt, False, NORMAL_PRIORITY_CLASS, 0, vbNullString, SNfo, PNfo) Debug.Print spud Debug.Print PNfo.hProcess Debug.Print PNfo.dwProcessId Debug.Print PNfo.dwThreadId Debug.Print PNfo.hThread End Sub ----------------------------------------------------- in the line spud = CreateProcess(vbNullString, "c:\one", SAtt, SAtt, False, NORMAL_PRIORITY_CLASS, 0, vbNullString, SNfo, PNfo) I set the value to 0, I have also tried Null (the default in c++) but that does not work eather.... HELP!?! |
|
#2
|
|||
|
|||
|
Using CreateProcess to Restart App
The App I'm working with is connected to vendor hardware through a vendor dll driver that needs restarting at the app level sometimes. How can a VB App restart itself? Can I use CreateProcess(....) followed immediately and lastly by a call to ExitProcess(...)?
Can this technique be used in general for App1 to start App2 and then die? |
|
#3
|
|||
|
|||
|
Possibly this page can help explain CreateProcess().
As far as your question Dan, I do not believe so. CreateProcess is used to open a process that you want to wait until it has finished before your application gains control again. You would probably want to check out ShellExecute() which there is a link to that in the link listed above. |
|
#4
|
|||
|
|||
|
THX
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > API CreateProcess |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|