capi adk link library

capi adk link library

Post by rs23 » Fri, 10 Nov 2006 06:12:03



Hello,
I'm developing my first application with capi adk, I'm using Microsoft
VC++.
I have specified lib directories (where there is capi2032.lib file) in
tools/options/projects/vc++ directories/library files and I have
inserted in in project/my_app properties/linker/command line
capi2032.lib

When I try to compile my program, I receive the following error:

error C3861: 'CAPI_INSTALLED': identifier not found, even with
argument-dependent lookup

I have seen inside file: cwin32.c: extern DWORD APIENTRY
CAPI_INSTALLED (void);
So I don't figured It out, this problem!

I also tried with cap2032.lib and cap2032d.lib but the i have the same
error.
I have installed capi drivers and C:\WINNT\system32 directory I have
capi2032.dll file


please help me.
Teo
 
 
 

capi adk link library

Post by mm » Sat, 11 Nov 2006 07:00:55

i Teo;

Forget about linking to any lib files. You want dynamic linking, as
stated in an earlier response. Do something like the following:

typedef DWORD (APIENTRY *pCAPI_REGISTER)(DWORD MessageBufferSize, DWORD
maxLogicalConnection, DWORD maxBDataBlocks, DWORD maxBDataLen, DWORD
*pApplID);
typedef DWORD (APIENTRY *pCAPI_RELEASE)(DWORD ApplID);
typedef DWORD (APIENTRY *pCAPI_PUT_MESSAGE)(DWORD ApplID, PVOID
pCAPIMessage);
typedef DWORD (APIENTRY *pCAPI_GET_MESSAGE)(DWORD ApplID, PVOID
*ppCAPIMessage);
typedef DWORD (APIENTRY *pCAPI_WAIT_FOR_SIGNAL)(DWORD ApplID);
typedef VOID (APIENTRY *pCAPI_GET_MANUFACTURER)(PVOID SzBuffer);
typedef DWORD (APIENTRY *pCAPI_GET_VERSION)(DWORD *pCAPIMajor, DWORD
*pCAPIMinor, DWORD *pManufacturerMajor, DWORD *pManufacturerMinor);
typedef DWORD (APIENTRY *pCAPI_GET_SERIAL_NUMBER)(PVOID SzBuffer);
typedef DWORD (APIENTRY *pCAPI_GET_PROFILE)(PVOID SzBuffer, DWORD
CtrlNr);
typedef DWORD (APIENTRY *pCAPI_INSTALLED)(void);

pCAPI_REGISTER CAPI_REGISTER=NULL;
pCAPI_RELEASE CAPI_RELEASE=NULL;
pCAPI_PUT_MESSAGE CAPI_PUT_MESSAGE=NULL;
pCAPI_GET_MESSAGE CAPI_GET_MESSAGE=NULL;
pCAPI_WAIT_FOR_SIGNAL CAPI_WAIT_FOR_SIGNAL=NULL;
pCAPI_GET_MANUFACTURER CAPI_GET_MANUFACTURER=NULL;
pCAPI_GET_VERSION CAPI_GET_VERSION=NULL;
pCAPI_GET_SERIAL_NUMBER CAPI_GET_SERIAL_NUMBER=NULL;
pCAPI_GET_PROFILE CAPI_GET_PROFILE=NULL;
pCAPI_INSTALLED CAPI_INSTALLED=NULL;

