Kris123 Posted February 4, 2009 Share Posted February 4, 2009 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. Link to comment Share on other sites More sharing options...
jvanegmond Posted February 4, 2009 Share Posted February 4, 2009 (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 February 4, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Kris123 Posted February 4, 2009 Author Share Posted February 4, 2009 Thanks for your reply. I tried in the same way, but is not working.... Link to comment Share on other sites More sharing options...
jvanegmond Posted February 4, 2009 Share Posted February 4, 2009 Please post the important parts of your code that are not working so we can isolate the issue. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Kris123 Posted February 4, 2009 Author Share Posted February 4, 2009 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 More sharing options...
jvanegmond Posted February 4, 2009 Share Posted February 4, 2009 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 github.com/jvanegmond Link to comment Share on other sites More sharing options...
Kris123 Posted February 4, 2009 Author Share Posted February 4, 2009 I have tried in this way. But my problem is not solved. Link to comment Share on other sites More sharing options...
trancexx Posted February 4, 2009 Share Posted February 4, 2009 I have tried in this way. But my problem is not solved.Just read $AddResult[2] ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Kris123 Posted February 4, 2009 Author Share Posted February 4, 2009 Thanks it is working. Great job. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now