Sign in to follow this  
Followers 0
Raik

Questions about Structs

2 posts in this topic

The Story:

I write a Tool for Notepad++, witch comunicates with NPP and the Scintilla-Control via _WinAPI_ReadProcessMemory / _WinAPI_WriteProcessMemory, Works now, but while i designed the functions, i came across some Questions.

If i succeed with it, i will release a UDF for complete Comunication with Notepad++ / Scintilla.

the Questions:

The Description of DllStructCreate sounds, like not only the elements of a struct can be named, but structs themselfs too. Is this right, and if so, how is it done? (will be usefull for my project, if possible)

"Struct mystruct;int;char[10],EndStruct" or something alike? (if that is possible,it should be mentioned in the helpfile)

And i came across an example, where someone used type "struct" instead of "ptr" in DllCall. Is that equivalent?


AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

Share this post


Link to post
Share on other sites



No, you can't name structs like that (as far as I know), but you can do something like this:

Global Const $tagMyStruct = 'int var1;byte var2;uint var3;char var4[128];'

;Global scope
Global $tMyStruct1 = DllStructCreate($tagMyStruct)
Global $tMyStruct2 = DllStructCreate($tagMyStruct)

Func Foo()
    ;Local scope
    Local $tMyStruct = DllStructCreate($tagMyStruct)
EndFunc

Func Bar()
    ;Local scope
    Local $tAnotherMyStruct = DllStructCreate($tagMyStruct)
EndFunc

 

And about your last question, for calling some functions which take a pointer to a struct, you can do it like this:

#include <StructureConstants.au3>

Global $hWnd = 0 ;Your window handle
Global $tRect = DllStructCreate($tagRect)

DllCall('User32.dll', 'BOOL', 'GetWindowRect', _
        'HWND', $hWnd, _
        'PTR', DllStructGetPtr($tRect))

Or as you said, like this:

#include <StructureConstants.au3>

Global $hWnd = 0 ;Your window handle
Global $tRect = DllStructCreate($tagRect)

DllCall('User32.dll', 'BOOL', 'GetWindowRect', _
        'HWND', $hWnd, _
        'STRUCT*', $tRect)

Both of them do the same thing.

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