# SimConnect_Open The **SimConnect\_Open** function is used to send a request to the *Microsoft Flight Simulator* server to open up communications with a new client.   ##### Syntax ``` cpp HRESULT SimConnect_Open( HANDLE* phSimConnect, LPCSTR szName, HWND hWnd, DWORD UserEventWin32, HANDLE hEventHandle, DWORD ConfigIndex ); ```   ##### Parameters
ParameterDescriptionType
phSimConnectPointer to a handle to a SimConnect object.Integer
szNamePointer to a null-terminated string containing an appropriate name for the client program.Integer
hWndHandle to a Windows object. Set this to NULL if the handle is not being used. UserEventWin32Integer
UserEventWin32Code number that the client can specify. Set this to 0 if it is not being used.Integer
hEventHandleA Windows Event handle. A client can be written to respond to Windows Events, rather than use a polling and callback system, which can be a more efficient process if the client does not have to respond very frequently to changes in data in Microsoft Flight Simulator.Integer
ConfigIndexThe configuration index. The SimConnect.cfg file can contain a number of configurations, identified in sections with the [SimConnect] or [SimConnect.N] titles. Setting this configuration index indicates which configuration settings to use for this SimConnect client. This is useful for applications that communicate with a number of different machines that are running Microsoft Flight Simulator. The default configuration index is zero (matching a [SimConnect] entry in a SimConnect.cfg file). Note the E_INVALIDARG return value.Integer
  ##### Return Values The function returns an **HRESULT**. Possible values include, but are not limited to, those in the following table. {{< table-wrapper >}} | Return value | Description | |---------------|-----------------------------------------------------------------------------------------------------------------| | S\_OK | The function succeeded. | | E\_FAIL | The function failed. | | E\_INVALIDARG | A SimConnect section in the `SimConnect.cfg` file did not contain the config index requested in the parameters. | {{< /table-wrapper >}}   ##### Example ``` cpp HRESULT hr; HANDLE hSimConnect = NULL; hr = SimConnect_Open(&hSimConnect, "Your Application Name", NULL, 0, 0, SIMCONNECT_OPEN_CONFIGINDEX_LOCAL); ```   ##### Remarks Most client applications will have one [SimConnect\_Open](simconnect-open/) call, and one corresponding [SimConnect\_Close](simconnect-close/) call. However in some applications, multiplayer in particular, multiple [SimConnect\_Open](simconnect-open/) calls may be necessary, in which case an array or list of handles will need to be maintained, and closed appropriately.   A client can optionally examine the [SIMCOMMENT\_RECV\_OPEN](../structures-and-enumerations/simconnect-recv-open/) structure that is returned after a call to [SimConnect\_Open](simconnect-open/). This structure gives versioning and build information that should be useful when multiple versions of SimConnect and multiple versions of *Microsoft Flight Simulator* that support it, are available. If a remote client successfully establishes a link with Flight Simulator, but at some later time the network connection is lost, SimConnect functions will return the `NTSTATUS` error `STATUS_REMOTE_DISCONNECT` (0xC000013CL).   The [SIMCONNECT\_EXCEPTION\_VERSION\_MISMATCH](../structures-and-enumerations/simconnect-exception/) exception will be returned if a versioning error has occurred, typically when a client built on a newer version of the SimConnect client dll attempts to work with an older version of the SimConnect server. If this exception is received the number 4 is returned in the *dwIndex* parameter of the [SIMCONNECT\_RECV\_EXCEPTION](../structures-and-enumerations/simconnect-recv-exception/) structure.