Hope someone can explain.
I have tried my best to explain how the structure stuff works..
[color=indigo]/*
Function DummyDllCall(
LPBYTE pUserData // user information buffer
);
The USERDATA structure specifies detailed user information
typedef struct USERDATA {
LPTSTR pNick;
LPTSTR pJoined;
DWORD Posts;
LPTSTR pLocation;
}
*/[/color]
Nick=IsNull
Joined=10 May 2007
Posts=66
Location=.switzerland
; Items 1,2 & 4 are strings - we have to obtain Pointers to null terminated strings
; Item 3 is already an Integer, so we can feed it into structure as value
pNick := &Nick
pJoined := &Joined
pLocation := &Location
; Lets view the Pointers
; MsgBox,0, Just viewing the Pointers, % pNick "`n" pJoined "`n" pLocation
; // Encoding structure USERDATA //
; Items 1,2,3,4 - all are now UINTs.
; 1 UINT needs 4 bytes, therefore 4 UINTs need 16 bytes
VarSetCapacity( USERDATA,16,0 ) ; empty structure created - with length of 16 bytes
; Now, put those 4 UINTs into Structure
NumPut( pNick, USERDATA, 0, "UInt" ) ; Pointer inserted @ offset 0
NumPut( pJoined, USERDATA, 4, "UInt" ) ; Pointer inserted @ offset 4
NumPut( Posts, USERDATA, 8, "UInt" ) ; UINT equals a DWORD - UINT inserted @ offset 8
NumPut( pLocation, USERDATA,12, "UInt" ) ; Pointer inserted @ offset 12
; Therefore -
; Structure USEDATA has been encoded with 4 elements
; 1,2 & 4 are Pointers to null terminated strings
; Item 3 is already a DWORD and so has been fed in directly
; // Lets call the Function DummyDllCall() and pass the structure USERDATA as parameter
DummyDllCall( &USERDATA )
Return ; // end of auto-execute section //
; The following WORKING FUNCTION will give you a crude idea on how the DLL Funtion would
; retrieve the data from the structure USERDATA
DummyDllCall( pUserdata ) {
pNick := NumGet( pUserData+0 , 0, "UInt" ) ; Pointer to Null Terminated String
pJoined := NumGet( pUserData+4 , 0, "UInt" ) ; Pointer to Null Terminated String
Posts := NumGet( pUserData+8 , 0, "UInt" ) ; is already Integer Data
pLocation := NumGet( pUserData+12, 0, "UInt" ) ; Pointer to Null Terminated String
VarSetCapacity( Nick ,20,0 )
VarSetCapacity( Joined ,20,0 )
VarSetCapacity( Location,20,0 )
DllCall( "lstrcpyA", UInt,&Nick , UInt,pNick )
DllCall( "lstrcpyA", UInt,&Joined , UInt,pJoined )
DllCall( "lstrcpyA", UInt,&Location, UInt,pLocation )
; Repair the variables - i.e., Set Internal Variable Length right!
VarSetCapacity( Nick, -1 ), VarSetCapacity( Joined,-1 ), VarSetCapacity( Location, -1 )
MsgBox,0,DummyDllCall(), % Nick "`n" Joined "`n" Posts "`n" Location
}