Sign in to follow this  
Followers 0
pdaughe

Help with DLLStruct

5 posts in this topic

$Header = DllStructCreate ("char Name[8]")
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

DllStructSetData ($Header,"Name","12345678")        ;<----- eight characters
if @error Then
    MsgBox (0, "DLLStructSetData Error", "Username")
    exit
endif

MsgBox(0,"DllStruct","Struct Size: " & DllStructGetSize($Header) & @CRLF & _
        "Data:" & @CRLF & _
        DllStructGetData($Header,1) & @CRLF & _
        DllStructGetData($Header,"Name"))

Why are only seven bytes returned by the GetData?

Thanks,

Paul

Share this post


Link to post
Share on other sites



This works fine.

So you must define char[number of chars + 1]

$Header = DllStructCreate ("char[9]")
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

DllStructSetData ($Header,1,"12345678")        ;<----- eight characters
if @error Then
    MsgBox (0, "DLLStructSetData Error", "Username")
    exit
endif

MsgBox(0,"DllStruct","Struct Size: " & DllStructGetSize($Header) & @CRLF & _
        "Data:" & @CRLF & _
        DllStructGetData($Header,1))

Share this post


Link to post
Share on other sites

Thanks Zedna -- I just wasn't sure if it was a bug or not. It would be helpful for others if it was documented in DLLStructCreate.

Paul

This works fine.

So you must define char[number of chars + 1]

$Header = DllStructCreate ("char[9]")
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

DllStructSetData ($Header,1,"12345678")        ;<----- eight characters
if @error Then
    MsgBox (0, "DLLStructSetData Error", "Username")
    exit
endif

MsgBox(0,"DllStruct","Struct Size: " & DllStructGetSize($Header) & @CRLF & _
        "Data:" & @CRLF & _
        DllStructGetData($Header,1))

Share this post


Link to post
Share on other sites

Search for some examples.

Look at

Func _GUICtrlStatusBarSetTip($h_StatusBar, $i_part, $s_ToolTip)
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    Local $struct = DllStructCreate("char[" & StringLen($s_ToolTip) + 1 & "]")
    DllStructSetData($struct, 1, $s_ToolTip)
    If @error Then Return SetError(@error,@error,0)
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETTIPTEXT, "int", $i_part, "int", DllStructGetPtr($struct))
    $struct = 0
EndFunc   ;==>_GUICtrlStatusBarSetTip

Local $struct = DllStructCreate("char[" & StringLen($s_ToolTip) + 1 & "]")

So it's definitely not a bug.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0