How to use Win API CreateProcess() in VB? 
Author Message
 How to use Win API CreateProcess() in VB?

I want to run b.exe in a.exe using CreateProcess() not WinExec().
In the case using WinExec(),
WinExec "b.exe", SW_SHOW
then running b.exe.
I want to use CreateProcess() to get same result.
Anyone has any sample code?



Sun, 03 Dec 2000 03:00:00 GMT  
 How to use Win API CreateProcess() in VB?


Quote:

>I want to run b.exe in a.exe using CreateProcess() not WinExec().
>In the case using WinExec(),
>WinExec "b.exe", SW_SHOW
>then running b.exe.
>I want to use CreateProcess() to get same result.
>Anyone has any sample code?

Paste the following declarations into a .BAS module:

 Type STARTUPINFO
  cb As Long
  lpReserved As String
  lpDesktop As String
  lpTitle As String
  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 Long
  hStdInput As Long
  hStdOutput As Long
  hStdError As Long
 End Type

 Type PROCESS_INFORMATION
  hProcess As Long
  hThread As Long
  dwProcessID As Long
  dwThreadID As Long
 End Type

Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
  hHandle As Long, ByVal dwMilliseconds As Long) As Long

Declare Function CreateProcessA Lib "kernel32" (ByVal _
  lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
  lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
  ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
  ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
  lpStartupInfo As STARTUPINFO, lpProcessInformation As _
  PROCESS_INFORMATION) As Long

Code to start the app:

    Dim proc As PROCESS_INFORMATION
    Dim start As STARTUPINFO
    Dim lRet As Long

    start.cb = Len(start)
    lRet = CreateProcessA(0&, "b.exe", 0&, 0&, 1&, _
        NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)

Lee Weiner
weiner AT fuse DOT net



Sun, 03 Dec 2000 03:00:00 GMT  
 How to use Win API CreateProcess() in VB?

Dear Lee Weiner,

Thank you for your kind help.
I solve the problem.  Your code was great help.

J.H.Yoo /Taewon Information System Co., Ltd.



Mon, 04 Dec 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to use Win API CreateProcess() in VB?

2. WIN 2k API vs WIN 98/WIN NT API - Help needed

3. Using CreateProcess API

4. Help using API CreateProcess ?

5. Help CreateProcess API using BCP for SQL 6.5

6. Modify VB Process Priority using Win API calls

7. Win API Call not working in vb.net app distributed to WIn 98

8. CreateProcess won't work

9. CreateProcess won't work

10. VB6, CreateProcess/Shell causes RT Error 5 when switching to Win2000 from Win 98

11. Reproducing SendKeys function using WIN api....

12. Using the Win API for serial comm

 

 
Powered by phpBB® Forum Software