Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide a CreateProcess

Status
Not open for further replies.

DaTommyboY

Programmer
Feb 10, 2004
40
NL
Hello people,

I have piece of code whith runs batchfiles. Every batchfile is on my screen like SW_NNORMAL, but i like to have something like SW_HIDE.
I have followed treat 222-859655 by foot, but it seems that I don't get it to work???

Code:
Option Explicit

Private 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

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

Public Type PROCESS_INFORMATION_EXT
   hProcess As Long
   hThread As Long
   hwnd As Long
   dwProcessID As Long
   dwThreadID As Long
End Type

'SW_HIDE = 0
'SW_NORMAL = 1
'SW_MAXIMIZE = 3
'SW_MINIMIZE = 6
Private Const STARTF_USESHOWNWINDOW = &H1&
Private Const SW_HIDE = 3
Private Const NORMAL_PRIORITY_CLASS = &H20

Private Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As String, 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 String, siStartup As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
         
Private Const INFINITE = &HFFFF
Private Declare Function WaitForInputIdle Lib "user32" (ByVal hProcess As Long, ByVal dwMilliseconds As Long) As Long


Public Function StartProcess(strProgram As String, hStdIn As Long, hStdOut As Long, hStdErr As Long) As Long 'PROCESS_INFORMATION_EXT
    Dim piProcess As PROCESS_INFORMATION
    Dim siStartup As STARTUPINFO
    Dim lResult As Long

    siStartup.hStdInput = hStdIn
    siStartup.hStdOutput = hStdOut
    siStartup.hStdError = hStdErr
    
    siStartup.dwFlags = STARTF_USESHOWNWINDOW 'Necessary for wShowWindow to work
    siStartup.wShowWindow = SW_HIDE 'Hide window
    
    lResult = CreateProcessA(vbNullString, strProgram, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, vbNullString, siStartup, piProcess)
    
    WaitForInputIdle piProcess.hProcess, INFINITE 'Let it initialise properly before continuing
    StartProcess = lResult
End Function

I hope somebody can help me to the next stage!!
Thanks so fare.

Tom
 
If I understand your questions correctly all you should have to do is change the line.
Private Const SW_HIDE = 3
to
Private Const SW_HIDE = 0

Try it and see what happens

The hardest questions always have the easiest answers.
 
Hello jtmach,

Sorry thats my mistake, I already tryed that, should have mentioned that!!
And that is also my problem, because the dosprompt is not responding to that. I think I did something not exactly correct but can not find what!!

Hope you, ore somebody else can provide me another solution or a push in the right direction.

Thanks anyways,

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top