-
What is a handle?
When people say "X() returns a Handle for a Bla" I think of a Handle as a pointer. My friend who has been programming since dirt was invented says a Handle is not a pointer , but similar. What the heck is a Handle ? I am reading a winsock book and it uses the term Handle every 3 words, so any help would be appreciated.
-
Re: What is a handle?
A handle is basically some kind of reference to a resource that enables you to use that resource. Typically it would be a pointer, or some pointer-like object.
-
Re: What is a handle?
I like to visualize a handle as something like a pointer to a pointer or a key into a map.
When using a handle you never directly access the data ( resource ) that this handle represents. This way e.g. the OS is able to transparently move the actual data ( resource ) around in memory but the actual value of the handle need not change during the lifetime of the handle.
Kurt
-
Re: What is a handle?
A handle is a means of referring to some internal data structure. You do not know what it actually is. It could be a pointer, it could be an index into an array, it could be a random number (perhaps used as an arbitrary key into some data structure). The point is that you don't know, and that its meaning could change at any time without your knowledge.
If someone gives you a handly, the ONLY thing you can/should use it for, is to pass it back to the same system, albiet a different function.
-
Re: What is a handle?
-
Re: What is a handle?
http://www.parashift.com/c++-faq-lite/references.html
There's a lot of info about handles vs. pointers, etc... I've had the same question some time ago... good luck!