Re: passing a string to a dll



These comments about LPCTSTR in the DLL, how much do they apply to a shared
DLL? Not that mine is necessarily going to be shared, but that's the type I
chose by default when I created it. Is this also about overhead? Should I
avoid C++ as much as possible inside the DLL?

The real purpose of this particular DLL is to store thousands of
alphanumeric codes. Presently, I do this in a function in the exe, building
a large CStringArray to which each constant is added, e.g.,
array.Add(_T("K34TU79456T1") ); When a string (code) is passed to this
function, an iteration searches for that string in the array and returns a
bool value accordingly. The call occurs only once during the running of the
exe. This has been working very effectively, but perhaps not so
efficiently; I am not sure how to evaluate the performance other than that
the results are instantaneous and accurate.

If I move these strings into the DLL function, I will be happy to get them
out of the exe; but what impact does this have on performance, memory
consumption or anything else? Am I gaining or losing anything?

And if I move the alphanumeric code array to the DLL as I intend, how do I
build the array with LPCTSTR instead of CString?
------------
"Tom Serface" <tom.nospam@xxxxxxxxxxxxx> wrote in message
news:ujvemyj%23HHA.4880@xxxxxxxxxxxxxxxxxxxxxxx
Just a guess, but did you include the header file for the DLL.

Also, you may want to define your functions for:

CString GetString();
CString LoadStringID(UINT stringID);

As

LPCTSTR GetString();
LPCTSTR LoadStringID(UINT stringID);

You can still assign to a CString on output:

CString cs = GetString();

Tom


.



Relevant Pages

  • Re: VC++ 6.0 DLL Using CString used in VC++ 2008
    ... CString in both return codes and function arguments. ... There is no way I can change the DLL, so my only idea is that I need to ... compiler-independent interface. ... fantasy world, compiler-dependent interfaces never change). ...
    (microsoft.public.vc.mfc)
  • Re: passing a string to a dll
    ... CString LoadStringID(UINT stringID); ... You can still assign to a CString on output: ... I have now specified unicode in the dll, so it should match up with the application. ... // DLLRect.h: ...
    (microsoft.public.vc.mfc)
  • Re: VC++ 6.0 DLL Using CString used in VC++ 2008
    ... CString in both return codes and function arguments. ... There is no way I can change the DLL, so my only idea is that I need to ... compiler-independent interface. ...
    (microsoft.public.vc.mfc)
  • 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)
  • Re: Sorry - basic Q about using char[] instead of CString
    ... I've got a call to an external DLL I'm using LoadLibrary to get. ... lpFUNCTION MyFunc(CString p1, CString p2, short* retVal, CString* retText) ... these would be better declarations for an MFC interface. ...
    (microsoft.public.vc.mfc)