[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Markward Schubert

4/24/2007 4:44:00 PM

Hi!

I would like to call a c-function with the following signature:

STATUS LNPUBLIC NSFDbOpen (const char far *PathName, DBHANDLE far *rethDB);

The paremeter PathName is the path to a Lotus Notes database. My PInvoke
declaration looks like this (VB.NET):

<DllImport("nnotes.dll")> Private Shared Function _
NSFDbOpen( _
ByVal PathName As String, _
ByRef rethDb As IntPtr _
) As UInteger
End Function

Calling this functin works fine for two pathes, that have no
special-characters like ä,ü etc in them. When calling it with a path
including an ü-character, i get an error, claiming, no file was found.

Additionally I found a blog where someone solved the problem by changing his
(non-.NET)-VB-Code like this:

Declare Function W32_NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" ( Byval
dbName As Lmbcs String, hDb As Long) As Integer

LINK:
http://www.theoldgit.com/redloh/TheOldGit.nsf/archive?openview&type=Category&key=API%20calls%20in%20L...

He included the Lmbcs in the declaration and succeeded.
I don't know, what this means as I am not very fit in VB.

LMBCS is declared in the Notes C-API like this:

typedef unsigned char LMBCS;

My question is:
Can someone of you gather from the methods signature, how I have to modify
the Marshaling to correctly pass Strings including special characters beyong
ASCI, so that the C Api will be able to work with it?

Regards,
Markward






3 Answers

(Mattias Sjögren)

4/24/2007 10:03:00 PM

0


>Can someone of you gather from the methods signature, how I have to modify
>the Marshaling to correctly pass Strings including special characters beyong
>ASCI, so that the C Api will be able to work with it?

I don't think it's as simple as that. As far as I know, neither
Windows nor the CLR has any support for converting strings to the
LMBCS encoding. That means you either have to find a Lotus library
that does it for you or implement the conversion yourself (yuck).
After it's been does you can pass in the result as a byte array to the
C function.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.n... | http://www.dotneti...
Please reply only to the newsgroup.

Markward Schubert

4/25/2007 3:48:00 PM

0

Thanks a lot.

Finally i found a proper function in the Notes-C-API. It is called
NLS_translate(...) and was able to use this to convert the strings.

May be this might help others having the same problem

Bye

Markward Schubert

4/25/2007 3:50:00 PM

0

Hi!

Thanks for the help!

I found a function that does what I need:

NLS_STATUS LNPUBLIC NLS_translate(
BYTE far *pString,
WORD Len,
BYTE far *pStringTarget,
WORD far *pSize,
WORD ControlFlags,
NLS_PINFO pInfo);

It is part of the Notes C-API

Maybe this helps people having the same problem