返回數(shù)據(jù)結(jié)構(gòu)元素的數(shù)據(jù).
DllStructGetData ( 結(jié)構(gòu), 元素 [, 索引] )
結(jié)構(gòu) | 由 DllStructCreate 返回的數(shù)據(jù)結(jié)構(gòu). |
元素 | 要訪問的數(shù)據(jù)結(jié)構(gòu)元素, 起始于 1 或由 DllStructCreate 函數(shù)定義的元素名. |
索引 | [可選參數(shù)] 對于數(shù)組元素,需指定基于 1 的元素索引. 如果省略或 Default(默認(rèn))關(guān)鍵字, 則檢索整個數(shù)組 (用于快速檢索字符串). 不用于非數(shù)組元素 |
成功: | 返回數(shù)據(jù)結(jié)構(gòu)的元素數(shù)據(jù). |
失敗: | 返回 0. |
@Error: | 0 = 無錯誤. |
1 = DllStructCreate 函數(shù)返回的數(shù)據(jù)結(jié)構(gòu)不正確. | |
2 = 元素值超出范圍. | |
3 = 索引值在數(shù)據(jù)結(jié)構(gòu)外面. | |
4 = 元素的數(shù)據(jù)類型未知 | |
5 = 索引 <= 0. |
Local $p
= DllStructCreate("dword dwOSVersionInfoSize;dword dwMajorVersion;dword
dwMinorVersion;dword dwBuildNumber;dword dwPlatformId;char
szCSDVersion[128]")
;請想象為這樣(C++樣式): p->dwOSVersionInfoSize =
sizeof(OSVERSIONINFO)
DllStructSetData($p,
"dwOSVersionInfoSize", DllStructGetSize($p))
;生成 DllCall
Local $ret
= DllCall("kernel32.dll", "int", "GetVersionEx", "ptr", DllStructGetPtr($p))
If Not $ret[0] Then
MsgBox(0, "DllCall
錯誤", "DllCall
失敗")
Exit
EndIf
;獲取返回值
Local $major
= DllStructGetData($p, "dwMajorVersion")
Local $minor
= DllStructGetData($p, "dwMinorVersion")
Local $build
= DllStructGetData($p, "dwBuildNumber")
Local $platform
= DllStructGetData($p, "dwPlatformId")
Local $version
= DllStructGetData($p, "szCSDVersion")
;釋放數(shù)據(jù)結(jié)構(gòu)占用的內(nèi)存
$p = 0
MsgBox(0, "", "Major:
" & $major & @CRLF & _
"Minor: " & $minor & @CRLF & _
"Build: " & $build & @CRLF & _
"Platform ID: " &
$platform &
@CRLF &
_
"Version: " & $version)
provider with jb51.net (unicode) |