ctOpenEx
- Last UpdatedJul 13, 2023
- 2 minute read
Establishes the connection to the CtAPI server using the given client instance. Create the client instance prior to calling ctOpenEx, using the function ctClientCreate.
ctOpenEx provides exactly the same connection functionality as ctOpen, the only difference being that ctOpen also creates the CtAPI client instance. See ctOpen for details on the connection mechanism and the parameters involved.
Syntax
ctOpenEx(sComputer, sUser, sPassword, nMode, hCTAPI);
sComputer
Type: LPCSTR
Input/output: Input
Description: The computer you want to communicate with via CTAPI. For a local connection,
specify NULL as the computer name. The Windows Computer Name is the name as specified
in the Identification tab, under the Network section of the Windows Control Panel.
Note: To use a local connection when the CtAP process is running as a Windows service, you
need to:
(i) Add the user account as a member to the Runtime Users security role in Configurator (see Security Roles)
(ii) Check that the Enable Encryption option is selected on the Configurator, Encryption page.
Note: Using a hostname to connect to a CTAPI server running Plant SCADA 8.20 or earlier will not work if Windows is configured to return an IPv6 address for that hostname, as 8.20 and earlier do not support IPv6 network addresses. To avoid this, use an IPv4 address directly, or if encryption is enabled, configure Windows to return an IPv4 address in preference to an IPv6 address.
sUser
Type: LPCSTR
Input/output: Input
Description: A user name as defined in the Plant SCADA project running on the computer
to which you want to connect, or a Windows user name if nMode is set to CT_OPEN_WINDOWSUSER.
This argument is only necessary if you are calling this function from a remote computer. On a local computer, it is optional.
sPassword
Type: LPCSTR
Input/output: Input
Description: The sUser password defined in the Plant SCADA project running on the computer to which you
want to connect, or the password for the Windows user name if nMode is set to CT_OPEN_WINDOWSUSER.
This argument is only necessary if you are calling this function from a remote computer. You need to use a non-blank password. On a local computer, it is optional.
nMode
Type: Dword
Input/output: Input
Description:The mode of the Cicode call.
CT_OPEN_WINDOWSUSER — Indicates that sUser and sPassword are Windows user credentials. If sUser and sPassword are blank, then the credentials of the Windows user that is launching the application will be used.
To use Windows credentials to run CtAPI operations, you need to confirm the following:
-
Your server needs to be running Plant SCADA 2020 R2 (or later).
-
You need to use the CT_OPEN_WINDOWSUSER mode, and either:
-
CT_OPEN_EXTENDED mode is used in the CtOpen call.
Or:
-
The encryption mode on the CtAPI client is set to "Encrypted" or "Mixed Mode".
-
hCTAPI
Type: Handle
Input/output: Input
Description: The handle to the CTAPI as returned from ctOpen().
Return Value
TRUE if successful, otherwise FALSE. Use GetLastError() to get extended error information.
Related Functions
ctClientCreate, ctOpen, ctClose, ctCloseEx, ctClientDestroy
Example
See ctClientCreate.