|
-
April 22nd, 2007, 12:18 AM
#1
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.
-
April 22nd, 2007, 12:47 AM
#2
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.
-
April 22nd, 2007, 03:56 AM
#3
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
-
April 22nd, 2007, 07:04 AM
#4
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.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
April 22nd, 2007, 11:09 AM
#5
Re: What is a handle?
thanks
-
January 18th, 2010, 09:51 AM
#6
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|