.net 2003 调用c++.dll

myminimouse 2009-06-04 11:18:56
头文件

#ifdef a
#define b_API __declspec(dllexport)
#else
#define b_API __declspec(dllimport)
#endif

extern "C"
{

b_API int __stdcall ZlibCompress(unsigned char **compr, unsigned long *comprLen, unsigned char *uncompr, unsigned long uncomprLen);

b_API int __stdcall ZlibUncompress(unsigned char *compr, unsigned long comprLen, unsigned char **uncompr, unsigned long *uncomprLen);

}

请大家帮忙,谢谢了
...全文
107 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
soaringbird 2009-08-08
  • 打赏
  • 举报
回复
unsigned char ** ----byte**
unsigned char * -----byte*
unsigned long * -----uint* 或者 ref uint

[DllImport("xxxx.dll",CallingConvention=CallingConvention.StdCall)]
myminimouse 2009-06-10
  • 打赏
  • 举报
回复
#ifdef GPSSUPPORT_EXPORTS
#define GPSSUPPORT_API __declspec(dllexport)
#else
#define GPSSUPPORT_API __declspec(dllimport)
#endif



extern "C"
{

GPSSUPPORT_API int __stdcall ZlibCompress(unsigned char **compr, unsigned long *comprLen, unsigned char *uncompr, unsigned long uncomprLen);

GPSSUPPORT_API int __stdcall ZlibUncompress(unsigned char *compr, unsigned long comprLen, unsigned char **uncompr, unsigned long *uncomprLen);
}

整个代码就是这样的
myminimouse 2009-06-10
  • 打赏
  • 举报
回复
还是不行。。。
ChrisAK 2009-06-04
  • 打赏
  • 举报
回复
没dll名,
没参数说明...
只能靠猜的写一下了:

unsafe static extern int ZlibCompress(out byte* compr,ref uint comprLen, byte[] uncompr, uint uncomprLen);
unsafe static extern int ZlibUncompress(byte[] compr, uint comprLen, out byte *uncompr, ref uint uncomprLen);

LZ自己把DllImport补下.
另外如果不能用unsafe只要把byte*换成IntPtr改用Marshal操作指针就行了.
bell49 2009-06-04
  • 打赏
  • 举报
回复
使用unsafe
zcandyly20211 2009-06-04
  • 打赏
  • 举报
回复
友情up!
ChrisAK 2009-06-04
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 cnzdgs 的回复:]
unsigned char **这种类型一般只在返回指针时才使用,数据压缩应该是不需要返回指针的,该不会是多写了个*吧?
[/Quote]说不定.如果它是被调用方来分配内存的话就可能是unsigned char **了
cnzdgs 2009-06-04
  • 打赏
  • 举报
回复
unsigned char **这种类型一般只在返回指针时才使用,数据压缩应该是不需要返回指针的,该不会是多写了个*吧?
myminimouse 2009-06-04
  • 打赏
  • 举报
回复
我先试一下
谢谢ChrisAK
wujinjian2008n 2009-06-04
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 li365941471 的回复:]
bang ding
[/Quote]

2
problc 2009-06-04
  • 打赏
  • 举报
回复
平台调用吧 P/Invoke...
sportTony 2009-06-04
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 li365941471 的回复:]
bang ding
[/Quote]
1
li365941471 2009-06-04
  • 打赏
  • 举报
回复
bang ding
zenowolf 2009-06-04
  • 打赏
  • 举报
回复
Marshal 下有很多类 可以参照下。。。

110,538

社区成员

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

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

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