VB6 - 声明和调用与指针C DLL [英] VB6 - Declaring and calling C DLL with pointers

查看:146
本文介绍了VB6 - 声明和调用与指针C DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个旧的C DLL我使用Ruby中调用,但现在我需要从VB6调用它,我无法找出正确的方式来做到这一点。

I have an old C DLL I use to call from Ruby, but now I need to call it from VB6 and I can't figure out the correct way to do so.

下面是我所需要的功能头:

Here is the header for the function I need:

INT Decrunch(常量BYTE * SRC,BYTE * DEST,DWORD src_length)

* src为将由功能被解密的字节序列

*src is a sequence of bytes which will be decrypted by the function

* dest为其中将收到解密的数据的缓冲器。我可以调用函数与DEST = NULL,它将返回解密的数据的大小,这样我就可以使用它来创建具有正确大小的缓冲区。

*dest is a buffer which will recieve the decrypted data. I can call the function with dest=NULL and it will return the size of the decrypted data, so I can use it to create the buffer with the correct size.

我试着用src和dest作为字符串(像我在做的Ruby)宣布,但它不会起作用。我也试着将它们声明为字节,并通过为我指出一些教程的字节数组的第一个元素,但我觉得我没有正确地做到这一点。

I tried to declare it with both src and dest as Strings (like I do in Ruby) but it won't work. I've also tried to declare them as Byte and pass the first element of a byte array as I was pointed by some tutorials, but I think I didn't do it correctly.

有人可以帮助我?

感谢您!

推荐答案

空气code

Private Declare DecrunchGetLength Alias "Decrunch" Lib "somedll.DLL" (ByRef src As Byte, ByVal nullptr As Long, ByVal SrcLength As Long) As Long 

Private Declare Decrunch Alias "Decrunch" Lib "somedll.DLL" (ByRef src As Byte, ByRef dest As Byte, ByVal SrcLength As Long) As Long 

Dim destLen As Long
 Dim src(0 To 9) As Byte 
Dim dest() As Byte 

' get bytes into src somehow 

' get dest length 
destLen = DecrunchGetLen( src(0), 0, 10) 

ReDim dest(0 To destLen - 1) 
destLen = Decrunch( src(0), dest(0), 10) 

相关链接

  • Declare statement
  • Advanced calling C DLLs from VB5/VB6

这篇关于VB6 - 声明和调用与指针C DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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