On 9/5/06, Medha Kulkarni <medha_19 / yahoo.com> wrote: > 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. [disclaimer] I am not an expert on the Win32 API [/disclaimer] Your problem does not look like an argument problem. It is ruby telling you that the constant 'GetContentsStream' does not exist. I wonder what it is doing there. Perhaps you meant: val = getdllfun.Call(arrObj.pack("C*"),arrObj.size,sStreamName) Reading error messages can help you. Don't jump to conclusions. > -- > Posted via http://www.ruby-forum.com/. >