Jump to content

Pointers


Kris123
 Share

Recommended Posts

Like in Visual Basic, you can just pass the variable to the function and not the pointer.

Please have a look at:

; Sample script with three user-defined functions
; Notice the use of variables, ByRef, and Return

$foo = 2
$bar = 5
swap($foo, $bar)
msgBox(0,"After swapping $foo and $bar", "$foo now contains " & $foo)
Exit

Func swap(ByRef $a, ByRef $B)  ;swap the contents of two variables
    Local $t
    $t = $a
    $a = $b
    $b = $t
EndFunc
Edited by Manadar
Link to comment
Share on other sites

Actually i have a Dll exposed which will accept a variable byref.

Here from my script i am trying to pass a value to the Dll by ref.

But i am not getting any value into that variable.

Sample code is:

Protocol_Get(18, $value)

Func Protocol_Get($opcode, ByRef $value)

$AddResult = DllCall($PE_Plugin, "long", "Monitor_GetProperty", "long", $opcode, "long*", $value)

EndFunc

MsgBox(0, "", $value)

Link to comment
Share on other sites

I'm still a bit confused about this myself, but to give you a quick answer: AutoIt ByRef does not mean the value is converted into a pointer.

Your script should be something along these lines:

Protocol_Get(18, $value)

Func Protocol_Get($opcode, $value)
    $long = DllStructCreate("long")
    DllStructSetData($long, 1, $value)
    
    $AddResult = DllCall($PE_Plugin, "long", "Monitor_GetProperty", "long", $opcode, "long*", DllStructGetPtr($long))
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...