Jump to content

Recommended Posts

Posted

Dear All,

Here i would like to know how to declare the pointer.

Because i am passing a variable to a function, and there the function is receiving as ByRef.

So Please help..

Thanks in advance.

Posted (edited)

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
Posted

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)

Posted

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

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
×
×
  • Create New...