Function Reference


_WinAPI_GetString

Returns a string located at the specified memory address

#include <WinAPIMisc.au3>
_WinAPI_GetString ( $pString [, $bUnicode = True] )

Parameters

$pString Pointer to a null-terminated string.
$bUnicode [optional] Specifies whether a string is Unicode or ASCII code of a character, valid values:
    True - Unicode (Default).
    False - ASCII.

Return Value

Success: a string. @extended returns the length of the string, in TCHARs (not including the null-terminating character).
Failure: an empty string and sets the @error flag to non-zero.

Example

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WinAPIMisc.au3>
#include <WinAPISys.au3>

Global Const $WM_MYMESSAGE = _WinAPI_RegisterWindowMessage('MyMessage')

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 93)
Local $idInput = GUICtrlCreateInput('', 20, 20, 360, 20)
Local $idButton = GUICtrlCreateButton('Send', 165, 59, 70, 23)
GUIRegisterMsg($WM_MYMESSAGE, 'WM_MYMESSAGE')
GUISetState(@SW_SHOW)

Local $pString
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            $pString = _WinAPI_CreateString(GUICtrlRead($idInput))
            _WinAPI_SetMessageExtraInfo($pString)
            _SendMessage($hForm, $WM_MYMESSAGE, 1, 255)
            _WinAPI_FreeMemory($pString)
    EndSwitch
WEnd

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

    Local $pString = _WinAPI_GetMessageExtraInfo()

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