Yashied Posted March 16, 2009 Share Posted March 16, 2009 (edited) Please advise how to get a pointer (address) to a variable ($a)?local $a = 16 Edited March 16, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
jvanegmond Posted March 16, 2009 Share Posted March 16, 2009 Not in AutoIt. github.com/jvanegmond Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 16, 2009 Share Posted March 16, 2009 Not in AutoIt. Unless you do it with a DLL struct: ; Create the struct and get it's pointer Global $iA = 16 Global $tagA = "int A" Global $tA = DllStructCreate($tagA) Global $ptA = DllStructGetPtr($tA) ; Set the data DllStructSetData($tA, "A", $iA) ; Use the pointer to extract the data MsgBox(64, "DLL Success Test", "A = " & _GetData($ptA) & @CRLF & "@error = " & @error) ; Force an error $ptA = 0 MsgBox(16, "DLL Error Test", "A = " & _GetData($ptA) & @CRLF & "@error = " & @error) Func _GetData($ptPointer) Local $tRET = DllStructCreate($tagA, $ptPointer) Local $iRET = DllStructGetData($tRET, 1) Return SetError(@error, 0, $iRET) EndFunc ;==>_GetData In this example, you can't get the pointer to $iA directly, but you can copy $iA into a struct and get the pointer of that. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
trancexx Posted March 16, 2009 Share Posted March 16, 2009 (edited) Unless you do it with a DLL struct: ; Create the struct and get it's pointer Global $iA = 16 Global $tagA = "int A" Global $tA = DllStructCreate($tagA) Global $ptA = DllStructGetPtr($tA) ; Set the data DllStructSetData($tA, "A", $iA) ; Use the pointer to extract the data MsgBox(64, "DLL Success Test", "A = " & _GetData($ptA) & @CRLF & "@error = " & @error) ; Force an error $ptA = 0 MsgBox(16, "DLL Error Test", "A = " & _GetData($ptA) & @CRLF & "@error = " & @error) Func _GetData($ptPointer) Local $tRET = DllStructCreate($tagA, $ptPointer) Local $iRET = DllStructGetData($tRET, 1) Return SetError(@error, 0, $iRET) EndFunc;==>_GetData In this example, you can't get the pointer to $iA directly, but you can copy $iA into a struct and get the pointer of that. Your structure is global. No need for _GetData() function: MsgBox(64, "DLL Success Test", "A = " & DllStructGetData($tA, 1)) Same thing as for pointer thoug I can see what could be your point(er). Yashied likely meant something else. Edited March 16, 2009 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Yashied Posted March 16, 2009 Author Share Posted March 16, 2009 Your structure is global. No need for _GetData() function: MsgBox(64, "DLL Success Test", "A = " & DllStructGetData($tA, 1)) Same thing as for pointer thoug I can see what could be your point(er). Yashied likely meant something else.trancexx, you are right. I want to access a variable (not structure) knowing only the address and type. But I think that this is not possible in AutoIt (different syntax). Although the structure is the same, but less convenient than a direct appeal to the variable. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 16, 2009 Share Posted March 16, 2009 trancexx, you are right. I want to access a variable (not structure) knowing only the address and type. But I think that this is not possible in AutoIt (different syntax). Although the structure is the same, but less convenient than a direct appeal to the variable. All AutoIt variables are a C-type variant, and the properties of the variant for the different AutoIt variable types is not meant to be exposed to the scripter. Valik doesn't even like that the VarGetType() function exists. So even if you got a pointer to the $a variable, it would be to a variant that required more processing to see that it was a variant containing an INT32 and where the actual value was. At least that's my understanding from a non-C programmer peek behind the curtain. Smarter people can and often do correct me. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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