Unicast Administration Utility Sample

This sample application illustrates the use of the #import directive to incorporate the Windows Media Unicast Admin control (Nsunimgr.ocx) in the development environment of Microsoft® Visual C++® version 5.0. By default, the source code is located in C:\Program Files\Windows Media Components\SDK\Source\UniConf.

Working with ActiveX Controls in Visual C++ 5.0

Microsoft® ActiveX® controls are distributed in one or more .ocx files, which also contain the type library for a particular 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. To do this, in Microsoft® Visual Studio®, perform the following tasks:

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 the CLSID of the control. For information on this API, see the C++ Reference 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 preceding convention implies that there is a copy of the .ocx file in the local working directory.

The Windows Media Services Setup application installs all the available Windows Media controls in C:\Program Files\Windows Media Components\Server by default. However, the system administrator can override the default value in the installation process. When in doubt, you can determine the path by 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.

Using the Windows Media Unicast Admin Control in Visual C++ 5.0

The Windows Media Unicast Admin control is distributed as the Nsunimgr.ocx file. By default, the import statement thus becomes

#import "C:\Program Files\Windows Media Components\Server\nsunimgr.ocx"

If you specify Windows Media Components\Server as one of the working directories to be linked with libraries in Visual Studio, use the following syntax:

#import <nsunimgr.ocx>

Note You can specify Windows Media Components\Server as one of the working directories to be linked with libraries in Visual Studio. To do so, on the Tools menu, click Options. From Directories, click Show directories for, and click Library Files.

To run the sample after it is built, type the following command at the MS-DOS prompt:

Nsumconf serverhost