C++ API - Creating session from external app

Hi all

I am pretty new to Domino C++ APIs, so need some help.

Trying to write a DLL (written a test dll) to get some database properties. Now, I want to use this dll in a VB based application.

I have a test function to get the title of a database. This is the code I am using:

char * getDBTitle() {

	LNNotesSession sess;

	LNDatabase db;

	LNString lnstrDBTitle;

	char *strRtn;

	sess.Init();

	LNSetThrowAllErrors(TRUE);



	try {

		sess.GetDatabase("names.nsf", &db, "");

		lnstrDBTitle = db.GetTitle();

		strRtn = lnstrDBTitle.GetTextPtr();

		sess.Term();

		return (strRtn);

		//return ("Fred");

	} catch (LNSTATUS sts) {

		sess.Term();

		return ("error");

	}



}

When I call this function from the VB app. I get a blank, no errors. (if I unremark ‘return (“Fred”);’ it returns ‘Fred’)

But, if I call the same dll in an agent, it works fine.

I think there is a authentication issue.

How do I get it to work? Any pointers will be highly appreciated.

Regards…

Subject: Use an [out]-variable instead …

If you want to create functions that can return strings (or any other object for that matter), you need to create a safestring or safearray of objects. It’s much easier to pass the out parameter like this:

bool getDBTitle(char *pszTitle)

When you declare this function in LS, it’s like this:

Declare Function getDBTitle Lib “whateverDLLnameyouuse.dll” getDBTitle(Byval pstrDbTitle as String) as Long

Bob

Proud Programmer!

Subject: RE: Use an [out]-variable instead …

Thanks for your suggestion Bob.

My prob. is that I have an external appl. which calls the DLLs (not a LS function). I wrote a simple VB appl. to call this DLL. Also tried a simple MFC appl. with the getDBTitle as a class function & a BUTTON_ONCLICK call this.

I am getting a empty string returned (though if I hardcode a return value, it works fine). I think (I maybe wrong) this is something to do with sess.Init()

Thanks…

Subject: C++ API - Creating session from external app - working !

Forgot to open the database before getting the title. Stupid mistake.

All working fine now.