Jump to content
Sign in to follow this  
Kris123

Pointers

Recommended Posts

Kris123

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.

Share this post


Link to post
Share on other sites
jvanegmond

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

Share this post


Link to post
Share on other sites
Kris123

Thanks for your reply.

I tried in the same way, but is not working....

Share this post


Link to post
Share on other sites
jvanegmond

Please post the important parts of your code that are not working so we can isolate the issue.

Share this post


Link to post
Share on other sites
Kris123

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)

Share this post


Link to post
Share on other sites
jvanegmond

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

Share this post


Link to post
Share on other sites
Kris123

I have tried in this way.

But my problem is not solved.

Share this post


Link to post
Share on other sites
trancexx

I have tried in this way.

But my problem is not solved.

Just read $AddResult[2]

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Kris123

Thanks it is working.

Great job.

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  

×