您的位置:首页 > 编程语言 > C语言/C++

c#调用c++写成的dll文件,返回char*,返回数组,用ref接收,byte[]

2008-06-02 18:07 791 查看
// Inclusion guard
#ifndef _DLLTUT_DLL_H_
#define _DLLTUT_DLL_H_

// Make our life easier, if DLL_EXPORT is defined in a file then DECLDIR will do an export
// If it is not defined DECLDIR will do an import

#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif

// Specify "C" linkage to get rid of C++ name mangeling
extern "C"

// End the inclusion guard
#endif

起因是,我想让c++的同事给我一个读取硬件编号的函数,没有参数,返回值是编号,可是我的同事说返回string不规范,返回结果应该是true或者false,然后利用参数返回值,就是利用指针返回编号,他就写了一个方法,我找了一些方法试验了一下,下面这种可行,希望给大家一点提示吧。

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace ConsoleApplication30

记录一些有用的链接吧

/article/5137577.html

http://www.cnblogs.com/wy/articles/123656.html

http://dotnet.csdn.net/page/aab1def7-35a4-4a5f-bd18-c82879278b22

http://www.liuwu.net/post/how-to-passing-structures-and-classes-to-unmanaged-code.aspx

/article/5460252.html

http://www.blue1000.com/bkhtml/2007-12/55484.htm

http://www.cnblogs.com/songwin/articles/1329545.html

最近老是碰到问题啊,提示“无法加载 DLL“FUKeyDll.dll”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。”,

这个问题也被解决了,多半是因为FUKeyDll.dll调用了其他的dll文件,缺少了其他的dll文件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: