Am 20.11.2018 um 21:24 schrieb Wendelin Uez:
> Ich will bloß aus meiner Anwendung heraus den Explorer starten und
> dessen Fenster in Position und Größe festlegen. Dazu brauche ich sein hWnd.
Nee, brauchst Du nicht.
Wer zwingt Dich, den Explorer mit Shell zu starten?
Mit CreateProcess ist es gar kein Problem ein Anwendung
an der gewünschten Position zu starten. Einfach die
Werte in STARTUPINFO eintragen und fertig.
(Aber ein Fensterhandle haste dann immer noch nicht...)
Ungetestet:
Private Const NORMAL_PRIORITY_CLASS = &H20
Private Const STARTF_USESIZE = &H2
Private Const STARTF_USEPOSITION = &H4
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
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 Declare Function CreateProcess Lib "kernel32" Alias
"CreateProcessA" (ByVal lpApplicationName&, ByVal lpCommandLine$, ByVal
lpProcessAttributes&, ByVal lpThreadAttributes&, ByVal bInheritHandles&,
ByVal dwCreationFlags&, ByVal lpEnvironment&, ByVal lpCurrentDirectory&,
lpStartupInfo As STARTUPINFO, lpProcessInformation As
PROCESS_INFORMATION) As Long
Sub Test (Byval szAllplication as string, Byval szCommandline as string)
Dim udtProcessInfo As PROCESS_INFORMATION
Dim udtStartupInfo As STARTUPINFO
Dim lResult As Long
Dim lFlags as long
udtStartupInfo.cb = Len(udtStartupInfo)
udtStartupInfo.dwX = 100
udtStartupInfo.dwY = 100
udtStartupInfo.dwXSize = 800
udtStartupInfo.dwYSize =600
lFlags = NORMAL_PRIORITY_CLASS Or STARTF_USEPOSITION or STARTF_USESIZE
lResult = CreateProcess(0&, szAllplication & " " & szCommandline, 0&,
0&, 0&, lFlags, 0&, 0&, udtStartupInfo, udtProcessInfo)
end Sub