Calling VB DLL from ruby code

M

Medha Kulkarni

I am facing a problem while calling a VB DLL (for which I do not have a
source code, just know the function signatures which DLL exposes) from a
ruby code.
DLL Function signature is as follows:

Public Declare Function GetContentsStream Lib
"C:\VisualCsource\SLStrucStorageContents\Debug\SSGetContents.dll" _
'(arg1 As Byte, _
' ByVal lElements As Long, _
' ByVal sStreamName As String) As Long
Following is the explanation given by DLL author regarding argument
types & how that DLL should be called:


lLen = GetContentsStream(arrayObj(0), UBound(arrayObj), sStreamName)


Parameter1: arrayObj is an array of Bytes. We pass the the first
element of the
array by Reference, arrayObj (0), which really means we are passing the
address of the
start of the array.
Parameter2: Ubound (arrayObj) is the length of the array.
Parameter3: Stream name of type string.

I have written following code to call this dll:

require ‘Win32API’
getdllfun = Win32API.new('C:\WINDOWS\system32\SSGetContents.dll',
“GetContentsStream", ['P','L','P'], 'L')
sStreamName = "CONTENTS"
arrayObj=New Array
## arrayObj stores some binary bitmap data
val=getdllfun.Call
(GetContentsStream.Call, arrObj.pack(“C*â€),arrObj.size,sStreamName)
puts "\n value: " + val.to_s


When I execute this code, I get following error while executing function
getdllgun.Call:

storeLOBData.rb:211: in `fgetContentsStream': uninitialized constant
GetContentsS
tream (NameError)

May be there is a problem with argument types which I am specifying
i.e. ['P','L','P'] & argument which I am passing to DLL.
Any help regarding mapping VB parameter types to Ruby would be really
appreciated.

Thanks and Regards,
Medha.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top