#include-once ; #FUNCTION# ============================================================================= ; Name...........: __SafeArray_Dummy_Obj ; @jugador ; ======================================================================================== Func __SafeArray_Dummy_Obj(ByRef $tInterface) Local $aMethods = [['Array_to_SafeArray', 'long', 'ptr;ptr;ptr*'], ['SafeArray_to_Array', 'long', 'ptr;ptr;ptr*']] Local $iUbound = UBound($aMethods) Local $tagIINTERFACE = 'int Size;ptr Object;ptr Methods[%i];int_ptr Callbacks[%i];' $tInterface = DllStructCreate(StringFormat($tagIINTERFACE, $iUbound, $iUbound)) Local $prefix = '__' Local $hCallback For $i = 0 To $iUbound - 1 $hCallback = DllCallbackRegister( $prefix & $aMethods[$i][0], $aMethods[$i][1], $aMethods[$i][2] ) DllStructSetData($tInterface, "Methods", DllCallbackGetPtr($hCallback), $i + 1) ; save callback pointer DllStructSetData($tInterface, "Callbacks", $hCallback, $i + 1) ; save callback handle Next DllStructSetData($tInterface, "Size", $iUbound) DllStructSetData($tInterface, "Object", DllStructGetPtr($tInterface, "Methods")) ; Interface method pointers Local $sInterface = 'Array_to_SafeArray hresult(struct*;ptr*);SafeArray_to_Array hresult(ptr;variant*);' Return ObjCreateInterface(DllStructGetPtr($tInterface, "Object"), '', $sInterface, False) EndFunc ; #FUNCTION# ============================================================================= ; Name...........: __Delete_SafeArray_ObjectFromTag ; ======================================================================================== Func __Delete_SafeArray_ObjectFromTag( ByRef $tInterface ) For $i = 1 To DllStructGetData( $tInterface, "Size" ) DllCallbackFree( DllStructGetData( $tInterface, "Callbacks", $i ) ) Next $tInterface = 0 EndFunc ; #FUNCTION# ============================================================================= ; Name...........: __Array_to_SafeArray ; @jugador ; ======================================================================================== Func __Array_to_SafeArray($pSelf, $p_SafeArray, $p_Ptr) Local $aRet = DllCall( "OleAut32.dll", "int", "SafeArrayCopy", "ptr", $p_SafeArray, "ptr*", 0 ) DllStructSetData( DllStructCreate('ptr', $p_Ptr), 1, $aRet[2] ) Return 0 #forceref $pSelf EndFunc ; #FUNCTION# ============================================================================= ; Name...........: __SafeArray_to_Array ; @jugador ; ======================================================================================== Func __SafeArray_to_Array($pSelf, $p_SafeArray, $p_D_Variant) Local $tvt = DllStructCreate( 'word vt;word r1;word r2;word r3;ptr data; ptr', $p_D_Variant ) DllStructSetData( $tvt, 1, 0x2000 + 0x000C ) DllStructSetData( $tvt, 'data', $p_SafeArray ) Return 0 #forceref $pSelf EndFunc