在这种情况下该怎么办 [英] What to do in this situation

查看:73
本文介绍了在这种情况下该怎么办的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用C语言制作了一个DLL,然后将其添加到Visual Studio的VC ++项目中,这是我的DLL调用返回状态为成功"或错误是什么的方法.

我做了这样的事情

I made an DLL in C sharp and added to my VC++ project in visual studio,a method of my DLL on calling return the status as "success" or what the error is.

I did some thing like this

char *a=interfacepointer->DLL Function




我在变量"a"中获得了垃圾值.
当我通过C#代码对其进行检查时,输出如下所示:-

成功:-




I get the garbage value in variable "a".
When i check it through my C# code the output is like this :-

ON SUCCESS:-

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Success</string>



出现错误



ON ERROR

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Unknown database 'nhms_temp11'</string>





I should get the Value as "SUCESS" or "Unknown database 'nhms_temp11'"



我该怎么办?



What should i do?

推荐答案

因为char * a是指针,而不是变量.所谓的垃圾"是数据的内存地址.
为了查看该数据,您必须再次取消引用指针. 指针 [
Because char *a is a pointer, not a variable. The "garbage" as you call it is the memory address of your data.
In order to see that data you have to dereference your pointer again. Pointers[^]


这样做
BSTR s1=interfacepointer->DLL Function
std::wcout <<s1<<std::endl ;


这篇关于在这种情况下该怎么办的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