Re: Can I call a dll with a C++ Class Cstring variable?



Nils Gokemeijer wrote:So,
 
we bought an optiphase interferometer, and it comes with a dll and with LabVIEW example code.
However, there is a big problem!
The dll is a C++ dll and requires the C++ Cstring class!
 
for example I can't get the function Boolean LoadDemodulatorDSPCore(Cstring arg1, U8Bit arg2) to work.
 
They did provide a GetDllVersionchar(Cstr arg1, long arg2) which does work, (offcourse, it uses a standard C string pointer)
but GetDllVersion(Cstring arg1) does not work. (offcourse not, it using the Cstring class)
 
Is there a way to get CString classes to work in LabVIEW? (with a struct, or an binary array or whatever?)
Or do I have to write a wrapper dll to convert CString classes to standard C string pointers?
 
Thanks.I'm afraid this won't really be
possible without a wrapper DLL. A CString is more like an object with
internal pointers and last time I checked into a DLL with a
disassembler it seemed that the actual layout of the internal structure
depends on the size of the string that is contained, with small strings
being entirely embedded and larger strings being a pointer to the
string. Trying to figure out these difficulties is something you should
leave to compiler developers and not try to do yourself.

One way that might be possible is to actually only create three or four
C functions that are exported by a helper DLL. These functions would
allocate a CString, copy a CStr into it and out of it and one to
deallocate it. As far as LabVIEW is concerned you would treat the
CString simply as a uInt32.

Rolf Kalbermatter
.



Relevant Pages

  • Re: passing a string to a dll
    ... Should I avoid C++ as much as possible inside the DLL? ... If you want to build an MFC extension DLL, I think that passing CString ... exported CString built in ANSI into an exe built in Unicode, ... or other string classes *inside* the DLL implementation. ...
    (microsoft.public.vc.mfc)
  • Pls help
    ... I have a C++ program that is giving me a CString type of data. ... I need to access that C# dll that accepts a String parameter in the C++ ... private string _property1; ...
    (microsoft.public.dotnet.general)
  • Re: passing a string to a dll
    ... I have, for now at least, chosen to use CString& in both the dll and the ... // DLLRect.h: ... Is the example you are using EXACTLY using the string "12345" or is it ...
    (microsoft.public.vc.mfc)
  • Re: Labview Call Library Node (DLL) Exception
    ... String pointer and printed a dialogue box with the contents of the ... if I try to modify the string in the DLL by changing characters in the ... //as well as changing the last null character to a real char ...
    (comp.lang.labview)
  • Re: Labview Call Library Node (DLL) Exception
    ... of whether we use a string constant or a path control converted to a string, ... your DLL is taking in a cstring input and doing something with it.  The something here is very unclear to me (I ... different data depending on whether or not a user has reselected the file ...
    (comp.lang.labview)

Loading