Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old June 5th, 2003, 09:51 AM
peterself peterself is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 2 peterself User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old July 14th, 2003, 01:44 PM
gguoming gguoming is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 5 gguoming User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #3  
Old July 24th, 2003, 05:56 PM
smiams smiams is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 1 smiams User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old July 25th, 2003, 11:43 AM
peterself peterself is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 2 peterself User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > CreateProcess in kernel32 query...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway