Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从托管代码调用本机API_C#_.net_Compact Framework_Windows Mobile 6 - Fatal编程技术网

C# 从托管代码调用本机API

C# 从托管代码调用本机API,c#,.net,compact-framework,windows-mobile-6,C#,.net,Compact Framework,Windows Mobile 6,我正在使用WM6 SDK开发一个Windows Mobile应用程序。该应用程序是一个托管代码(使用C#)&我想知道调用本机函数需要采取的步骤 谢谢你的帮助, Abdel Olakara您需要首先使用将本机API声明为静态外部,然后像普通方法一样使用它们。例如: [DllImport("user32.dll", ExactSpelling = true)] internal static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nID

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

谢谢你的帮助,
Abdel Olakara

您需要首先使用将本机API声明为静态外部,然后像普通方法一样使用它们。例如:

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


应该可以了。

谢谢,我不知道这个网站。。能够获得我所需要的详细信息。这是一个很好的例子——但如果它是为Windows Mobile设计的话会更好。与桌面不同,大多数API将在一个名为coredll.dll的dll中找到,因此上面的示例实际上会在Windows Mobile设备上引发一个异常,声明找不到user32.dll。