The CloseHandlemethod closes an open Microsoft Windows object handle.

Namespace:  Microsoft.Rtc.Sip
Assembly:  ServerAgent(in ServerAgent.dll)

Syntax

Visual Basic (declaration)
Public 
Shared 
Function 
CloseHandle ( _
	
hObject 
As 
IntPtr _
) 
As 
Integer
Visual Basic (usage)
Dim 
hObject 
As 
IntPtr
Dim 
returnValue 
As 
Integer

returnValue = 

ServerAgent.
CloseHandle(
hObject)
C#
public 
static 
int 
CloseHandle(
	
IntPtr 
hObject
)

Parameters

hObject
Type: System . . :: . . IntPtr

The object handle to close, such as the handle to any security token.

Return value

Type: System . . :: . . Int32

Remarks

If the function succeeds, the return value is nonzero. Otherwise, it returns zero (0). To get the specific Windows error code, create a new instance of Win32Exception, which will obtain the corresponding Windows error code, as demonstrated in the following code example.

  Copy codeCopy code
if (ServerAgent.CloseHandle(mySecurityToken) == 0) {
 Win32Exception e = new Win32Exception();
 Console.WriteLine("Windows Error {0}: {1}", e.ErrorCode,
e.Message);
}

In the Microsoft Windows Platform SDK, a list of Windows error codes appears in Winerror.h.

Calling this method is identical to calling the Windows CloseHandle function in kernel32.lib (defined in Windows.h).

See also