hi all, i want to call a C function through a agent.But when i am running the agent an error is comming: “external function not found”.How can i solve this problem?
Subject: calling C function through agent
Which C Function do you want to use? Do you need an external dll?Or do you want to use the Lotus Notes API?
Subject: RE: calling C function through agent
yes,i need an external dll…
Subject: RE: calling C function through agent
Did you define you external procedure with a declaration?
And is the dll located in the domino program directory? Look for the location of e.g. nnotes.dll.
Subject: RE: calling C function through agent
i have given the path of the dll when i have declared the function in the agent.and i have included the dll file in the system32 folder.dll file is not located in domino program directory…
Subject: RE: calling C function through agent
Can you post your code?
I recommend not to use the full path of a dll in your declaration. A Windows Application searches for dlls in the Main Application path, Windows Path, System32 path…so put your dll in one of these folders (i prefer the system32 folder)
I think these Folders are read from the “PATH” environment variable in windows.
Is your declaration correct and does the dll have an external function name (c/c++ dll)?
Subject: RE: calling C function through agent
You have to declare the external function of a dll:
Declare Private Function FUNCTION Lib “something.dll” Alias “FUNCTION” (put in your parameters here) As Integer
Call FUNCTION(your parameters)
or with return value (here Integer)
Dim intTest as Integer
intTest = FUNCTION(your parameters)
Subject: RE: calling C function through agent
yes i have declared the function.but i have a doubt…i have given the function name same as in dll.is it right? is there any other possibility for raising error:“external function not found”??
Subject: RE: calling C function through agent
Ok lets go for it step by step:
In case you want to Popup a MessageBox by Windows API you use:
Declare Function MessageBoxForExample Lib “user32.dll” Alias “MessageBoxA” (Byval hwnd As Long, Byval lpText As String, Byval lpCaption As String, Byval wType As Long) As Long
As you can see we declare the function “MessageBoxForExample” for local use. The real name of this function is “MessageBoxA” in the file “user32.dll”.
“MessageBoxForExample” is the name we want to use local, you can type here whatever you want.
For calling this “MessageBoxForExample” we use:
Call MessageBoxForExample(0, “Hello World!”, “Caption”, 0)
I dont know which c-function you want to call so i cant help you that much.
You can fetch the error “48” or “165” which raised when you call a external function not existing in the dll.
on error 48 goto errorhandler
on error 165 goto errorExternalFunctionNotFound
’ your Call Function() here
Subject: RE: calling C function through agent
i have checked my code.i have done it as you told.still the error is comming.actually i want to connect a webcam with my application.i have downloaded a dll file from internet.then i have set the file in system32 folder.the c function is:#include <windows.h>
#include “escapi.h”
initCaptureProc initCapture;
deinitCaptureProc deinitCapture;
doCaptureProc doCapture;
isCaptureDoneProc isCaptureDone;
SimpleCapParams capture;
int setupESCAPI(int aWidth, int aHeight)
{
HMODULE capdll = LoadLibrary("escapi.dll");
if (capdll == NULL)
return 0;
initCapture = (initCaptureProc)GetProcAddress(capdll, "initCapture");
deinitCapture = (deinitCaptureProc)GetProcAddress(capdll, "deinitCapture");
doCapture = (doCaptureProc)GetProcAddress(capdll, "doCapture");
isCaptureDone = (isCaptureDoneProc)GetProcAddress(capdll, "isCaptureDone");
if (initCapture == NULL ||
deinitCapture == NULL ||
doCapture == NULL ||
isCaptureDone == NULL)
return 0;
capture.mWidth = aWidth;
capture.mHeight = aHeight;
capture.mTargetBuf = new int[aWidth * aHeight];
return initCapture(&capture);
}
please take a look on the function…
Subject: RE: calling C function through agent
My first opinion is to export this function (don’t see it here)
I never did a dll with functions in c/c++
hope this helps you:
There is an example “Creating DLL exports”…
Think you need to add a line like this:
extern “C” __declspec(dllexport) int setupESCAPI(int aWidth, int aHeight);
When i’m at home i can test this and tell you if this works.
But for now you can try it for your own.