OpenNtmsSessionA function (ntmsapi.h)

[Removable Storage Manager is no longer available as of Windows 7 and Windows Server 2008 R2.]

The OpenNtmsSession function sets up a session with a RSM server.


HANDLE OpenNtmsSessionA(
  [in] LPCSTR lpServer,
  [in] LPCSTR lpApplication,
       DWORD  dwOptions


[in] lpServer

RSM server name. If this parameter is NULL, the current computer name is used.

[in] lpApplication

Unique character string that identifies the application. This name identifies resources and operator requests. This parameter is optional and may be NULL.


Reserved; must be zero.

Return value

If OpenNtmsSession succeeds, it returns a handle that uniquely identifies this session. If the function fails, it returns INVALID_HANDLE_VALUE. To retrieve more information, call the GetLastError function. This function can return one of the following values.

Value Meaning
The computer name format that was specified was not in a valid format.
One of the parameter values was not valid.
The network is not started or not available.
Unable to connect to the RSM service.
RSM service has not started. The application should wait and retry.
The function was successful.
RSM cannot open a session.
The service is using an older version of RSM than your application.


The OpenNtmsSession function returns a session handle used with other RSM functions, establishes a connection with the RSM database, and initializes the RSM subsystem for the application.

When OpenNtmsSession returns, the application can perform RSM operations.

Sessions are thread-safe but cannot be passed among processes.


The ntmsapi.h header defines OpenNtmsSession as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.


Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header ntmsapi.h
Library Ntmsapi.lib
DLL Ntmsapi.dll

See also


Session Management Functions