Ejemplo 1 para DllStructCreate:
Código: Seleccionar todo
; Crea la estructura
; struct {
; int var1;
; unsigned char var2;
; unsigned int var3;
; char var4[128];
; }
;=========================================================
$str = "int var1;ubyte var2;uint var3;char var4[128]"
$a = DllStructCreate($str)
if @error Then
MsgBox(0,"","Error in DllStructCreate " & @error);
exit
endif
;=========================================================
; Establece datos en la estructura
; struct.var1 = -1;
; struct.var2 = 255;
; struct.var3 = INT_MAX; -1 will be typecasted to (unsigned int)
; strcpy(struct.var4,"Hola");
; struct.var4[0] = 'h';
;=========================================================
DllStructSetData($a,"var1",-1)
DllStructSetData($a,"var2",255)
DllStructSetData($a,"var3",-1)
DllStructSetData($a,"var4","Hola")
DllStructSetData($a,"var4",Asc("h"),1)
;=========================================================
; Mostrando la información de la estructura
;=========================================================
MsgBox(0,"DllStruct","Tamaño de estructura: " & DllStructGetSize($a) & @CRLF & _
"Puntero de estructura: " & DllStructGetPtr($a) & @CRLF & _
"Dato:" & @CRLF & _
DllStructGetData($a,1) & @CRLF & _
DllStructGetData($a,2) & @CRLF & _
DllStructGetData($a,3) & @CRLF & _
DllStructGetData($a,4))
msgbox(0,"prueba", $a)
;~ MsgBox(0,"DllStruct","Tamaño de estructura: " & DllStructGetSize($a) & "Puntero de estructura: " & DllStructGetPtr($a) & "Dato:" DllStructGetData($a,1) & @CRLF & _
;~ DllStructGetData($a,2) & @CRLF & _
;~ DllStructGetData($a,3) & @CRLF & _
;~ DllStructGetData($a,4))
;=========================================================
; Liberando memoria asignada a la estructura
;=========================================================
$a=0
Código: Seleccionar todo
$p = DllStructCreate("dword dwOSVersionInfoSize;dword dwMajorVersion;dword dwMinorVersion;dword dwBuildNumber;dword dwPlatformId;char szCSDVersion[128]")
;Pensar en esto como p->dwOSVersionInfoSize = sizeof(OSVERSIONINFO)
DllStructSetData($p, "dwOSVersionInfoSize", DllStructGetSize($p))
;haciendo el DllCall
$ret = DllCall("kernel32.dll","int","GetVersionEx","ptr",DllStructGetPtr($p))
if Not $ret[0] Then
MsgBox(0,"DllCall Error","DllCall Failed")
exit
EndIf
;obtener los valore de retorno
$major = DllStructGetData($p,"dwMajorVersion")
$minor = DllStructGetData($p,"dwMinorVersion")
$build = DllStructGetData($p,"dwBuildNumber")
$platform = DllStructGetData($p,"dwPlatformId")
$version = DllStructGetData($p,"szCSDVersion")
;liberando la estructura
$p =0
msgbox(0,"","Mayor: " & $major & @CRLF & _
"Menor: " & $minor & @CRLF & _
"Build: " & $build & @CRLF & _
"ID plataforma: " & $platform & @CRLF & _
"Versión: " & $version)
Muchas gracias de ante mano....
Saludos!