bool loadCapiLib(void){
HINSTANCE hLibDLL=LoadLibrary("CAPI2032.DLL");
if( hLibDLL == NULL){ return false; }
if( (CAPI_REGISTER =
(pCAPI_REGISTER)GetProcAddress(hLibDLL,"CAPI_REGISTER")) == NULL
|| (CAPI_RELEASE =
(pCAPI_RELEASE)GetProcAddress(hLibDLL,"CAPI_RELEASE")) == NULL
|| (CAPI_PUT_MESSAGE =
(pCAPI_PUT_MESSAGE)GetProcAddress(hLibDLL,"CAPI_PUT_MESSAGE")) == NULL
|| (CAPI_GET_MESSAGE =
(pCAPI_GET_MESSAGE)GetProcAddress(hLibDLL,"CAPI_GET_MESSAGE")) == NULL
|| (CAPI_WAIT_FOR_SIGNAL =
(pCAPI_WAIT_FOR_SIGNAL)GetProcAddress(hLibDLL,"CAPI_WAIT_FOR_SIGNAL"))
== NULL
|| (CAPI_GET_MANUFACTURER =
(pCAPI_GET_MANUFACTURER)GetProcAddress(hLibDLL,"CAPI_GET_MANUFACTURER"))
== NULL
|| (CAPI_GET_VERSION =
(pCAPI_GET_VERSION)GetProcAddress(hLibDLL,"CAPI_GET_VERSION")) == NULL
|| (CAPI_GET_SERIAL_NUMBER =
(pCAPI_GET_SERIAL_NUMBER)GetProcAddress(hLibDLL,"CAPI_GET_SERIAL_NUMBER"))
== NULL
|| (CAPI_GET_PROFILE =
(pCAPI_GET_PROFILE)GetProcAddress(hLibDLL,"CAPI_GET_PROFILE")) == NULL
|| (CAPI_INSTALLED =
(pCAPI_INSTALLED)GetProcAddress(hLibDLL,"CAPI_INSTALLED")) == NULL
){
return false;
}
return true;
}

Bye
Michael


rs232 wrote:


 
 
 

capi adk link library

Post by rs23 » Sat, 11 Nov 2006 17:05:59

Hello Michael,
thanks for your reply.
Ok, for dynamic linking I'll follow your good suggestions.
Why you tell me to forget about linking to any lib files?
I'm beginning so, I was think that capi-adk was a
facilities to develope isdn communication's programs.
Could I please ask you if you send me a simple program? Even with a
single statement
(CAPI_INSTALLED/CAPI_REGISTER).
my email is : rs232atemail.it
Thanks in advance
Bye
Teo



mm ha scritto:
 
 
 

capi adk link library

Post by mm » Sun, 12 Nov 2006 00:04:41

i again;

Following is a program that reads the manufacturer name.

Compile i.e. with borlands free bcc55, like so

c:\borland\bcc55\bin\bcc32 -w-par -tWCR -I"c:\borland\bcc55\include"
-L"c:\borland\bcc55\lib;c:\borland\bcc55\lib\psdk" test.cpp

You will get a program called test.exe.

Of course this code will work with any compiler.

The output should look like:

Loaded capi2032,dll
Capi installed.
Manufacturer: AVM-GmbH

test.cpp source code:


#include <windows.h>
#include <stdio.h>

typedef DWORD (APIENTRY *pCAPI_REGISTER)(DWORD MessageBufferSize, DWORD
maxLogicalConnection, DWORD maxBDataBlocks, DWORD maxBDataLen, DWORD
*pApplID);
typedef DWORD (APIENTRY *pCAPI_RELEASE)(DWORD ApplID);
typedef DWORD (APIENTRY *pCAPI_PUT_MESSAGE)(DWORD ApplID, PVOID
pCAPIMessage);
typedef DWORD (APIENTRY *pCAPI_GET_MESSAGE)(DWORD ApplID, PVOID
*ppCAPIMessage);
typedef DWORD (APIENTRY *pCAPI_WAIT_FOR_SIGNAL)(DWORD ApplID);
typedef VOID (APIENTRY *pCAPI_GET_MANUFACTURER)(PVOID SzBuffer);
typedef DWORD (APIENTRY *pCAPI_GET_VERSION)(DWORD *pCAPIMajor, DWORD
*pCAPIMinor, DWORD *pManufacturerMajor, DWORD *pManufacturerMinor);
typedef DWORD (APIENTRY *pCAPI_GET_SERIAL_NUMBER)(PVOID SzBuffer);
typedef DWORD (APIENTRY *pCAPI_GET_PROFILE)(PVOID SzBuffer, DWORD
CtrlNr);
typedef DWORD (APIENTRY *pCAPI_INSTALLED)(void);

