windows ce 调用DLL的问题

tzszk 2011-01-18 03:03:47
有个C++的DLL,函数原型:
int WINAPI GenBarCode(char * barcode, DWORD Id,DWORD cjm,DWORD wsm,DWORD slm,DWORD xhm);

在WIN32下的声明:
public static extern int GenBarCode([MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder s, UInt32 Id, UInt32 cjm, UInt32 wsm, UInt32 slm, UInt32 xhm);
在win32下成功调用

转到windows ce
声明和wind32下一样,但怎么也不行,我想可能是字符集的问题,但不知道怎么解决,请赐教
...全文
268 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
colorall 2011-01-19
  • 打赏
  • 举报
回复
先弄清楚 你这个Dll是否支持CE平台?
xingyuebuyu 2011-01-19
  • 打赏
  • 举报
回复
public static extern int GenBarCode(IntPtr buff, UInt32 Id, UInt32 cjm, UInt32 wsm, UInt32 slm, UInt32 xhm);

int len=100;
byte[] bytes=new byte[len];
IntPtr hglobal = Marshal.AllocHGlobal(len);
GenBarCode(hglobal,...);
Marshal.Copy(hglobal,bytes,0,bytes.Length);
string s=System.Text.Encoding.ASCII.GetString(bytes);
Marshal.FreeHGlobal(hglobal);

这个改下声明试试,申请一段缓冲区,然后看调用结果

wuyq11 2011-01-19
  • 打赏
  • 举报
回复
dll是不是选错平台了
Wince是一个Unicode系统。
mjp1234airen4385 2011-01-19
  • 打赏
  • 举报
回复
是CPU型号的问题吧。
你的winCE系统硬件CPU是X86架构的吗?
你的动态库是X86架构的,所有在win32下就可以运行。
但是wince系统CPU架构不是X86的,当然就不行了。
如果你想运行的话,就需要找个支持你的cpu型号的动态库了。
「已注销」 2011-01-19
  • 打赏
  • 举报
回复
可能是你在CE下用宽字符,32下用了多字节的原因,你检查下是不是这个问题.
如果是这个原因的话,你试试改声明为public static extern int GenBarCode([MarshalAs(UnmanagedType.LPTStr)] System.Text.StringBuilder s, UInt32 Id, UInt32 cjm, UInt32 wsm, UInt32 slm, UInt32 xhm);
tzszk 2011-01-18
  • 打赏
  • 举报
回复
请问1楼?后面加一个W是什么意思?
flyerwing 2011-01-18
  • 打赏
  • 举报
回复
GenBarCodeW()

110,556

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