从DLL获取多个结果 [英] Getting multiple results from a DLL

查看:57
本文介绍了从DLL获取多个结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个新手问题.我有一个正在使用的第三方DLL.我正在DLL中使用其他功能正常的函数,但它们仅返回一个数字,指示其是否有效.它们还有另一个函数,应该从该函数中获取多个结果,但是我不确定如何检索它们.这是有关该功能的文档.每当我尝试调用该函数时,我的程序都会崩溃.如果我打电话给第三方,他们基本上会说这是VB问题,他们不能支持它.有任何想法吗.

int queryActiveClients(char * returnInfo,int * rtnInfoLength);

返回客户端上当前已注册(即正在运行)的环境的列表.

参数:
缓冲区以保存返回信息
指向缓冲区长度的指针

返回:
如果成功,则为0
如果客户端未运行,则为-1
-2如果应用程序无效(不允许发送命令)
-3,如果缓冲区太小而无法保存返回信息.在这种情况下,rtnInfoLength包含所需的缓冲区大小,而returnInfo包含空字符串.
-4如果命令不正确(语法或语义)

This is a newbie question. I have a third party DLL that I''m working with. I''m using other functions inside the DLL that are working fine but they are only returning a number indicating whether it worked or not. They have another function that should get multiple results from the function but I''m not sure how to retrieve them. Here is the documentation on the function. Whenever I try to call the function my program blows up. And if I call the third party they basically say that it''s a VB problem and they can''t support it. Any ideas.

int queryActiveClients(char *returnInfo, int *rtnInfoLength);

Return a list of the environments that are currently registered (i.e. running) on the Client.

Parms:
Buffer to hold the return information
Pointer to the length of the buffer

Returns:
0 if successful
-1 if Client is not running
-2 if application is invalid (not allowed to send commands)
-3 if buffer is too small to hold return info.  In this case, rtnInfoLength contains the buffer size needed, and returnInfo contains an empty string.
-4 if command is incorrect (syntax or semantics)

推荐答案

该函数应返回正在运行的客户端的活动列表,因为可能存在多个.我有一种感觉,我错误地声明了该函数,但是由于我是vb.net的新手,所以我不确定如何返回多个结果,但是到目前为止,我已经取得了很多进展.

我收到以下错误:

尝试读取或写入受保护的内存.这通常表明其他内存已损坏.

这是我试图用来调用函数的代码
The function should return the active list of clients running as there could be multiples. I have a feeling I''m declaring the Function incorrectly but I''m not sure how to return multiple results as I''m a total newbie to vb.net but I''ve made a ton of progress so far.

I get the following error:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Here is the code i''m trying to use to call the function
Dim Hostname As String
Dim bufferlength As Integer
Hostname = " "
bufferlength = 0
rtnVal = queryActiveClients(Hostname, bufferlength)


这是我声明DLL函数的地方.

声明函数queryActiveClients Lib"p2mpi01"(ByVal主机名作为字符串,ByVal缓冲区长度作为整数)作为整数


Here is where I declared the DLL function.

Declare Function queryActiveClients Lib "p2mpi01" (ByVal hostName As String, ByVal bufferlength As Integer) As Integer


我假设您在询问问题之前尝试使用Google搜索.无论如何,以防万一,请尝试 [ ^ ](如果它对您有用).它为您提供有关在VS上调整某些设置的说明.如果不是,那么您可以尝试
I assume you tried googling your problem before asking the question here. Anyway, incase not, try this[^] if it works for you. It gives you instructions on tweaking some settings on your VS. If not, then you can try this[^].


这篇关于从DLL获取多个结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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