Admin Production ni-theme
Current Publication

CA_InitActiveXServer

LabWindows/CVI

CA_InitActiveXServer

HRESULT CA_InitActiveXServer (HINSTANCE serverHInstance, ServerModuleType serverModuleType, const char *commandLine, CAServerModuleDesc *serverModuleDescription, int *runServer, char *errorBuffer, size_t errorBufferSize);

Purpose

Initializes your ActiveX server.

If your server is a DLL, call this function in DllMain, for the DLL_PROCESS_ATTACH case. If your server is an EXE, call this function in WinMain. You must call InitCVIRTE before calling this function.

If you are using the ActiveX Server Wizard, call the Init function that the wizard generates for your server in place of this function.

Parameters

Input
Name Type Description
serverHInstance HINSTANCE The HINSTANCE of your server.

Note that the HINSTANCE is passed in as an argument to DllMain and WinMain. If your code uses main instead of WinMain as the module entry point, this value is not available. Therefore, EXE servers must use WinMain as their entry point.
serverModuleType ServerModuleType The type (DLL or EXE) of your server.

Pass kServerModuleType_Dll for a DLL server and kServerModuleType_Exe for an EXE server.
commandLine const char * The command line with which your EXE server was launched.

Pass NULL for a DLL server. Note that the command line is passed in as an argument to WinMain.
serverModuleDescription CAServerModuleDesc * Pointer to the structure describing your ActiveX server.
errorBuffer char * The buffer in which an error string is copied if a library error occurs during initialization.

Pass NULL if you do not want this information.

If buffer cannot hold the entire error string, (errorBufferSize - 1) bytes are copied into buffer, appended by the ASCII NUL byte.
errorBufferSize size_t The number of bytes in the errorBuffer parameter.
Output
Name Type Description
runServer int A Boolean value indicating whether your EXE server was launched to be run or for registration purposes.

If this value is zero when the function returns, then your EXE server was launched for registration purposes only, and you should exit after calling CA_CloseActiveXServer. Pass NULL for DLL servers.

Return Value

Name Type Description
status HRESULT A value indicating whether an error occurred. Function failure is indicated by a negative error code.

Error codes are defined in CVIversion\include\cviauto.h and <Program Files>\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\winerror.h. The LabWindows/CVI ActiveX Library explicitly returns error codes. Other error codes in winerror.h are generated by the COM runtime and passed on to you by the ActiveX Library.

You can use CA_GetAutomationErrorString to get the description of an error code or CA_DisplayErrorInfo to display the description of the error code.

Note   You should not return the ActiveX Library error codes from your ActiveX server to your ActiveX clients, unless you document them in your server documentation. An acceptable compromise in this case is to return E_UNEXPECTED to the clients.

The error codes defined in <Program Files>\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\winerror.h are too numerous to display here. These error codes can be returned to your ActiveX clients.

Additional Information

Library: ActiveX Library

Include file: cviauto.h

LabWindows/CVI compatibility: LabWindows/CVI 6.0 and later