vbHide benutzen, aber wo ?
23.09.2004 10:09:17
Dirk
ich hab hier ein Super-Programm gefunden, wonach ich lange gesucht habe.
Wenn jetzt die Datei geöffnet und ausgeführt wird, sieht man das DOS-Fenster.
Bei einem Shell-Aufruf hab ich immer vbHide eingeben können.
Aber bei dem Programm finde ich keine Möglickeit, das vbHide einzusetzten, ohne das eine Fehlermeldung kommt.
Kann mir jemand weiterhelfen ?
Das wäre echt super.
Vielen Dank im Voraus.
Viele Grüße von der Mosel.
Dirk
Option Explicit
'Declarationen für Message
Type RECT32
cl As Long
ct As Long
cr As Long
cb As Long
End Type
Declare
Function FindWindow32 Lib "User32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare
Function GetModuleHandle32 Lib "kernel32" Alias _
"GetModuleHandleA" (ByVal lpModuleName As Any) As Long
Declare
Function CreateWindowEx32 Lib "User32" Alias "CreateWindowExA" _
(ByVal dwExStyle As Long, ByVal lpClassName As String, _
ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, _
ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hWndParent As Long, ByVal hMenu As Any, ByVal hInstance As Long, _
lpParam As Any) As Long
Declare
Function ShowWindow32 Lib "User32" Alias "ShowWindow" _
(ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Declare
Sub SetWindowText32 Lib "User32" Alias "SetWindowTextA" _
(ByVal hWnd As Long, ByVal lpString As String)
Declare
Function DestroyWindow32 Lib "User32" Alias "DestroyWindow" _
(ByVal hWnd As Long) As Long
Const GWL_HINSTANCE = (-6)
Const WS_CAPTION = &HC00000
Const WS_BORDER = &H800000
Const WS_CHILD = &H40000000
Const WS_EX_TOPMOST = &H8
Const SW_SHOWNOACTIVATE = 4
Const SW_HIDE = 0
Const SS_CENTER = &H1&
Dim hWnd32 As Long
Dim hWndTxt32 As Long
'Deklarationen für ShellAndWait
Public 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
Public Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Public Declare
Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public 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
Public Declare
Function CloseHandle Lib "kernel32" (ByVal _
hObject As Long) As Long
Public Const NORMAL_PRIORITY_CLASS = &H20&
Public Const INFINITE = -1&
'Prozedur zum Aufrufen einer Anwendung
Public
Sub ShellAndWait(ByVal RunProg As String)
Dim proc As PROCESS_INFORMATION
Dim StartInf As STARTUPINFO
Dim RetVal As Long
Dim hWndP As Long
Dim hInstP As Long
Dim a As Long
'shelled Anwendung starten
RetVal = CreateProcessA(0&, RunProg, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, StartInf, proc)
'warten, bis shelled Anwendung geschlossen wurde
RetVal = WaitForSingleObject(proc.hProcess, INFINITE)
RetVal = CloseHandle(proc.hProcess)
End Sub
'Aufrufprozedur
Sub load()
ChDrive "C"
ChDir "C:\abteilungen\"
Call ShellAndWait("C:\abteilungen\test.exe")
End Sub