hi
anyone here had used the iKey usb token development tools? if yes, could you please share with me the methods to create a console based program which detects the usb token and let us change the pin?

cause i've tried modifying the codes given under the sample201 folder but to no avail.. i only need a portion of the code which let us detect and change the pin of the token..but it seems my program is not working. It can't even detect the usb token inserted.

here's my code:
Code:
//
// SecPin.cpp : implementation file
//

#include "stdafx.h"
#include "test.h"
#include "dkcryp32.h"
#include "SecPin.h"
#include "typemap.h"


#include <iostream.h>


int main(){

	char		pinBuf[256];
	char		*pin = pinBuf;
	CK_RV			RV;
	CK_RV status;

	cout<<"Test here\n";

	//
	// Initialize the library
	//
	RV = C_Initialize(0);
	if (RV != CKR_OK)
	{
		cout<<"initialize failure.\n";
		return FALSE;
	} 
	//
	//		All slots that have readers
	//
    CK_SLOT_ID_PTR pSlotList = 0;
	CK_UINTX count = 20;
    pSlotList = new CK_SLOT_ID[20]; // (20 * sizeof(CK_SLOT_ID));

	RV = C_GetSlotList(FALSE, pSlotList, &count);
	if (RV != CKR_OK)
	{
		cout<<"Get slot list failure.\n";
		delete[] pSlotList;
		return FALSE;
	}
	//
	//		All slots that have readers AND tokens!
	//
	RV = C_GetSlotList(TRUE, pSlotList, &count);
	if (RV != CKR_OK)
	{
		cout<<"Get slot list failure.\n";
        delete[] pSlotList;
		return FALSE;
	}
	if (count < 1)
	{
		cout<<"No tokens detected.\n";
        delete[] pSlotList;
		return FALSE;
	}



	///////////////////////////////////
	///////////////////////////////////
	///////////////////////////////////


	cout<<"Login - UnProtected Authentication\n";
	cout<<"Please Enter your PIN and press the enter key\n";
	cin>>pin;

	//
	// Allowing a NULL pin to initiate a Secure Authentication
	// if using a GCR420 reader.
	//
	status = C_Login(NULL, CKU_USER, (CK_CHAR_PTR)pin, (CK_UINTX)strlen(pin));
	if (status != CKR_OK)
	{
		cout<<"Login failure.\n";
		return;// (status);
	}
    else
        cout<<"Successful login.\n";


}

//
BOOL TokenOpen()
{
	CK_RV			RV;
	int				flags;
	CK_TOKEN_INFO	tokenInfo;
	CK_INFO			info;


	//
	// Initialize the library
	//
	RV = C_Initialize(0);

	//
	//		All slots that have readers
	//
    CK_SLOT_ID_PTR pSlotList = 0;
	CK_UINTX count = 20;
    pSlotList = new CK_SLOT_ID[20]; // (20 * sizeof(CK_SLOT_ID));

	RV = C_GetSlotList(FALSE, pSlotList, &count);

	//
	//		All slots that have readers AND tokens!
	//
	RV = C_GetSlotList(TRUE, pSlotList, &count);

	//
	// Blow away any left open sessions on the slot to open a session.
	//
	RV = C_CloseAllSessions(pSlotList[0]);

	//
	// Open a session
	//

	flags = CKF_RW_SESSION | CKF_SERIAL_SESSION;

	RV = C_OpenSession(pSlotList[0], flags, 0, NULL, NULL);

	//	
	// Get Info
	//
	RV = C_GetInfo(&info);

	//
	// Get Token Info
	//
	RV = C_GetTokenInfo(pSlotList[0], &tokenInfo);

    delete[] pSlotList;
	return TRUE;
}




//
// OnCommonLogin() - Login to token using Unprotected Authentication.
//
void Login()
{
	char		pinBuf[256];
	char		*pin = pinBuf;
	int			pinLen;
	CK_RV		RV;

	cout<<"Login - UnProtected Authentication\n";
	cout<<"Please Enter your PIN and press the enter key.\n";
	cin>>pin;

	pinLen = strlen(pin);

	//
	// Log the user in
		RV = C_Login(NULL, CKU_USER,	(CK_CHAR_PTR)pin, (CK_UINTX)pinLen);
	if (RV != CKR_OK)
	{
		cout<<"Login failed.";
		return;
	} 
	else
	{
		cout<<"Alhamdulillah, successful login.";
	}

	return;
}


//
// OnCommonChangePin() - Change PIN on token using Unprotected Authentication.
//
void ChangePin()
{

	char		oldPinBuf[256];
	char		newPinBuf[256];
	char		newPin2Buf[256];
	char		*oldPin = oldPinBuf;
	char		*newPin = newPinBuf;
	char		*newPin2 = newPin2Buf;
	int			oldPinLen;
	int			newPinLen;
	int			newPin2Len;
	CK_RV		RV;

	cout<<"Change PIN - Unprotected Authentication";

	cin>>oldPin;
	cin>>newPin;
	cin>>newPin2;
	oldPinLen = strlen(oldPin);
	newPinLen = strlen(newPin);
	newPin2Len = strlen(newPin2);

	C_Logout(NULL);

	RV = C_Login(NULL, CKU_USER, (unsigned char *)oldPin, (CK_USHORT)oldPinLen);
	if (RV != CKR_OK)
	{
		cout<<"The Pass Phrase entered is not allowed to login, or you have exceeded your limit of incorrect Pass Phrases.";
		return;
	}
	

	RV = C_SetPIN(NULL, (unsigned char *)oldPin, (CK_USHORT)oldPinLen, (unsigned char *)newPin, (CK_USHORT)newPinLen);			
	if (RV != CKR_OK)
	{
		
		cout<<"The Change Pass Phrase failed.";
		return;
	}
	else
	{

		cout<<"Change Pass Phrase successful";
	}
}
any help is greatly appreciated..thanks.