Programming with the CryptoSys PKI Toolkit
To use CryptoSys PKI with Visual Basic (VB6) or VBA, copy the declarations in the file basCrPKI.bas
into a module in your project. VBA programmers (MS Office, Access, Excel, etc) should delete the first line with
Attribute VB_Name in it.
Dim nRet As Long nRet = PKI_Version(0, 0) Debug.Print "PKI_Version = " & nRet nRet = PKI_LicenceType(0) Debug.Print "PKI_LicenceType is " & Chr(nRet)
#include "diCrPKI.h" in your source code and link with the library diCrPKI.lib.
Here is some minimal code:-
/* myver.c */
#include <stdio.h>
#include "diCrPKI.h"
int main()
{
long version;
version = PKI_Version(NULL, NULL);
printf("Version=%ld\n", version);
return 0;
}
To create myver.exe with MSVC++:
cl myver.c diCrPKI.libWith Borland C++ (but see Using With Borland C++ below to generate a new lib file):
bcc32 myver.c diCrPKI.libWith some compilers you can avoid having to link explicitly to the LIB file by inserting this line in the source code:
#pragma comment(lib, ".\\diCrPKI.lib")The #pragma statement instructs the linker to link to the library file located - in this case - in the current working directory. Edit the location to suit your own situation. This
#pragma
method works for MSVC++ and Borland C++5.
To compile our example code with MSVC, you can create a `command-line' project and add the two files
PKI_Example.c and diCrPKI.h to it.
Alternatively, use this command line instruction:
C:\>CL PKI_Examples.c diCrPKI.lib Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 11.00.7022 for 80x86 Copyright (C) Microsoft Corp 1984-1997. All rights reserved. PKI_Examples.c Microsoft (R) 32-Bit Incremental Linker Version 5.10.7303 Copyright (C) Microsoft Corp 1992-1997. All rights reserved. /out:PKI_Examples.exe PKI_Examples.obj diCrPKI.lib
C:\>implib diCrPKI.lib diCrPKI.dll Borland Implib Version 3.0.22 Copyright (c) 1991, 2000 Inprise CorporationNote the order of the parameters (.lib then .dll). If you get them the wrong way round it will destroy your DLL file!
To compile our test source code using Borland C++ for Win32, do the following:-
C:\>bcc32 PKI_examples.c Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland pki_examples.c: Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 BorlandIn our PKI_Example.c code, we used certain variables in
assert
statements as a quick-and-dirty error checking mechanism.
The Borland compiler will warn you that they are not used, even though they are.
To avoid these warnings, use this command:
bcc32 -w-8004 PKI_examples.c
diCrSysPKINet.dll
and include the line (for C#)
using CryptoSysPKI;or (for VB.NET)
Imports CryptoSysPKIin your source code. Alternatively, with C#, you can include the source code module
CryptoSysPKI.cs
in your project and do not set a reference.
using CryptoSysPKI;
int n;
n = General.Version();
Console.WriteLine("Version={0}", n);
Imports CryptoSysPKI
Dim n As Integer
n = General.Version()
Console.WriteLine("Version={0}", n)
For more details, see the section in the manual
Using with .NET: C# and VB.NET.
This page last updated 28 March 2007
Home |
PKI Home |
Purchase |
Cryptography Software Code |
Contact us
Copyright © 2004-7 D.I. Management Services Pty Limited ABN 78 083 210 584,
Sydney, Australia. All rights reserved.
<www.di-mgt.com.au>
<www.cryptosys.net>