MI_Application_NewSession function (mi.h)

Creates a session used to share connections for a set of operations to a single destination.

Syntax

MI_INLINE MI_Result MI_Application_NewSession(
  [in]           MI_Application        *application,
  [in, optional] const MI_Char         *protocol,
  [in, optional] const MI_Char         *destination,
  [in, optional] MI_DestinationOptions *options,
  [in, optional] MI_SessionCallbacks   *callbacks,
                 MI_Instance           **extendedError,
  [out]          MI_Session            *session
);

Parameters

[in] application

A pointer to a handle returned from the MI_Application_Initialize function.

[in, optional] protocol

A pointer to an optional protocol handler to carry out the operation. If this parameter is NULL, a default value is used, based on the destination. Currently supported protocols are L"WMIDCOM" and L"WINRM".

[in, optional] destination

An optional destination for the session. If the destination argument is NULL, the session communicates with the local machine. Otherwise, the destination can be the computer name of the local machine or a remote machine.

[in, optional] options

A pointer to optional destination options, such as default time-outs and credentials.

[in, optional] callbacks

A pointer to an optional MI_SessionCallbacks structure that contains callbacks to receive various results.

extendedError

Pointer to optional additional error information if the operation failed. When you have finished using the error information, free the memory by calling the MI_Instance_Delete function.

[out] session

A pointer to the returned session handle. When you have finished using the session handle, close it by calling the MI_Session_Close function. If the session handle is not closed before shutting down both the application and the application handle, the application handle shutdown will not respond.

Return value

This function returns MI_INLINE MI_Result.

Remarks

Creating a destination may not communicate with the destination computer. It will not be until the first operation is carried out on a session that the application can determine whether the computer is accessible.

The MI_Session_Close function must be called on the outbound session handle. Close all operations under the target session before closing the session.

If no protocol is specified and destination is NULL, the WMIDCOM protocol is used. If no protocol is specified and destination is not NULL, the WINRM protocol is used. .

Requirements

Requirement Value
Minimum supported client Windows 8
Minimum supported server Windows Server 2012
Target Platform Windows
Header mi.h
Redistributable Windows Management Framework 3.0 on Windows Server 2008 R2 with SP1, Windows 7 with SP1, and Windows Server 2008 with SP2

See also

Windows Remote Management