函数参考


_WinAPI_GetString

Returns a string located at the specified memory address.

#Include <WinAPIEx.au3>
_WinAPI_GetString ( $pString [, $fUnicode] )

参数

$pString Pointer to a null-terminated string.
$fUnicode [可选参数] Specifies whether a string is Unicode or ASCII code of a character, valid values:
TRUE - Unicode. (Default)
FALSE - ASCII.

返回值

Success A string. @extended returns the lenght of the string, in TCHARs (not including the null-terminating character).
Failure Empty string and sets the @error flag to non-zero.

注意/说明

If the pointer is incorrect, _WinAPI_GetString() does not set @error flag but always returns an empty string.

相关

详情参考

None

示例/演示


#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

Global Const $WM_MYMESSAGE = _WinAPI_RegisterWindowMessage('MyMessage')

Global $hForm, $Msg, $Button, $Input, $pString

$hForm = GUICreate('MyGUI', 400, 93)
$Input = GUICtrlCreateInput('', 20, 20, 360, 20)
$Button = GUICtrlCreateButton('Send', 165, 59, 70, 23)
GUIRegisterMsg($WM_MYMESSAGE, 'WM_MYMESSAGE')
GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3
            ExitLoop
        Case $Button
            $pString = _WinAPI_CreateString(GUICtrlRead($Input))
            _WinAPI_SetMessageExtraInfo($pString)
            _SendMessage($hForm, $WM_MYMESSAGE, 1, 255)
            _WinAPI_FreeMemory($pString)
    EndSwitch
WEnd

Func WM_MYMESSAGE($hWnd, $iMsg, $wParam, $lParam)

    Local $pString = _WinAPI_GetMessageExtraInfo()

    If _WinAPI_IsMemory($pString) Then
        ConsoleWrite('WM_MYMESSAGE | WP = ' & Number($wParam) & ' | LP = ' & Number($lParam) & ' | EXTRA = "' & _WinAPI_GetString($pString) & '"' & @CR)
    EndIf
EndFunc   ;==>WM_MYMESSAGE