Add COM and ActiveX Support in .Net Compact Framework Using Odyssey Software CFCOM (Chinese)
Andy sjöströmbusinessanyPlace.net
September 2003
Applies TO:
Microsoft® .NET Compact Framework 1.0 Microsoft Visual Studio® .NET 2003 Odyssey Software CFCOM 1.0 Microsoft Windows MobileTM -Based Pocket PC
Aawolf: This month, brought you a post on MSDN home page, reader evaluation of 7. Original text issued on September 8, 2003, and the topic is also a more concern to how to call COM and ActiveX components under CF. Therefore, the old wolf took out the time translation in the afternoon, hoping that everyone can understand the latest technology, and keep synchronization with it. But after all, the old wolf is a programmer rather than professional translators, and there is no more time to translate articles, so I hope everyone can read English information, and the translation of the old wolf is only referring to the reference. The original connection is as follows: http://msdn.microsoft.com/library/default.asp? URL = / library / en-us / dnppc2k3 / html / cfcom.asp
Summary: Learn in Visual C # If you add COM and ActiveX support to the .NET Compact Framework application. Also, how to use Macromedia Flash Player 6 for a Microsoft Windows Mobile-Based Pocket PC in the .NET Compact Framework application.
Background: The interoperability of COM and ActiveX is available in Full .NET Framework. Managed .NET Compact Framework code can use Platform Invoke (P / Invoke) to call non-managed code in the DLL, but support for COM and ActiveX in .NET Compact Framework is unavailable. ODYSSEY SOFTWARE CFCM as an intervention layer exposes COM objects and ActiveX controls to the .NET Compact Framework application, using a Memory Foot Print with only 30K.
Odyssey Software CFcom can transparently access controls (such as Windows Media Player) and objects (such as Pocket Outlook Object Model and AdoCE), and actually any third-party COM or ActiveX components. CFCOM can be licensed through Odyssey Software, although the code example in the article can be created in the code through the license key.
Download cfcom.exe from the Microsoft Download Center.
Contents
Introductionodyssey Software CFComcode Walk-Throughmacromedia Flash 6 Player for Pocket Pcflash AnyplaceFlash Anyplace Code Walk-ThroughconClusion
Introduction
No matter whether the size, .NET Compact Framework's namespace and class structure hierarchy and complete .NET Framework are very similar. Of course, because of the problem of volume and execution efficiency, some features of the .NET Framework are removed. One of them is COM intermingness. Many core modules for Microsoft® Windows® CE and Pocket PC are implemented as COM objects and ActiveX controls, such as connectivity, messages, communications, graphics, media, object storage, and personal information management (PIM). There are also many third-party COM and ActiveX controls being used on mobile devices, such as GPS, chart, security, and connectivity. Platform Invoke (P / Invoke) is stored in System.Runtime.InteropServices namespace, which can be used to call simple non-accomplished code functions. An example of a third-party effective provider is SAPPHIRE SOLUTIONS LTD (http://www.sapphire-solutions.co.uk/), using the existing .NET Compact Framework service is sufficient. SAPPHIRE SOLUTIONS Remote Access Service, CPP, and more via components and source code. The SAPPHIRE SOLUTIONS component is loaded into the .NET Compact Framework code example with Platform Invoke, making it earlier to start using these code. Calling more complex non-managed code functions requires a large number of complex codes, including more challenging areas, such as Marshalling. Developing COM packages often require a single function-based interface. Combining COM and ActiveX is challenging in managed code.
Odyssey Software CFCOM
Odyssey Software is not unfamiliar with the Windows CE developer community. Since 1996, they have played an important role in promoting enterprise mobile app development, and their products have Cefusion and Viaxml. The company continuously provides tools for mobile application development communities. This time they brought a conversion layer in the middle of COM and Compact Framework, which allows COM to expose an equivalent .NET interface. CFCOM is converted to COM and ActiveX to Compact Framework applications to provide a wide range of interoperability.
CFcom can be seen as a package that enables COM and .NET objects to run in the same application. A Compact Framework object is constrained in the managed memory when a COMMON LANGUAGE RUNTIME (CLR) is saved in non-accomplished memory. CFcom enables a transparent conversion layer that allows managed and non-accomplished components to interact: set or acquire attribute values, call methods, capture COM events, process advanced type conversion functions (AKA Marshalling) and from non-accomplished code The local .NET exception is generated in the abnormal event.
For developers, cfcom consists of three files:
· Odyssey.cfcom.dll contains CFCOM runtime.
· Odyssey.cfcom.design.dll provides the design period support for Visual Studio. This file is installed in the C: / Program Files / Microsoft Visual Studio .NET 2003 / CompactFrameworksDK / V1.0.5000 / Windows CE / Designer directory.
· ODYSSEY.CFCOM.1248.DLL is the runtime component of local (device support).
Figure 1 shows that the COMOBJECT and COMCONTROL tools are added to Toolbox.
Figure 1. COMOBJECT AND COMCONTROL Tools Added to the Toolboxodyssey Software also includes an example Windows Media Player Wrapper Designer, developers can add to Toolbox and set attribute values during the design period. Compact Framework applications using Windows Media Player can be created quickly.
For Embedded Visual Basic developers, cfcom means they can use familiar COM objects and ActiveX components without learning C / C and P / Invoke. Embedded Visual C Developers can continue to use C to write the performance-critical section of their application without creating a local package and use Custom Marshalling.
ODYSSEY SOFTWARE CFCOM, you can read Microsoft Case Study, COM Interop Library Gives Compact Framework Applications Easy Access To CoM Components and Activex Controls.
Code Walk-Through
The design idea of CFCOM is to achieve transparent conversion. Just do two things before using the ActVIEX control or COM object.
· ActiveX control or progid or CLSID of the COM object.
· License Key from the CFcom obtained from ODYSSEY SOFTWARE.
After that, you can start using the CFCM's call method to use the components. The following code shows how to use Windows Media Player in a Compact Framework application.
License Key is set at the main function entry of the application.
COMOBJECT.ADDLICENSE (CFcom_LicenseKey);
One-form application can start using Windows Media Player.
Public Class frmmain: System.Windows.Forms.form
{
Private const string cfcom_licensekey = "xxxxxxxxxxxxxxxxxxxxxxxx";
Public frmmain ()
{
InitializationComponent ();
mpc.progid = "wmpceocx.wmp";
Mpc.invoke ("ShowControls", Invokeflags.SetProperty, False);
Mpc.invoke ("ShowaudioControls", Invokeflags.SetProperty, False);
Mpc.invoke ("ShowPositionControls", Invokeflags.SetProperty, False);
Mpc.invoke ("ShowTracker", Invokeflags.SetProperty, False);
Mpc.invoke ("ShowStatusbar", Invokeflags.SetProperty, true);
Mpc.invoke ("AutoStart", Invokeflags.SetProperty, True;
Mpc.invoke ("FileName", Invokeflags.SetProperty, "http://news.com.com/1604-2-966406-1.asx?msft_aw win"" MPC.INVOKE ("sendMouseClicKevents ", Invokeflags.SetProperty TRUE);
Mpc.comObject.comEvent = new comventhandler (mpc_comevent);
}
Note How to set up ProgID and how to set properties through the Invoke method. Invokeflags Enumeration includes SetProperty, GetProperty, and CallMethod.
For more information on these codes and how to add multimedia information in the Compact Framework application, "Play Media with .NET CF USING CFCOM" http://www.businessanyPlace.net/?p=cfcommedia.
Figure 2 shows the application using Windows Media Player ActiveX.
Figure 2. Windows Media Player Active X Control
Macromedia Flash 6 Player for Pocket PC
Macromedia has exited the free Pocket PC player playing the Macromedia Flash content. Flash is a popular platform for publishing High Profile Content, Movies, can even be used for mobile applications. The Flash development group is active and growing. Based on Visual Studio .Net and the Compact Framework, developers use Flash in mobile applications to easily create singular content and applications. Pocket PC Player's personal version can be found on the Macromedia Web server: http://www.macromedia.com/software/flashplayer/pocketpc/2002.html.
The player is an ActiveX control, mostly in Pocket Internet Explorer, physically as Flash.dll is installed in the / windows / macromedia directory. Once the player is installed, the user can watch the Macromedia Flash content via Pocket Internet Explorer. One way is to place a flash content file (.swf) and HTML files in the same directory and open the HTML file. This HTML file shows how the ActiveX control is called. The following fragments are from the HTML file:
HEAD>