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 @!
Printable View
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 @!
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 :)
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..
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 :
Regards.Code:#ifdef STRICT
typedef void *HANDLE;
#else
typedef PVOID HANDLE;
#endif
typedef HANDLE *PHANDLE;
-Vipul Pathak ;
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.