步骤来创建使用C++为Windows Mobile的DLL:
1)文件>新建>项目...>的Visual C++>智能设备> Win32的智能设备项目
2)写的名字该项目并单击确定。
3)下一步>插入需要
4)右键点击Source文件夹的SDK(如WM5和WM6)>下一页>点击DLL>完成,然后选择添加>新
5)查找.DEF文件名称与dll名称相同,然后单击确定。
现在高清你需要写这样的事:
LIBRARY "dllName"
EXPORTS
exactFunctionName1 DATA
exactFunctionName2 DATA
In dllName.cpp You need to add those two methods (exactFunctionName1, exactFunctionName2) and write code for them.
You don't need to state more then a method names in def (plus <tab><tab>DATA next to name).
Where to place the DLL after builiding to make use of it in my C# project
It must be placed next to Your app or in Windows folder of Your device.
To get methods from that library just do the following in C#:
using System.Runtime.InteropServices;
[DllImport("dllName.dll")]
private static extern anyReturnType exactFunctionName1(anyArgumentType argumentName);
So as an example let's get arithmethic sum form myMath.dll:
[DllImport("myMath.dll")]
private static extern int sum(int first, int second);
Those methods can be also public but they still require "static extern".
Following example in C++ side You'll have this:
In myMath.cpp:
INT sum(INT first, INT second)
{
return first + second;
}
In myMath.def:
LIBRARY "myMath"
EXPORTS
sum DATA
来源:
http://social.msdn.microsoft.com/Forums/en-US/windowsmobiledev/thread/98e60ab6-aecf-4399-a5be-4937ec40aac9
桌面不需要安装CF消耗CF组件。 CF组件可重定位并在完整框架下运行。 – ctacke 2009-11-25 16:16:46
谢谢ctacke。 – EKS 2009-11-26 09:05:24