1

CString Convert to LPCTSTR
i write DLL file,it is static dll
i want CString type Convert to LPCTSTR
but error
Code:
<<<<<<<<<<<Dll File>>>>>>>>>
<<<<<<<A.H>>>>>>>
class AFX_NOVTABLE dll
{
public:
__declspec(dllexport) LPCTSTR Fun();
};
<<<<<<<A.Cpp>>>>>>
LPCTSTR dll::Fun()
{
CString Rxg=_T("rxg");
LPCTSTR lpszStr=Rxg.GetBuffer();
return lpszStr;
}
<<<<<<<<Exe>>>>>>>>>
#pragma comment(lib,"dll.lib")
#include "A.h"
..................
dll d;
LPCTSTR b=d.Fun();

error,why
thank:)

3
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by rxgmoral
0

try this

LPCTSTR lpszStr=(LPCTSTR)Rxg;

>>LPCTSTR b=d.Fun();

post the complete error message, I don't think you exported/imported the function correctly. This is a macro I use. When compiling the DLL, define the macro MYEXPORT, when compiling the application then do not define it.

#ifdef MYEXPORT
#define DllExport  __declspec( dllexport )
#else
#define DllExport  __declspec( dllimport )
#endif

class AFX_NOVTABLE dll 
{
public:
DllExport LPCTSTR Fun();
};
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.