Code : Tout sélectionner
#include <Winapi.au3>
Desk_StartProgram("c:\windows\explorer.exe", "c:\windows\", "Test") ; "Test" est le nom attribuer au bureau dans lequel le programme doit être afficher, évidement j'ai crée le bureau en question au préalable.
Func Desk_StartProgram($hPath, $hCurrentdir, $hDesktop)
Local $tSTARTUPINFO = DllStructCreate("dword cbSize;" & _
"ptr Reserved;" & _
"ptr Title;" & _
"str Desktop;" & _ ; Lorsque le "str" de cette ligne est remplacer par "ptr" le programme est lancer correctement cependant il reste dans le bureau courant (par défaut)
"dword X;" & _
"dword Y;" & _
"dword XSize;" & _
"dword YSize;" & _
"dword XCountChars;" & _
"dword YCountChars;" & _
"dword FillAttribute;" & _
"dword Flags;" & _
"ushort ShowWindow;" & _
"ushort Reserved2;" & _
"ptr Reserved2;" & _
"ptr hStdInput;" & _
"ptr hStdOutput;" & _
"ptr hStdError")
MsgBox(0,"",_WinAPI_GetLastErrorMessage()) ; Me renvoie "L’opération a réussi."
DllStructSetData($tSTARTUPINFO, "Desktop", $hDesktop)
MsgBox(0,"",_WinAPI_GetLastErrorMessage()) ; Me renvoie "L’opération a réussi."
Local $tPROCESS_INFORMATION = DllStructCreate("ptr Process;" & _
"ptr Thread;" & _
"dword ProcessId;" & _
"dword ThreadId")
$aCall = DllCall("kernel32.dll", "int", "CreateProcessW", _
"wstr", $hPath, _
"wstr", "", _ ; CMDLINE
"ptr", 0, _
"ptr", 0, _
"int", 0, _
"dword", 4, _ ; Volontairement pré-suspendu
"ptr", 0, _
"wstr", $hCurrentdir, _ ; Curent Dir
"ptr", DllStructGetPtr($tSTARTUPINFO), _
"ptr", DllStructGetPtr($tPROCESS_INFORMATION))
If @error Or Not $aCall[0] Then
MsgBox(0,"",_WinAPI_GetLastErrorMessage()) ; Me renvoie "Paramètre incorrect."
Return SetError(1, 0, 0)
EndIf
Local $hThread = DllStructGetData($tPROCESS_INFORMATION, "Thread")
DllCall("kernel32.dll", "int", "ResumeThread", "ptr", $hThread)
Return DllStructGetData($tPROCESS_INFORMATION, "ProcessId")
EndFunc