Problems calling C++ API's DLL functions from VB

I am using Lotus C++ API with Lotus 8.5.0. I am using VS6.0 and was able to run various exe files & created DLL’s successfully. The problem is I am able to use the DLL only in Lotus script.

I tried using the DLL in VB & the error “error opening one lotus notes application” and the VB GUI gets closed. I am pasting my VB code below.

-----------------VB CODE----------------------

Private Declare Function NSFType Lib “tvb.dll” (ByVal strFilePath As String) As Integer

Dim str As Variant

Dim ret1 As Integer



str = "D:\Program Files\Lotus\Notes\Data\TestNSF\email.nsf"

  ret1 = NSFType(str)'-----ERROR AT THIS LINE

Print "Database Type ->", ret

-------------DLL Code of the function------

extern “C”

{

//by soumya

__int32 __stdcall NSFType(LNString strDbPath)

{

char errorBuf[151];

LNSetThrowAllErrors(TRUE); //capturing all errors

LNNotesSession session;

session.Init();//initializing API

LNDatabase db;

int status;

LNString TemplateName;



try

{

		session.GetDatabase(strDbPath,&db);// getting the database

	db.Open();

	TemplateName=db.GetInheritsFromTemplateName();//getting the template name of the database

	TemplateName=TemplateName.GetTextPtr();

	if (TemplateName=="")

	{

	status=0; // an email database will always have a template name.

		

	}

	else

	{

	// An email database will have a template name. To confirm the datbase type, we open one

	//document from the database & check if it has fields like Subject,To and From.

	LNViewFolder View;

	LNDocument Doc;

	db.GetViewFolder("($All)", &View);//get the view $All which is present in email database.

	View.Open();//open the view

	LNVFEntry Entry = View[0];//get the first entry in the view

	Entry.GetDocument(&Doc);//get the handle of the first document

	Doc.Open();//open the document

		if (Doc.HasItem("Subject")&&Doc.HasItem("SendTo")&&Doc.HasItem("From"))

		{

		status=1;

		}

		else

		{

		status=0;	

		}

		Doc.Close();//closing the document to free memory

	}



}

catch(LNSTATUS error)

{

	LNGetErrorMessage(error,errorBuf);

	//error handling is done

}

	return(status);//return the result as email/Non email type

	

session.Term();//terminating the lotus session.

}