返回数据结构(struct)元素的数据.
DllStructGetData ( 数据结构, 元素 [, 索引 ] )
数据结构 | 由 DllStructCreate 返回的数据结构(struct). |
元素 | 你想要访问的数据结构(struct)元素, 起始于 1 或者由 DllStructCreate 函数定义的元素名. |
索引 | [可选参数] 如果元素是一个数组,你需要指定返回的索引,否则它返回索引 1 . 第一个元素是 1. |
成功: | 返回数据结构(struct)的元素数据. |
失败: | 返回 0. |
@Error: | 0 = 没有错误. |
1 = DllStructCreate 函数返回的数据结构(struct)不正确. | |
2 = 元素值超出范围. | |
3 = 索引值在数据结构(struct)外面. | |
4 = 元素的数据类型未知. | |
5 = 索引 <= 0. |
; Create the DLL structure to use in the DLLCall function.
Local $tagOSVERSIONINFO = DllStructCreate('dword dwOSVersionInfoSize;dword dwMajorVersion;dword dwMinorVersion;dword dwBuildNumber;dword dwPlatformId;char szCSDVersion[128]')
; Update the 'size element' in the structure by using DllStructGetSize to retrieve the total size of the structure.
DllStructSetData($tagOSVERSIONINFO, 'dwOSVersionInfoSize', DllStructGetSize($tagOSVERSIONINFO))
; Call the API function 'GetVersionEx' using DLLCall and passing the structure.
Local $aReturn = DllCall('kernel32.dll', 'int', 'GetVersionEx', 'struct*', $tagOSVERSIONINFO)
If @error Or Not $aReturn[0] Then
MsgBox(0, "DLLCall Error", "An error occurred when retrieving the Operating System information.")
EndIf
; Get specific data from the element strings.
Local $iMajorVersion = DllStructGetData($tagOSVERSIONINFO, 'dwMajorVersion')
Local $iMinorVersion = DllStructGetData($tagOSVERSIONINFO, 'dwMinorVersion')
Local $iBuildNumber = DllStructGetData($tagOSVERSIONINFO, 'dwBuildNumber')
Local $sServicePack = DllStructGetData($tagOSVERSIONINFO, 'szCSDVersion')
; Free the structure.
$tagOSVERSIONINFO = 0
MsgBox(0, "Operating System information", "Major version: " & $iMajorVersion & @CRLF & _
"Minor version: " & $iMinorVersion & @CRLF & _
"Build: " & $iBuildNumber & @CRLF & _
"Service Pack: " & $sServicePack & @CRLF)