|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
CreateProcess in kernel32 query...
Hi,
I want to use CreateProcess in kernel32 in place of the usual VB shell command. I am opening up a multi-argument commandline app and want to hide the DOS shell (have been using vbHide in the shell command) but can't see what parameter sets the window state in CreateProcess. Everything works fine except the DOS box is Normal size with Focus - I want Hidden - no focus. My existing working code is: sInfo.cb = Len(sInfo) lngReply = CreateProcess(sNull, CommandLine, ByVal 0&, ByVal 0&, 1&, NORMAL_PRIORITY_CLASS, ByVal 0&, sNull, sInfo, pInfo) Any help or info please???!!! Thanks...Peter |
|
#2
|
|||
|
|||
|
Hi peter,
I just saw your question. It's easy. You to change the Shell() function parameter from vbNormalFocus to vbHide. You go the MSDN library to see the detail info about Shell() function. //Constant Value Description --vbHide 0 Window is hidden and focus is passed to the hidden window. --vbNormalFocus 1 Window has focus and is restored to its original size and position. --vbMinimizedFocus 2 Window is displayed as an icon with focus. --vbMaximizedFocus 3 Window is maximized with focus. --vbNormalNoFocus 4 Window is restored to its most recent size and position. The currently active window remains active. vbMinimizedNoFocus 6 Window is displayed as an icon. The currently active window remains active. I test the code, it will hide the DOS Prompt Window. Hope it helps. Example: Public Sub runShell() ' Define API return variables Dim iTask As Long, ret As Long, pHandle As Long ' Start DOS command and retrieve handle of open process 'iTask = Shell("c:\DavidPrg\MoeReport\moerun.bat", vbNormalFocus) iTask = Shell("Test.bat", vbHide) pHandle = OpenProcess(SYNCHRONIZE, False, iTask) ' Wait until DOS command has completed ret = WaitForSingleObject(pHandle, INFINITE) ret = CloseHandle(pHandle) End Sub Private Sub Command1_Click() Call runShell End Sub Jim Guo |
|
#3
|
|||
|
|||
|
CreateProcess - Hide window
'I guess you need the sInfo.dwFlags to force CreateProcess
'to use the wShowWindow command 'And then of course you have to tell the window how to start up 'by specifying sInfo.wShowWindow = SW_Hide 'CODE Public Const SW_HIDE& = 0 Public Const STARTF_USESHOWWINDOW& = &H1 Public Const NORMAL_PRIORITY_CLASS = &H20& Public sNull As String Private Function Launch(p_Path) as Long Dim sInfo As STARTUPINFO sInfo.cb = Len(sInfo) sInfo.dwFlags = STARTF_USESHOWWINDOW sInfo.wShowWindow = SW_HIDE Launch = CreateProcess(sNull, p_Path, ByVal 0&, _ ByVal 0&, 1&, NORMAL_PRIORITY_CLASS, ByVal 0&, sNull, sInfo, pInfo) End Function 'End Code Let me know if this helps |
|
#4
|
|||
|
|||
|
Many thanks - looks like that's what I need. I'm away on vacation now but will look at it when I return - thanks again!
Pete |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > CreateProcess in kernel32 query... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|