Page 1 sur 1

[..] Erreur "Paramétres incorects" sur CreateProcessW (DLL)

Posté : ven. 01 janv. 2010 06:15
par HeartKey
Tout d'abord, Bonne année :lol:,
Donc voici mon problème :
J'essaie depuis bien longtemps d'appeler la fonction "CreateProcessW" dans kernel32.dll afin de démarrer un nouveaux programme dans un autre bureau (desktop), mais la fonction en question n'aime pas du tout ma structure :(.
Voici le code :
► Afficher le texteCode
Dans l'espoir que quelqu'un puisse m'apporter de l'aide, car je désespère de pouvoir y arriver un jour :cry:.
PS: J'ai deja éplucher le forum anglais de fond en comble sur tout ce qui concerne le changement de bureau, il n'ont -presque- rien, mais rien qui me soit utile...

Re: [..] Erreur "Paramétres incorects" sur CreateProcessW (DLL)

Posté : ven. 01 janv. 2010 14:14
par Tlem

Re: [..] Erreur "Paramétres incorects" sur CreateProcessW (DLL)

Posté : ven. 01 janv. 2010 21:52
par HeartKey
Oui je l'ait ait vu et examiner mais aucun de ces code n'utilise ce que je cherche :cry:, c'est a dire le support des multiple desktop qui existe déjà d'origine dans Windows (a partir de Windows 2000). Merci quand même :).

Re: [..] Erreur "Paramétres incorects" sur CreateProcessW (DLL)

Posté : ven. 01 janv. 2010 22:02
par timmalos
Je pense qu'il va vous falloir faire votre requete sur le forum anglais. Tres peu de personnes ici en savent suffisament sur les structures pour arriver a trouver l'erreur.
Je savais meme pas qu'on pouvait faire du multi desktop sur Windows...

Re: [..] Erreur "Paramétres incorects" sur CreateProcessW (DLL)

Posté : ven. 01 janv. 2010 22:05
par HeartKey
Bien... malheureusement je comprend l'anglais mais pour ce qui en est de l'écrire...:lol:, Et je confirme que c'est bien la structure qui est incorrect, mais je n'ait toujours pas trouver pourquoi.

Re: [..] Erreur "Paramétres incorects" sur CreateProcessW (DLL)

Posté : ven. 01 janv. 2010 22:15
par timmalos
Hi guys, and firstly, Happy New Year :lol: ,
So here's my problem:
I'm trying since long to call the "CreateProcessW" kernel32.dll in order to start a new program in another desktop location , but the function in question doesn't like my structure :( . .
Here's the code:

Code : Tout sélectionner

#include <Winapi.au3>

Desk_StartProgram("c:\windows\explorer.exe", "c:\windows\", "Test") ;"Test" is the name given to the desktop in which the program must be displayed, of course I created the named desktop  before. 

Func Desk_StartProgram($hPath, $hCurrentdir, $hDesktop)

        Local $tSTARTUPINFO = DllStructCreate("dword  cbSize;" & _
            "ptr Reserved;" & _
            "ptr Title;" & _
            "str Desktop;" & _ ; When the "str" of this line is replaced by "ptr" the program is running properly, however it remains in the current desktop (default) 
            "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()) ;returns "The operation was successful." 
            DllStructSetData($tSTARTUPINFO, "Desktop", $hDesktop)
            MsgBox(0,"",_WinAPI_GetLastErrorMessage()) ; returns "The operation was successful." 

    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, _ ; deliberately pre-hung 
            "ptr", 0, _
            "wstr", $hCurrentdir, _ ; Curent Dir
            "ptr", DllStructGetPtr($tSTARTUPINFO), _
            "ptr", DllStructGetPtr($tPROCESS_INFORMATION))

    If @error Or Not $aCall[0] Then
        MsgBox(0,"",_WinAPI_GetLastErrorMessage()) ; returns "The parameter is 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
Hoping someone can give me help, because I despair of being able to succeed one day :cry: ...

Cheers, Heartkey
:arrow: Merci Google trad

Re: [..] Erreur "Paramétres incorects" sur CreateProcessW (DLL)

Posté : ven. 01 janv. 2010 22:35
par HeartKey
:lol:, Merci ! :wink: