C/C++ code:
//这是在.h头文件中定义的
struct _TestStruct;
typedef struct _TestStruct TestStruct;
//这是在.cpp文件中定义的
typedef struct _TestStruct
{
TestStruct1 struct1;
TestStruct2 struct2;
}TestStruct;
__declspec(dllexport) TestStruct* __stdcall Init()
{
return init();
}
__declspec(dllexport) BOOL __stdcall Update_Info(intptr_t* struct, char* key, char* value)
{
return update_info((TestStruct*)struct, key, value);
}
//释放
__declspec(dllexport) void __stdcall Free_Struct(intptr_t struct)
{
return free_struct((TestStruct*)struct);
}
C# code:
[DllImport("Test.dll")]
public static extern IntPtr Init();
[DllImport("Test.dll")]
public static extern bool Update_Info(IntPtr struct, String key, String value);
[DllImport("Test.dll")]
public static extern void Free_Struct(IntPtr struct);
因为不需要公开,所以在头文件中定义的结构,在.cpp文件中实现结构。
现在问题是C#要调用dll中这几个函数,运行全部通过,但是带不出值,
请大家帮帮忙,急啊......
在线等,如果解决,必定加分答谢!~
问题自己解决了,不好意思,忘了及时上来结贴。
谢谢1楼2楼两位。
问题出在我内部指针传递有错....
使用ACCESS最大的隐患就是不安全。今天对ACCESS数据库设置了一个密码,必须使用密码才能打开,但是在程序中却无法连接数据库了。大家知道使用用户名和密码,如何连接ACCESS数据库?貌似ACCESS的用户名还不知道?只知 ......
希望给大家提供一些新的思路.
我们在使用C编程时会遇到一个问题,比如头文件的一个函数包含在一个lib 中,但是
在实际连接中我们不知道它在哪个库中。也许可行的一种办法是直接上网查询某个
函数的依赖条件,这对 ......