Hallo Comunity,
wie sich der Überschrift entnehmen lässt habe ich ein Problemchen mit der Übergabe einer DLL-Struct an ein anderes, kompiliertes Script.
Ich hatte bereits mit DLLStructs gearbeitet, und innerhalb des ersten Scriptes funktioniert es auch.
Erstmal den Code des Start-Scriptes
ScriptA
Code
;~
;~ Sender Script
#RequireAdmin
Local _
$sFile = @ScriptDir & "\ScriptB.exe", _
$aString = "TestTestTest", _
$iMode = 1, _
$iMaximum = 0, _
$str = "char sString["&StringLen($aString)&"];int iMode;int iMaximum", _
$hStruct = DllStructCreate($str)
DllStructSetData($hStruct, "sString", $aString)
DllStructSetData($hStruct, "iMode", $iMode)
DllStructSetData($hStruct, "iMaximum", $iMaximum)
;~ $aHandle = ShellExecute($sFile, DllStructGetPtr($hStruct) & "|" & StringLen($aString), @SW_HIDE) ; ScriptB.exe starten, Struct-Pointer und String-Size übergeben
$sString = DllStructGetData($hStruct, "sString")
$iMode = DllStructGetData($hStruct, "iMode")
$iMaximum = DllStructGetData($hStruct, "iMaximum")
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$sString' & @lf & @lf & 'Return:' & @lf & $sString) ;### Debug MSGBOX
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$iMode' & @lf & @lf & 'Return:' & @lf & $iMode) ;### Debug MSGBOX
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$iMaximum' & @lf & @lf & 'Return:' & @lf & $iMaximum) ;### Debug MSGBOX
$aHandle = ShellExecute($sFile, DllStructGetPtr($hStruct) & "|" & StringLen($aString), @SW_HIDE) ; ScriptB.exe starten, Struct-Pointer und String-Size übergeben
Do
Sleep(2)
Until not ProcessExists("ScriptB.exe")
Alles anzeigen
ScriptA erstellt die Struct und Startet das kompilierte ScriptB:
ScriptB
Code
;~
;~ Empfänger Script - Kompilieren!
if @Compiled Then
if $CmdLine[0] >= 1 Then
Dim _
$Temp = StringSplit($CmdLine[1], "|", 1), _ ; Pointer & Size werden empfangen
$hDll = $Temp[1], _
$iSize = $Temp[2]
Dim _
$str = "char sString["&$iSize&"];int iMode;int iMaximum", _ ; Struct definieren, die Size für den $sString
$hData = DllStructCreate($str, $hDll), _ ; Struct erstellen und Daten aus dem Pointer verwenden
$sString = DllStructGetData($hData, "sString"), _
$iMode = DllStructGetData($hData, "iMode"), _
$iMaximum = DllStructGetData($hData, "iMaximum")
MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @CRLF & '$sString' & @CRLF & @CRLF & 'Return:' & @CRLF & $sString) ;### Debug MSGBOX
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$iMode' & @lf & @lf & 'Return:' & @lf & $iMode) ;### Debug MSGBOX
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$iMaximum' & @lf & @lf & 'Return:' & @lf & $iMaximum) ;### Debug MSGBOX
EndIf
EndIf
Alles anzeigen
Entweder gibt ScriptB total falsche Werte aus, oder es stürzt sofort ab... Nur ist mir nicht ganz klar wieso?!?
Anscheinend übergebe ich die Struct falsch, oder ich baue diese in ScriptB falsch auf.
Momentan weiß ich mir nichtmehr zu helfen... Ich hoffe Ihr könnt mir auf die Sprünge helfen
Grüsse!