pdaughe Posted May 29, 2007 Posted May 29, 2007 $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
Zedna Posted May 29, 2007 Posted May 29, 2007 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)) Resources UDF ResourcesEx UDF AutoIt Forum Search
pdaughe Posted May 29, 2007 Author Posted May 29, 2007 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))
Zedna Posted May 29, 2007 Posted May 29, 2007 Search for some examples.Look atFunc _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 ;==>_GUICtrlStatusBarSetTipLocal $struct = DllStructCreate("char[" & StringLen($s_ToolTip) + 1 & "]")So it's definitely not a bug. Resources UDF ResourcesEx UDF AutoIt Forum Search
GaryFrost Posted May 29, 2007 Posted May 29, 2007 You need to make sure to add 1 for null char. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now