This sample demonstrates how a C# program can interoperate with an unmanaged COM component.
Security Note |
---|
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended. |
To build and run the COM Interop Part 1 samples within Visual Studio
In Solution Explorer, right-click the Interop1 project and click Set as StartUp Project.
In Solution Explorer, right-click the Interop1 project and click Properties.
Open the Configuration Properties folder, and click Debug.
In the Command-Line Arguments property, enter an AVI file such as
c:\winnt\clock.avi
.Click OK.
From the Debug menu, click Start Without Debugging.
Repeat the preceding steps for Interop2.
If the QuartzTypeLib.dll included with Interop1 is out of date
In Solution Explorer, open References for Interop1.
Right-click QuartzTypeLib, and click Remove.
Right-click References, and click Add Reference.
In the COM tab, select the component named "ActiveMovie control type library."
Click Select, and then click OK.
Rebuild Interop1.
Note Adding a reference to the component does the same thing as invoking tlbimp at the command line to create QuartzTypeLib.dll (as shown below).
To build and run the COM Interop Part 1 samples from the Command Line
Use the Change Directory command to change to the Interop1 directory.
Type the following:
tlbimp %windir%\system32\quartz.dll /out:QuartzTypeLib.dll csc /r:QuartzTypeLib.dll interop1.cs interop1 %windir%\clock.avi
Use the Change Directory command to change to the Interop2 directory.
Type the following:
csc interop2.cs interop2 %windir%\clock.avi