RtOpenSemaphore

RtOpenSemaphore returns a handle of an existing named semaphore object.

Syntax

Copy
HANDLE RtOpenSemaphore(
    [ignored]  DWORD dwDesiredAccess,
    [in]       BOOL bInheritHandle,
    [in]       LPCTSTR lpName
);

Parameters

[ignored] DesiredAccess

Ignored.

[in] bInheritHandle

This must be FALSE.

[in] lpName

A pointer to a null-terminated string that names the semaphore to be opened. Name comparisons are case-sensitive.

Return Value

If the function succeeds, it returns the semaphore object. If the function fails, it returns NULL. Call GetLastError to obtain an error code.

Remarks

RtOpenSemaphore enables multiple processes to open handles of the same semaphore object. The function succeeds only if some process has already created the semaphore by using RtCreateSemaphore. The calling process can use the returned handle in any function that requires a handle of a semaphore object, such as a wait function, subject to the limitations of the access specified in DesiredAccess.

Use RtCloseHandle to close the handle. The system closes the handle automatically when the process terminates. The semaphore object is destroyed when its last handle has been closed.

Requirements

Minimum supported version Header Library

wRTOS 1.0 SDK

RtApi.h

RtApi.lib (Windows), Startup.lib (RTSS)

See Also: