fIguRE 9-6:
The AxImp tells you that it has generated the two DLLs needed for a control.
Exploring the Windows Media Player Interop DLL
When working with imported Python modules, you use the
dir()
function to see what those
modules contain. In fact, you often use
dir()
when working with .NET assemblies as well, even
though you have the MSDN documentation at hand. Theoretically, you can also use
dir()
when
working with imported COM components as well, but things turn quite messy when you do. The
“Using the Windows Media Player Interop DLL” section of this chapter describes how to import
and use an interop assembly, but for now, let’s just look at WMPLib.DLL using
dir()
. Figure 9-7
shows typical results.
fIguRE 9-7:
Using dir() won’t work well with interop assemblies in many cases.
548592c09.indd 172
2/24/10 12:48:19 PM
www.finebook.ir
Defining an Interop DLL
❘
173
The list goes on and on. Unfortunately, this is only the top level. You still need to drill down into
the interop assembly, so things can become confusing and complex. Figuring out what you want to
use is nearly impossible. Making things worse is the fact that any documentation you obtain for the
interop assembly probably won’t work because the documentation will take the COM perspective
of working with the classes and you need the IronPython perspective. Using
dir()
won’t be very
helpful in this situation.
Fortunately, you have another alternative in the form of the Intermediate Language Disassembler
(ILDasm) utility. This utility looks into the interop assembly and creates a graphic picture of it
for you. Using this utility, you can easily drill down into the interop assembly and, with the help
of the COM documentation, normally figure out how to work with the COM component — even
complex COM components such as the Windows Media Player.
To gain access to ILDasm, you use the same process you use for TLbImp to create a Visual Studio
Command Prompt. At the command prompt, type
ILDasm WMPLib.DLL
and press Enter (see more
of the command line options in the “Using the ILDasm Command Line” section of the chapter). The
ILDasm utility will start and show entries similar to those shown in Figure 9-8.
ILDasm is an important tool for the IronPython developer who wants to work with COM. With this in
mind, the following sections provide a good overview of ILDasm and many of its usage details. Most
important, these sections describe how to delve into the innermost parts of any interop assembly.
fIguRE 9-8:
Use ILDASM to explore WMPLib.DLL.
548592c09.indd 173
2/24/10 12:48:19 PM
www.finebook.ir
Do'stlaringiz bilan baham: |