Partager via


ServerAgent.CloseHandle

ServerAgent.CloseHandle

The CloseHandle method closes an open Microsoft Windows object handle.

Syntax

[C#]

public static int CloseHandle(
  System.IntPtr hObject
);

Syntax

[Visual Basic .NET]

Public Shared Function CloseHandle( _
  ByVal hObject As System.IntPtr _
) As int

Parameters

  • hObject
    Specifies the object handle to close, such as the handle to a security token.

Return Values

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.

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

A list of Windows error codes can be found in Winerror.h, which ships with the Microsoft Windows Platform SDK.

Remarks

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

Requirements

Redistributable: Requires Microsoft Lync Server 2010

Namespace:Microsoft.Rtc.Sip

Assembly: ServerAgent (in ServerAgent.dll)

See Also

Concepts

ServerAgent