Re: calling C/C++ DLL that takes a pointer to LPTSTR

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Sam,

Is lpFileNames written to? If not, then just pass it as an array. I
assume you would have to pass a null string at the end of the array, but
that should translate just fine.

Also, make sure you do not use long in C# when defining this function.
Use int (LONGs in C/C++ are 32 bit integers).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Sam Carleton" <scarleton-nospam@xxxxxxxxxxxxxxxx> wrote in message
news:4HXre.42390$XA6.31136@xxxxxxxxxxxxxxxxxxxxxxxxx
> The C definition is along the lines of:
>
> LONG SetFilenames( LONG nFiles, LPCSTR* lpFileNames);
>
> Where the lpFileNames is an array of LPCSTR's.
>
> The ultimate DLL that needs to be called is a 3rd party's module,
> but there is a C/C++ DLL which is a wrapper for the 3rd party
> module, this wrapper is called directly by C#. There does not
> appear that such a method signature can be called direct from C#.
> What tactic should be used to get a collection of strings from C#
> to the wrapper class? A fellow developer suggested that I define
> a struct in C# that simply contains a string. I know that it
> would work, but it is messy and I am looking for a more straight
> forward, cleaner approach. Any ideas?
>
> Sam


.



Relevant Pages

  • Re: calling C/C++ DLL that takes a pointer to LPTSTR
    ... > LONG SetFilenames(LONG nFiles, LPCSTR* lpFileNames); ... > Where the lpFileNames is an array of LPCSTR's. ... You can simply pass it as an array of string pointers, ...
    (microsoft.public.dotnet.languages.csharp)
  • Help in French|Spanish|German translation.
    ... I am also an author of User-defined string functions. ... WORDTRANEX (cSearched, cArExpressionSought | cExpressionSough, ... each string of the array is searched ... If the parameter nArStartOccurrence is -1 or omitted, the replacement starts ...
    (microsoft.public.fox.helpwanted)
  • Re: passing a string to a dll
    ... Joe, I really appreciate you taking the time to demonstrate this. ... sure how I would implement indexing it for random alphanumeric codes. ... I might handle the array. ... I actually have been wondering if I could use a second string ...
    (microsoft.public.vc.mfc)
  • Re: passing a string to a dll
    ... I might handle the array. ... I actually have been wondering if I could use a second string ... look at insertion cost, organization cost, and search cost. ...
    (microsoft.public.vc.mfc)
  • RE: Structure conversion from C++ to VB-2008?
    ... One of the most important structures is AmiVar structure. ... point number, the array of floating point numbers, a string or IDispatch ... Dim 13012679 as Integer ...
    (microsoft.public.dotnet.languages.vb)