HighTechTalks DotNet Forums  

Marshaling question

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss Marshaling question in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Markward Schubert
 
Posts: n/a

Default Marshaling question - 04-24-2007 , 12:44 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/TheO...%20LotusScript

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







Reply With Quote
  #2  
Old   
Markward Schubert
 
Posts: n/a

Default Re: Marshaling question - 04-25-2007 , 11:48 AM






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

Reply With Quote
  #3  
Old   
Markward Schubert
 
Posts: n/a

Default Re: Marshaling question - 04-25-2007 , 11:50 AM



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

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.