Consider a method in your Xojo code called Foo that accepts an OSHandle as a parameter. That method could then create a declare that accepts an Integer. When you call the declare method, you could then pass it a variable of type OSHandle which could have been assigned either an Integer or a Ptr.
To use this, declare a parameter as OSHandle:
MyMethod(handle As OSHandle)
Var handle As OSHandle = 5 MyMethod(handle)
All project types on all supported operating systems.