pCAPI_REGISTER CAPI_REGISTER=NULL;
pCAPI_RELEASE CAPI_RELEASE=NULL;
pCAPI_PUT_MESSAGE CAPI_PUT_MESSAGE=NULL;
pCAPI_GET_MESSAGE CAPI_GET_MESSAGE=NULL;
pCAPI_WAIT_FOR_SIGNAL CAPI_WAIT_FOR_SIGNAL=NULL;
pCAPI_GET_MANUFACTURER CAPI_GET_MANUFACTURER=NULL;
pCAPI_GET_VERSION CAPI_GET_VERSION=NULL;
pCAPI_GET_SERIAL_NUMBER CAPI_GET_SERIAL_NUMBER=NULL;
pCAPI_GET_PROFILE CAPI_GET_PROFILE=NULL;
pCAPI_INSTALLED CAPI_INSTALLED=NULL;

bool loadCapiLib(void){
HINSTANCE hLibDLL=LoadLibrary("CAPI2032.DLL");
if( hLibDLL == NULL){ return false; }
if( (CAPI_REGISTER =
(pCAPI_REGISTER)GetProcAddress(hLibDLL,"CAPI_REGISTER")) == NULL
|| (CAPI_RELEASE =
(pCAPI_RELEASE)GetProcAddress(hLibDLL,"CAPI_RELEASE")) == NULL
|| (CAPI_PUT_MESSAGE =
(pCAPI_PUT_MESSAGE)GetProcAddress(hLibDLL,"CAPI_PUT_MESSAGE")) == NULL
|| (CAPI_GET_MESSAGE =
(pCAPI_GET_MESSAGE)GetProcAddress(hLibDLL,"CAPI_GET_MESSAGE")) == NULL
|| (CAPI_WAIT_FOR_SIGNAL =
(pCAPI_WAIT_FOR_SIGNAL)GetProcAddress(hLibDLL,"CAPI_WAIT_FOR_SIGNAL"))
== NULL
|| (CAPI_GET_MANUFACTURER =
(pCAPI_GET_MANUFACTURER)GetProcAddress(hLibDLL,"CAPI_GET_MANUFACTURER"))
== NULL
|| (CAPI_GET_VERSION =
(pCAPI_GET_VERSION)GetProcAddress(hLibDLL,"CAPI_GET_VERSION")) == NULL
|| (CAPI_GET_SERIAL_NUMBER =
(pCAPI_GET_SERIAL_NUMBER)GetProcAddress(hLibDLL,"CAPI_GET_SERIAL_NUMBER"))
== NULL
|| (CAPI_GET_PROFILE =
(pCAPI_GET_PROFILE)GetProcAddress(hLibDLL,"CAPI_GET_PROFILE")) == NULL
|| (CAPI_INSTALLED =
(pCAPI_INSTALLED)GetProcAddress(hLibDLL,"CAPI_INSTALLED")) == NULL
){
return false;
}
return true;
}

int main(void){
if(loadCapiLib()){
fprintf(stderr,"Loaded capi2032,dll\n");
int errno=CAPI_INSTALLED();
if(errno==0){
fprintf(stderr,"Capi installed.\n");
char cbuf[64]={0};
CAPI_GET_MANUFACTURER(cbuf);
fprintf(stderr,"Manufacturer: %s\n",cbuf);
}else{
fprintf(stderr,"Capi not installed. Errno=0x%04X\n",errno);
}
}else{
fprintf(stderr,"Couldn't load capi2032,dll\n");
}
}

Bye
Mic
 
 
 

capi adk link library

Post by Werner Hen » Sun, 12 Nov 2006 20:06:20

Hi!


Why should he? Linking to the lib is much easier than explicitly
having to deal with LoadLibrary and GetProcAddress.

Ciao,
Werner...
--
PGP 8 available
http://www.yqcomputer.com/
 
 
 

capi adk link library

Post by Werner Hen » Sun, 12 Nov 2006 20:09:58

Hi!

It seems, you are new to C++ programming?


This is a compiler error. Assuming you are using the AVM CAPI ADK,
you probably did not include the CAPI h file which declares the
DLL functions?


Of course this won't help. C3861 is a compiler message. When changing
the lib to use, you are playing with the linker setting. Of course, if
the compiler fails the linker will never get invoked.

Ciao,
Werner...
--
PGP 8 available
http://www.yqcomputer.com/
 
 
 

