Because I received no answer, I assume that either no one knows, or no
one cares. Just in case someone does care, however...
I wrote a DLL that accepts a string.
I can create a string in OOo containing null characters. For example:
"ABC\0\0D"
The DLL receives only ABC and on return, the string has been changed to
only be ABC. Thats life, deal with it.
OK, so I did deal with it. I now encode my strings in HEX as:
414243000044
In my DLL, which acts as a wrapper, I convert it back to the desired
string and call the destination DLL. I then encode the returned string
back into HEX, and send that back to OOo... Life is good!
OOo accepts "Dim x As String*3", but this declares a normal string, not
a string with fixed length.
Andrew Douglas Pitonyak wrote:
Using OOo 2.3 on Windows, I need to call a DLL from StarBasic.
The argument to the DLL is a simple array of characters. Consider a
super simple example:
Type FOO1TYPE
Dim name1 As String * 10
Dim rank1 As String * 10
End Type
Type FOO2TYPE
Dim name2 As String * 10
Dim rank2 As String * 10
Dim foo As FOO1TYPE
End Type
Normally, I would declare my DLL call similar to
Declare Sub MethodName Lib "wow.dll" (arg As FOO2TYPE)
Although I can do this from VB, I have many problems with this in
StarBasic. To avoid the issues, I created a string with 40 characters
in to, and tried to make a call using a string. I did not use this
code, it is simple and not efficient.
Declare Sub MethodName Lib "wow.dll" (arg As String)
Dim i As Integer
Dim s As String
For i = 1 To 40
s = s & Chr(0)
Next
Mid(s, 1, 5, "12345")
Mid(s, 10, 3, "123")
If I inspect my string, things look as I expect, but as soon as I make
a call, things change.
MethodName s
Now, if I inspect the string, the string length is 5 rather than 40. I
assume that this is related to the way that the string is converted
and sent around. I do not know what string value makes it to the DLL.
My next thought was that I could avoid this problem all together by
creating an array of type Byte.
Declare Sub MethodName Lib "wow.dll" (arg(0 To 39) As Byte)
This does not seem to work.
I am considering writing a Calc-Addon so that I can hide the DLL call
in C++. Any help is appreciated.
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info: http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]