Using COM Objects in Code

When you have an instance of the ActiveX control, or of a type library, you can access its members like any other .NET object, thus invoking methods, assigning properties, or handling events. For example the following code assigns the URL property of the media player with a media file to start playing:

image

You can also handle events if available, as demonstrated by the following code snippet:

image

In this particular case the MediaError event is raised when an error occurs in playing the media file. At a more general level, notice ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.