While making stdCOM for stdVBA, I ran into the need to dereference a pointer into a real VBA object. This was because I wanted to add an Object
property to stdCOM
objects, which enabled the retrieval of the full object data. I.E.
set cmApp = stdCOM.CreateFromPtr(ObjPtr(Application))
Debug.Print cmApp.Object.Name 'Print Application.Name
I had a load of issues with trying to find how to dereference an object, but finally stumbled upon some posts that suggesed using CopyMemory
. I still found it difficult to find a x64 example, but eventually settled with the implementation in Deref.Bas
.
This is now a part of stdCOM
which may be useful to others, but if importing a whole class is overkill for your use case, feel free to use this GIST.