|
-
May 31st, 2004, 08:39 PM
#1
What is a HANDLE?
I have something which is not quite sure about it... it is HANDLE .. I though it was a kind of data type.. But I heard from my friend saying that : it was a thread .. Is it true..?
THank YOu @!
-
May 31st, 2004, 08:58 PM
#2
A handle is ... Well its pretty hard to explain. You can have a handle to a thread and a handle to device context. You can also have a handle to a file. You can think of it as a pointer to a structure that windows hides from you to keep it more user friendly for the programmer . To close any HANDLE use CloseHandle() api. The usefull ness of this is you can have an array of handles for various things e.g. files, threads, processes etc... and have a simple loop closeing all the handles using CloseHandle().
Hope this helps
-
June 1st, 2004, 12:35 AM
#3
So.. what I heard from friend is... I think is partial true (I mean handle to thread)... basically it just a structure.. right?
THanks a lot..
-
June 1st, 2004, 03:11 AM
#4
Although answer has explained the stuff. Yes, a HANDLE is a pointer to Internal Data structure that is explaining may be a Thread, an Event, a File etc. When the Handle is passed to CloseHandle() API, it correctly understand what it is representing and thus Cleans-Up in appropriate way.
For your interest, here is the code snippet from WinNt.H :
Code:
#ifdef STRICT
typedef void *HANDLE;
#else
typedef PVOID HANDLE;
#endif
typedef HANDLE *PHANDLE;
Regards.
-Vipul Pathak ;
-
June 1st, 2004, 03:15 AM
#5
Basically HANDLE is a UINT value, sometime it's a pointer, sometime it's a index... More detail, u have to know what object is. Maybe an article in MSDN - 'Give me a handle, I'll show you an object' - will help u a little bit.
Last edited by sephiroth2m; June 1st, 2004 at 03:23 AM.
Trust urself!
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
|