Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 20 AUG 2008 12:56:10PM Bruce Cameron wrote:

I am trying to use a 3rd party dll with OI 8.0.3.

The DLL was written in Visual Basic (VB), not sure of the version but guess 5.0 or 6.0.

I have registered the Dll and dropped it into my revboot directory.

I have validated that it can been seen with the IsLib() function.

I created my prototype with the DLL_ prefix and added the dll name on row .

There is a .bas file defining the function as …

Declare Function MyConnection Lib "MyClient.dll" (ByVal Host As String, ByVal Port As Integer, ByVal UserName As String, ByVal Password As String, ByVal Account As String) As Boolean

I have tried several variations of the Prototype line

INT STDCALL MyConnection(LPASTR,INT,LPASTR,LPASTR,LPASTR)

by changing the data types as well as the return type and call.

I know that the VB function was written using BSTR pointers.

I am talking to the function as I can get back error messages with anthor function in the dll but I seem to be passing the incorrect pointer(s) types.

Any help or information is appreciated.


At 20 AUG 2008 02:02PM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:

So it returns a Boolean?

The Sprezzatura Group

World leaders in all things RevSoft


At 20 AUG 2008 02:49PM Bruce Cameron wrote:

That's what the .bas states.

Zero for false, one for true if succesful.

It is attempting to connect to a remote with the args Host,Port (uses 4243 - telnet default), windows username, pwd.

The response I have gotten has always been zero (0) so far and

a read of the myerrors() function usually states "Invalid User Name" although playing around with the types I can get it to (a) crash OI (b) non-numeric value © "Invalid Host".

Is there a difference in using a Long Pointer type with the char(0) imbedded verses passing a char(0) concatenated with the arg?


At 20 AUG 2008 02:56PM Sean FitzSimons wrote:

Bruce,

I think Sprezzatura was asking a leading question. If it returns a Boolean should the return value be an INT? Have you tried LPCHAR?

Sean


At 20 AUG 2008 03:07PM Bruce Cameron wrote:

Sean, thanks I am asking about *all of the above* really.

Honestly I am not completly sure what the return value type should be, I've tried several and get a zero (0) and the "Invalid" msg.

Also, I am not sure of the correct calling convention either.

The OI help only lists CDECL and PASCAL and I have tried those with no difference.

Maybe that is another question. Is the calling convention tied in with the parameter type(s)?


At 20 AUG 2008 04:42PM [url=http://www.srpcs.com]SRP[/url]'s Kevin Fournier wrote:

Bruce,

I think you guys might be talking past each other. As I understand it, the DLL your using requires BSTRs passed into the parameters. You've tried prototyping your parameters as LPASTRs and others with no success. So, your question is (and I'm curious to know the answer myself) is whether or not OI supports a BSTR parameter for passing OI strings into BSTR parameters. My guess is no.

However, this can possibly be done. A BSTR is essentially a zero terminated Unicode string prepended with 4 bytes of length information. If we can at least get you to the point that you can convert your OI variables into BSTR equivalents, then we can use GetPointer to pass your BSTR pointer to the DLL.

You could start by looking into the AllocSysString and FreeSysString WinAPI calls, which you'd have to prototype of course. You should be able to google these. Alternatively, it should be possible to create BSTR strings in pure BASIC+ code using Str_Unicode and prepending the necessary 4 bytes.

Once you are ready to pass BSTR pointers, you'd prototype your DLL as follows:

INT STDCALL MyConnection(ULONG, INT, ULONG, ULONG, ULONG)

Does this sound like I understand your delimma?

[email protected]

SRP Computer Solutions, Inc.


At 20 AUG 2008 05:02PM Bruce Cameron wrote:

Kevin,

Yes, that is exactly correct!

I have tried different types in my prototype then in my code have tried using getPointer() function with no success.

I have tried both

myHost=127.0.0.1" ; lockvariable myHost as Char

And

myHost=127.0.0.1":\00\ ; lockvariable myHost as Char

( also tried different VARIABLE_TYPE(s) )

I wasn't aware that OI may not support BSTR parameters. (And my knowledge of pointers is very limited).

I will google that which you speak of, thanks!


At 20 AUG 2008 05:30PM Bruce Cameron wrote:

Kevin,

If this is the definition of BSTR http://msdn.microsoft.com/en-us/library/ms221069.aspx is it possible to easily create the string manually then set it in the memory and pass the pointer?

For example, if Param1=localhost" could we calculate and build the BSTR based on the information in the link above?

It states that the pointer would point to the beginning of the string in memory. The string would begin with a 4-byte integer value for the length of the string (in this case "localhost") then the string in Unicode then be terminated by null:null (not included in the length).

If so then I assume I could… ??/

Param1=int:string:\00\:\00\

LockVariable Param1 as Char

xParam1=getPointer(Param1)

Call Myconnection(Param1,….

UnlockVariable Param1


At 20 AUG 2008 06:52PM Colin Rule wrote:

Bruce

You probably already know this but be sure to run the DECLARE_FCNS on SYSPROG and not on your application. Also if you have run it on your applicaton you may need to delete the items created from your app before the SYSPROG ones will be picked up.

Colin


At 20 AUG 2008 07:52PM Bruce Cameron wrote:

Thanks Colin.

I've actually been testing/working in SYSPROG exclusively.

Also, I did discover that if I make a change to the DLL_ prototype

I need to re-run the Declare_fcns and then logoff and back in

to get the updated prototype.


At 20 AUG 2008 08:09PM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:

Bruce,

You don't necessarily need to log out of OI to make DLL prototype changes stick. You just need to knock the object code off the program stack to make sure it's reloaded from SYSOBJ next time it's executed (the Basic+ compiler does this for you for "normal" programs…)

Two ways to do this:

1) Issue a GarbageCollect call

2) Use RTP27 to load your program - e.g. RUN RTP27 "MYCONNECT"

The Sprezzatura Group

World leaders in all things RevSoft


At 21 AUG 2008 12:00AM Bruce Cameron wrote:

Interesting, thanks. Maybe a naive question but does it make a difference doing RUN RTPXX XXXX from the sysed vs. sysmon ?


At 21 AUG 2008 09:25AM Carl Pates wrote:

Not really - but the System Monitor runs in "event context" so you can use get_property and set_property with it.


At 21 AUG 2008 06:13PM Bruce Cameron wrote:

Carl,

Thanks. FYI, I did get this working but not using the VB dll and BSTR's although I would like to know why/how sometime.

It would seem that nailing down a consistent way to convert the strings and putting in memory in the correct manner would be helpful to all.

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/521f46521b7d0805852574ab005d08be.txt
  • Last modified: 2023/12/30 11:57
  • by 127.0.0.1