include stdafx include iostream include cryptoki include eTPkcs11 incl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "stdafx.h"
#include <iostream>
#include "cryptoki.h"
#include "eTPkcs11.h"
#include <windows.h>
#include "stdlib.h"
using namespace std;
#define pkcs11_path "etpkcs11.DLL"
void init();
CK_FUNCTION_LIST_PTR pFunctionList=NULL;
CK_C_GetFunctionList pGFL = 0;
bool wasInit = false;
CK_SLOT_ID_PTR pSlotList;
CK_ULONG pulCount = 10;
CK_SLOT_INFO pInfo;
CK_RV rv;
void init()
{
HINSTANCE hLib = LoadLibrary((LPCWSTR) pkcs11_path);
if (hLib == NULL) {
printf("Error load library\n");
}
(FARPROC&)pGFL= GetProcAddress(hLib, "C_GetFunctionList");
if (pGFL == NULL) {
printf("Cannot find GetFunctionList().\n");
}
if (CKR_OK != pGFL(&pFunctionList)) {
printf("Can't get function list. \n");
}
if (CKR_OK != pFunctionList->C_Initialize (NULL_PTR)) {
printf("C_Initialize failed...\n");
}
}
int _tmain(int argc, _TCHAR* argv[])
{
init();
//CK_FUNCTION_LIST_PTR_PTR ppFL;
//C_GetFunctionList(ppFL);
//cout << ppFL;
cout << endl;
system("pause");
return 0;
}