Thursday, February 21, 2008

HANDLES In WIN32

Every running program is an instance or copy of the program.

This is also called object of the program. Windows should be capable enough to keep track of number of objects of a particular application in the memory.

So windows keep track of the addresses of different objects in the memory by storing their addresses, which is in the form of an unsigned integer.

This unsigned number, which is used to represent address of an object in the memory is called a HANDLE.

Handle is unique from one object to another. In windows handles refer to all objects.

Handle is pointer to a pointer to a memory location.

There are a number of data types in windows for describing the handles. These data types begin with a H.

Example:
HWND –handle to a window

Internally windows maintain tables that allow window to convert handles to physical addresses.



Example of Win32 API Program to display an message:

#include

int PASCAL WinMain(HANDLE hInstance , HANDLE hPrevInstance,LPSTR lpszCmdLine,int nShowCmd)
{
MessageBox (0,”Application is executing”,”Application”, MB_OK);
return 0;
}

No comments: