Error in loading dll

Hi all,Ive got a strange error cuz its not the error message that’s strange “error in loading dll” but when it occurs. What happens is that I call an external C++ dll through a lotus script agent. I can run the agent once but when I try and run it again it pops up the error message. Now I’ve looked through the forums but the error message for them happens at the first instance in trying to run the agent.

Here’s my function in notes:

Declare Function Call Lib “S_Notes” Alias “_Call@8” _

(Byval userName As String, Byval response As String) As Integer

and this is the C++ function:

S_NOTES int __stdcall Call(const char* userName, char* response)

Also I have put the S_Notes.dll in the correct path…I think…c:\lotus\notes\S_Notes.dll.

Once again I can execute this function once but not twice and after a while all of notes collapses and disappears.

Thank you in advance!!

Francisco

Subject: Error in loading dll

Did you correctly defined your DLL? Does it contains the following code?:

BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)

{

switch (fdwReason) {

case DLL_PROCESS_ATTACH:

  if (Session.Init()) {

     cout << "\nUnable to initialize the API" << endl;

     return(FALSE);

  }

  break;

case DLL_PROCESS_DETACH:

  Session.Term();

  break;

}

return(TRUE);

}

With a special look at the DLL_PROCESS_DETACH case.

I use a DLL with this code many times from my Notes-client. For me it is invoked via an action button on a form, but I do expect it to be different when invoked via an agent.

Subject: RE: Error in loading dll

thank you so much I figured it out just before you sent me this message and you are right I needed to detach the dll using a case of the form PROCESS_DETACH. The problem was that I started doing this dll using JNI methods but then my boss asked me to take the JNI and just use LS and the C++ and with the JNI you import the dll manually and that’s why i didn’t need to have this case. Thank you soooo much for your help!Francisco