capi adk link library

Post by mm » Mon, 13 Nov 2006 16:57:45

Hi Werner;

Why not link to a static lib ?

A program statically linked to a capiXXXX.lib from AVM will not work
with an Eicon card.
All manufacturer ship their own capi dlls under windows. These dlls are
not compatible/exchangable. That's the reason why you cannot have AVM
and Eicon cards in one Windows computer. (It should work under Linux,
though)

If you do dynamic linking your program will work with all cards!

There are other advantages to using dynamic linking, which are more
general and can be looked up on the internet (smaller executables,
faster/lazy loading ...).

Bye;
Michael
 
 
 

capi adk link library

Post by Werner Hen » Mon, 13 Nov 2006 21:05:27

Hi Michael,

I guess you do not understand the meaning of the capi2032.lib provided
in the AVM CAPI ADK. Of course it is not the complete implementation of
the capi203.dll but only an import library. If you link to that lib you
will not have the complete functionality of capi2032.dll built into your
code so that you do not need the capi2032.dll any more. Linking against
capi2032.lib just tells the linker to integrate a table into the exe so
that the Windows exe loader knows that when loading this exe it also
needs to load capi2032.dll. That's the way it is also done with all the
Windows DLLs like kernel32.dll etc..
Of course linking against the capi2032 (import) lib works with AVM and
Eicon cards.

Doing LoadLibrary and GetProcAddress is not necessary if your program
always needs to load capi2032.dll. In fact with linking against capi2032
import lib the LoadLibrary and GetProcAddress stuff is done by Windows
when loading your program - so your code gets smaller and easier.

Ciao,
Werner...
--
PGP 8 available
http://www.yqcomputer.com/
 
 
 

capi adk link library

Post by mm » Tue, 14 Nov 2006 03:49:02

Hi again;

Right, I see what you mean. I was wondering where Teo had those libs
from ;)

Bye
Michael
 
 
 

capi adk link library

Post by rs23 » Tue, 14 Nov 2006 17:35:28

Hi Michael,
thanks for your source example, I have tried and It works fine!
I have downloaded lib files from AVM CAPI ADK web site.



'Doing LoadLibrary and GetProcAddress is not necessary if your program
always needs to load capi2032.dll. In fact with linking against
capi2032
import lib the LoadLibrary and GetProcAddress stuff is done by Windows
when loading your program - so your code gets smaller and easier. '

So I was thinking about using or not using AVM CAPI ADK.
Werner post is very interesting, and I asked myself which is the best
way.
Which is your opinions about this?


Bye
Teo



mm ha scritto:
 
 
 

capi adk link library

Post by mm » Tue, 14 Nov 2006 20:12:31

Hi Teo;

I hope somebody is correcting me, if I tell you complete bullocks here.

I assume that linking to that lib just adds a few entries to your
import table of your exe file. So, when you start up the app, the
windows loader loads the 'real' capi dll and does the usual address
rewriting. (The only book I know about 'Linker & Loaders' is from John
R. Levine ISBN 1-55860-496-0, as always lots of info on the net :) )

As Werner said, if you know there is a capi dll and your program always
needs capi then go ahead and use it. Otherwise don't ;) I don't think
there is a big difference in terms of speed and space, if at all.

The reason why I would never use a lib like that is simple: I don't
like 'black boxes'. And this lib is just another one. I guess AVM did a
proper job and nothing fishy is going on in there, but who am I to
tell. Never trust another programmer if you don't have to ;)


Bye
Michael
 
 
 

capi adk link library

Post by Tobias Eri » Tue, 14 Nov 2006 20:34:38

> I assume that linking to that lib just adds a few entries to your

There are two kinds of libs when developing with Visual-studio:
"real libs" that contain all functionality and "stub libs" that just
reference to DLLs which then contain the functionality...


Normally those "stub-libs" that just implicitely load a dll at
execution-time
are autogenerated by the compiler that produced the DLL, or it can also
be created by some Microsoft-SDK-tools from an existing DLL. So not
much "blackbox" stuff going on.

The only advantage to really dynamically loading dlls is the fact, that you
application can start up even if the DLL does not exist (obviously with
reduced functionality ;-)

Tobias