From: Medha Kulkarni Date: 2006-09-06T00:31:16+09:00 Subject: Calling VB DLL from ruby code 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. -- Posted via http://www.ruby-forum.com/.