Update May 16, 2005:
Added _DllStructCreateFromString() Creat a struct that is a copy of a string
Added _GetLastErrorMessage() String containing system error message
Update May 12,2005:
Renamed _StructWriteToFile() to _FileWriteFromDllStruct()
Renamed _FileReadToStruct() to _FileReadToDllStruct()
Fixed header comments
Added _StructWriteToFile($p,$szFileName)
Added _FileReadToStruct($szFileName)
Update May 11, 2005:
Added _DllStructGetSizeFromStr($szStruct) like DllStructGetSize() without creating the struct
Added _DllStructSubStruct($p,$iElement,$szStruct) see header
Function Headers:
;===================================================== ; _DllStructGetSizeFromStr($szStruct) ; $string The string you would use in DllStructCreate ; Returns The size of the struct ; 0 on error and sets @Error To the DllStructCreate Error ;===================================================== ;===================================================== ; _DllStructSubStruct(ByRef $p, $iElement, $szStruct) ; $p The return from DllStructCreate() ; $iElement The element where the sub struct is located ; $szStruct The String representing the Sub Struct ; Returns a new struct for use in DllStructGet/DllStructSet ; Sets @Error to -1 if $iElement is outside, -2 sub struct ; would go outside the bounds of the struct ; $p's elements are decreased as the substruct elements are removed ; ; $RECT_STR = "int;int;int;int" ; $POINT_STR = "int;int" ; $p = DllStructCreate("ptr;" & $RECT_STR & ";" & $POINT_STR) ; $rect = _DllStructSubStruct($p,2,$RECT_STR) ; $point = _DllStructSubStruct($p,3,$POINT_STR) ; DllCall("some.dll","int","func","ptr",DllStructPtr($p)) ; $point_x = DllStructGet($point,1) ; $point_y = DllStructGet($point,2) ; $left = DllStructGet($rect,1) ; $top = DllStructGet($rect,2) ; $right = DllStructGet($rect,3) ; $bottom = DllStructGet($rect,4) ; DllStructFree($p) ;===================================================== ;=============================================== ; _FileWriteFromDLLStruct($p,$szFileName) ; Write a Struct to a file ; $p Struct to write ; $szFileName Name of the file to write ; Return Bytes Written ; On Error @Error is set to ; -1 invalid Struct ; -2 DllStructGetSize Failed ; -3 Could not open File ; -4 DllCall Failed ; -5 WriteFile Failed ;=============================================== ;=============================================== ; _FileReadToDLLStruct($szFileName) ; Read a file into a DllStruct, which you must delete ; $szFileName Name of the file to read ; Return DllStruct which element 1 is an ; array of bytes = file size ; element 2 is the number of bytes ; read. Access the data with: ; $n = DllStructGetData($p,2) ; DllStructGetData($p,1,1..$n) ; On Error @Error is set to ; -1 File does not exist ; -2 DllStructCreate Failed ; -3 Could not open File ; -4 DllCall Failed ; -5 ReadFile Failed ;=============================================== ;=============================================== ; _DllStructCreateFromString($szString) ; Create a DllStruct That is a string, and copy $szString into it ; $szString String to be in the new struct ; Return Success a new struct, Failure @error = -1 ;=============================================== ;=============================================== ; _GetLastErrorMessage($DisplayMsgBox="") ; Format the last windows error as a string and return it ; if $DisplayMsgBox <> "" Then it will display a message box w/ the error ; Return Window's error as a string ;===============================================
Attached Files
Edited by Ejoc, 16 May 2005 - 08:44 PM.







