2.1.10.4 CloseHandle


Description

This function closes an open object handle.

Syntax

BOOL CloseHandle( HANDLE hObject )

Parameters

hObject
[modify] Handle to an open object.

Return

TRUE for success

Examples

EX1

int CloseHandle_ex1()
{
    char* szFilename = "c:\\test.txt" ;
    BOOL bRet = FALSE;
    HANDLE hFile = CreateFile(szFilename, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    if (hFile != INVALID_HANDLE_VALUE)
    {
    	//do something...
        CloseHandle(hFile);
    }
    return 1;
}

Remark

See Also

CreateFile

Header to Include

origin.h

Reference