Search Wiki:
Resource Page Description
Even though the .NET Compact Framework contains a lot of functionality, there are situations where you need to make use of native Win32 APIs in order to get your job done. Calling native APIs from inside a managed application is known as P/Invoke.

On this Code Gallery page you will find the accompanying sample code of the webcast titled 24 Hours of Windows Mobile Application Development: Interoperability between managed and native code.

The first sample available in the downloadable Visual Studio 2008 solution, called SimplePInvoke shows you how you can call out to PowerPolicyNotify API to put your Windows Mobile 6 Professional Device into Suspend mode. PowerPolicyNotify accepts two value types as parameters and returns another value type.

The second sample, called AdvancedPInvoke is a little more complex. This sample shows you how to P/Invoke to the EnumWindows API that expects a callback function as one of its parameters. This effectively means that we are calling native code from inside managed code, but that the native API calls back into managed code as well. This functionality is supported in the .NET Compact Framework 2.0 or higher.

The last sample shows you the support for COM Interoperability inside a managed smart device application. The project CalculatorAppV2 makes use of an existing COM Object (that also ships as part of the sample code) and shows you how to call methods on the COM Object and how the COM Object can call back into managed code. This functionality is supported in the .NET Compact Framework 2.0 or higher.

For more information about interoperability between managed code and native code on Windows Mobile Devices, you can take a look at Webcast in which we showed this sample code. This Webcast is currently available for on-demand viewing.
Last edited Dec 3 2008 at 1:02 PM  by Maarten_MVP, version 2
Updating...
Page view tracker