Use of LNStringTranslate

Few days ago I asked how I can convert LNString to char because I got only strange chars. Somebody got me a solution but my problem are now that I don’t know how I can implement this solution in my C++ Code because I’m new in this and don’t have experience.

My Code are:

char * GetStartDate(char * dbServer, char * dbName, char * agName)

{

LNNotesSession	session;

session.Init();



LNDatabase		db;	



LNSetThrowAllErrors(TRUE);

try

{

	LNAgent		agent;

	LNDatetime	date;

	LNString	day;

	LNString	month;

	LNString	year;

	LNString	strDate;

	char * dayAsChar;

					

	session.GetDatabase(dbName, &db, dbServer);

	db.Open();

	

	if(db.AgentExists(agName))

		db.GetAgent(agName, &agent);

		

	agent.Open();

	date = agent.GetStartDate();

	day = date.GetDay();

	month = date.GetMonth();

	year = date.GetYear();

	

	strDate = day;

	strDate += ".";

	strDate += month;

	strDate += ".";

	strDate += year;

	dayAsChar = strDate.GetTextPtr();

	

	return (dayAsChar);

}	

catch (LNSTATUS error)

{

	session.Term();

	return("00.00.0000");

}

}

The solution are:

inline LNStringToCString(const LNString& lns, CString * pStr)

{

#ifdef UNICODE

DWORD dwSize = lns.GetLength() * sizeof(TCHAR) + 1;

LNStringTranslate(lns, LNCHARSET_UNICODE, dwSize, pStr->GetBuffer(dwSize));

pStr->ReleaseBuffer(lns.GetLength());

#else

(* pStr) = (LPCTSTR) lns;

#endif

}

inline StringToLNString(LPCTSTR pszString, LNString * plns)

{

#ifdef UNICODE

LNStringTranslate(pszString, LNCHARSET_UNICODE, plns);

#else

  • plns = (LPCTSTR) pszString;

#endif

}

All this I want to use it in a DLL to get the Startdate of the Agent.

I hope somebody can help me :wink:

Thanks a lot

Toni