2009-11-24 103 views
0

我正在开发使用WM6 SDK的Windows Mobile应用程序。该应用程序是一个托管代码(使用C#)&我想知道为了调用本地函数而要采取的步骤。从托管代码调用本机API

感谢您的帮助, 阿卜杜勒Olakara

回答

3

http://www.pinvoke.net/

应该这样做。

+0

谢谢,我不知道这个网站..能够得到我需要的细节。 – 2009-11-24 08:07:48

-1

您需要使用DLLImport首先声明本机API为static extern和再利用他们像普通的方法。例如:

[DllImport("user32.dll", ExactSpelling = true)] 
    internal static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, int uElapse, IntPtr lpTimerFunc); 
+0

一个很好的例子 - 但如果它是为Windows Mobile设计的话会更好。与桌面不同,大多数API都可以在名为coredll.dll的单个dll中找到,因此上述示例实际上会在Windows Mobile设备上抛出异常,指出user32.dll无法找到。 – 2010-05-13 10:06:24

相关问题