我如何通过一个数组(通过引用VB6)为C \ C ++的* .dll子程序? [英] How do I pass an Array (By Reference, in VB6) to a C\C++ *.dll subroutine?
问题描述
我需要通过变体的空数组以C语言编写的(和适用于所有Windows版本)一个DLL,而C code(这是我无法控制的,不能编辑)将填充空数组变体,其某些函数的返回值。
I need to pass an empty Array of Variants to a DLL written in C (and available on all Windows versions), and the C code (which I have no control over and cannot edit) will populate the Empty Array of Variants with its some return values.
Bascially,当我尝试这 - 的ByRef的数组总是空的,当它应该包含函数/子调用的结果(如果我在.NET中完全一样的东西,它的工作原理)
Bascially, when I try this - the ByRef Array is always empty when it should contain the results of the function/sub call (if I do the exact same thing in .NET, it works).
我想我需要做一个自定义的声明,使VB知道如何调用C函数,或?
I'm thinking I need to do a custom declaration so VB knows how to call the C function, or?
下面是如何在c子/函数声明。鉴于此,我需要什么做的,为了保证C是能够正常,我用我的空数组的燕鸥得到结果回来?
Here is how the C sub/function is declared. Given this, what do I need to do in order to ensure C is able to use my Empty Array properly and I in tern get my results back?
HRESULT InvokeAction(
[in] BSTR bstrActionName,
[in] VARIANT varInActionArgs,
[in, out] VARIANT *pvarOutActionArgs,
[in, out] VARIANT *pvarRetVal
);
有关此功能的更多信息:的http:// MSDN .microsoft.com / EN-US /库/ aa382237(VS.85)的.aspx
感谢
推荐答案
从的 http://msdn.microsoft.com/en-us/library/aa381230(VS.85)的.aspx :
Dim returnVal
Dim outArgs(1)
Dim args(1)
args(0) = 3
returnVal = service.InvokeAction("GetTrackInfo", args, outArgs)
'return Val now contains the track length
'and outArgs(0) contains the track title
Dim emptyArgs(0)
returnVal = service.InvokeAction("Play", emptyArgs, emptyArgs)
'returnVal indicates if the action was successful
您究竟获得和服务的实例是不是从这个例子虽然。
Just how you get and instance of service is not clear from this example though.
这篇关于我如何通过一个数组(通过引用VB6)为C \ C ++的* .dll子程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!