The NetShow Unicast Administration Utility sample illustrate the use of the #import directive to incorporate the NetShow Unicast Manager Admin control (Nsunimgr.ocx) in the development environment of Microsoft Visual C++ 5.0. You can find the sample source code, together with the Visual C++ project files, in the\NetShowRoot\SDK\Samples\Admin\UniConf directory. Here, \NetShowRoot is the root directory where NetShow is installed.
ActiveX controls are distributed in one or more .OCX files, which also contains the type library for a particularly control. To make an ActiveX control available to a C/C++ application, you must incorporate the control into a C/C++ source file and then create an instance of the control. In Microsoft Visual Studio you can accomplish these by carrying out the following tasks.
#import “anActiveXControl.ocx”
HRESULT hr = ControlPtr.CreateInstance(L”ProgID”);
Here the ControlPtr variable is a pointer to the specified ActiveX control. “ProgID” is the string value of the ProgID of the control. Instead of ProgID, you can also use CLSID of the control. For information on this API, see The C++ References Documentation for _com_ptr_t::CreateInstance(CLSD|ProgID, [dwClsContext]).
The #import directive is closely related to the #include C-preprocessor macro. It directs the compiler to include, at the point of import, the appropriate type library and to make the type information available for use in the application. The convention above implies that there is a copy of the .OCX file in the local working directory.
The NetShow setup application installs all the available NetShow controls in the NetShowRoot\Server directory. Here NetShowRoot is the root directory of NetShow. The default setting is C:\Program Files\Microsoft NetShow. But the system administrator can override the default value in the installation process. When in doubt, you can determine the path using the OLE/COM Object Viewer application, which is accessible from Visual Studio for Visual C++.
You can also examine all the available methods, events and properties from OLE/COM Object Viewer.
The NetShow Unicast Server Manager Admin control is distributed as the nsunimgr.ocx file. The import statement thus becomes
#import “NetShowRoot\Server\nsunimgr.ocx”
If you specify NetShowRoot\Server as one of the working directories for linking with libraries in Visual Studio (You can do so after selecting the Library Files entry in the Show directories for drop-down list from the Directories pane in the Options dialog box activated from the Tools menu), you can use the following syntax:
#import <nsunimgr.ocx>
After you build the sample, you can run it by issuing from the MS-DOS console terminal the following command:
Nsumconf serverhost
[Previous][Next]