Aide et conseils concernant AutoIt et ses outils.
17Cx
Niveau 1
Messages : 11 Enregistré le : mer. 20 janv. 2010 13:05
Status :
Hors ligne
#1
Message
par 17Cx » jeu. 21 oct. 2010 22:17
Hello tout le monde,
J'ai un petit soucis avec l'utilisation de la fonction "MsiEnumProducts" de msi.dll, en effet en exécutant le code ci dessous, le script plante lamentablement " Autoit v3 script à cesser de fonctionner" .
Il y a visiblement un soucis lors de l'appel de DllCall(), mais lequel ? je pense avoir bien renseigné la fonction.
http://msdn.microsoft.com/en-us/library ... 85%29.aspx ==> fonction
Code:
Code : Tout sélectionner
; // ======================== Ouverture msi.dll
Local $msi
$msi = DllOpen("Msi.dll")
; // ========================
Local $buffer = DllStructCreate("char buffer[39]")
Local $pointer = DllCall($msi, "UINT", "MsiEnumProducts", _
"DWORD", 0 _ ; __in
)
DllStructSetData($buffer, "buffer", DllStructGetPtr($pointer[0]))
MsgBox(0, "", DllStructGetData($buffer, "buffer"))
; // ======================== Fermeture msi.dll
DllClose($msi)
; // ========================
Ps: Je tiens à passer par cette fonction au lieu d'un objet COM par exemple
Merci
++
Modifié en dernier par
17Cx le jeu. 21 oct. 2010 22:41, modifié 1 fois.
Tlem
Site Admin
Messages : 11824 Enregistré le : ven. 20 juil. 2007 21:00
Localisation : Bordeaux
Status :
Hors ligne
#2
Message
par Tlem » jeu. 21 oct. 2010 22:36
Votre réponse ce trouve ici :
http://www.autoitscript.com/forum/index ... t&p=223774
► Afficher le texte
Code : Tout sélectionner
#Include <String.au3>
#include <Array.au3>
Global $Debugit = 0
Global $ERROR_BAD_CONFIGURATION = 1610
Global $ERROR_INVALID_PARAMETER = 87
Global $ERROR_NO_MORE_ITEMS = 259
Global $ERROR_NOT_ENOUGH_MEMORY = 8
Global $ERROR_SUCCESS = 0
$dll = DllOpen("msi.dll")
Global $ret, $aApps[1][2], $x = 0
While 1
_GetMSIInstalledApps($dll, $x, $aApps)
If @error Then ExitLoop
$x += 1
WEnd
Switch @error
Case $ERROR_BAD_CONFIGURATION
ConsoleWrite("ERROR_BAD_CONFIGURATION" & @LF)
Exit
Case $ERROR_INVALID_PARAMETER
ConsoleWrite("$ERROR_INVALID_PARAMETER" & @LF)
Exit
Case $ERROR_NO_MORE_ITEMS
ConsoleWrite("$ERROR_NO_MORE_ITEMS" & @LF)
Case $ERROR_NOT_ENOUGH_MEMORY
ConsoleWrite("$ERROR_NOT_ENOUGH_MEMORY" & @LF)
Exit
EndSwitch
$fileH = FileOpen(@ScriptDir & "\InstalledApps.txt", 2)
For $j = 1 To $aApps[0][0]
FileWriteLine($fileH, $aApps[$j][0] & @TAB & $aApps[$j][1])
Next
; ==============
; FUNCTIONS
; ==============
Func _GetMSIInstalledApps(ByRef $dll, ByRef $i_index, ByRef $aApps)
; Enumerate MSIs
$ret = DllCall($dll, "int", "MsiEnumProducts", "int", $i_index, "str", "")
If $ret[0] <> 0 Then Return SetError($ret[0], $ret[0], $ret[0])
ReDim $aApps[UBound($aApps) + 1][2]
$aApps[0][0] = UBound($aApps) - 1
$aApps[UBound($aApps) - 1][0] = RegRead('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' & $ret[2], 'DisplayName')
$aApps[UBound($aApps) - 1][1] = $ret[2]
If $Debugit Then _DebugPrint("Debug: DllCall Return:" & @LF & "--> " & $ret[0] & @LF & "--> " & $ret[1] & @LF & "--> " & $ret[2])
EndFunc ;==>_GetMSIInstalledApps
Func OnAutoItExit()
DllClose($dll)
EndFunc ;==>OnAutoItExit
Func _DebugPrint($s_text)
$s_text = StringReplace($s_text, @LF, @LF & "-->")
ConsoleWrite("!===========================================================" & @LF & _
"!===========================================================" & @LF & _
"-->" & $s_text & @LF & _
"!===========================================================" & @LF)
EndFunc ;==>_DebugPrint
17Cx
Niveau 1
Messages : 11 Enregistré le : mer. 20 janv. 2010 13:05
Status :
Hors ligne
#3
Message
par 17Cx » jeu. 21 oct. 2010 22:41
Re,
Nickel, j'aurais dû mieux chercher --'
Merci !
+++