Тимофей Ершов пишет:Добрый день. Пришлите ту часть кода, где организован поиск ключа. Начиная с инициализации API и до вызова Find, включая Find.
//------------------------------------------------------------------------------
// (C) 1997 - 2014 Aktiv Co. All rights reserved.
// Guardant API example C++
//------------------------------------------------------------------------------
// This example demonstrates Guardant API usage.
// This code sample is for API demonstration only!
// Please do not use this code in real projects!
//------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#include <windows.h>
#endif
#include <grdapi.h>
#include "grddongle.h"
// Definitions
#define CryptPU 0x8566783lu // Random value for access codes security
#define CryptRD 0x17d49c84u // Random value for access codes security
#define CryptWR 0x9843de24u // Random value for access codes security
#define CryptMS 0x47832845u // Random value for access codes security
// Data variables
uint32_t dwPublic = (uint32_t)GrdDC_DEMONVK - CryptPU; // Must be encoded
uint32_t dwPrivRD = (uint32_t)GrdDC_DEMORDO - CryptRD; // Must be encoded
uint32_t dwPrivWR = (uint32_t)GrdDC_DEMOPRF - CryptWR; // Must be encoded
uint32_t dwPrivMS = (uint32_t)GrdDC_DEMOMST - CryptMS; // Must be encoded
void PrintError(const char* Text);
void PrintText(const char* Text);
int PrintCode(int nErrorCode);
int PrintDongleModel(DWORD dwModelID);
int ErrorHandling( int nRet);
//----------------------------------------------------------------------------------
// Main function
//----------------------------------------------------------------------------------
int main(int argc, char** argv)
{
int nRet;
int dwLMS =-1;
//------------------------------------------------------------------------------
// Check argument for work with local or remote dongle
//------------------------------------------------------------------------------
uint32_t dwRemoteMode = GrdFMR_Local; // Operation mode flags
if (argc > 1 && (strstr(argv[1], "-remote")))
dwRemoteMode = GrdFMR_Remote;
if (argc > 1 && (strstr(argv[1], "-all")))
dwRemoteMode = GrdFMR_Local|GrdFMR_Remote;
printf("------------------------------------------------------------------------------\n");
printf(" Guardant StealthII/Sign/Time example for C++ (32/64-bit)\n");
printf(" ( C ) 2014 Aktiv Co. All rights reserved\n");
printf("Usage option: -remote (work with remote dongles) -all (work with all dongles) \n");
if ( dwPrivRD == 0x51917645-CryptRD ){
printf(" This example can be executed with DEMO dongle only. \n");
printf(" To execute with fully operable dongle, assign your own codes \n");
printf(" to appropriate variables.\n");
}
printf("------------------------------------------------------------------------------\n");
// Declare GrdDongle object
printf("Declare GrdDongle object: ");
CGrdDongle grdDongle(dwRemoteMode); // parameters for call GrdStartup() & GrdSetFindMode
ErrorHandling(GrdE_OK); // Some error found?
// Create GrdDongle object
printf("Create GrdDongle object: ");
// Set parameters for call GrdSetAccessCodes()
nRet = grdDongle.Create(dwPublic + CryptPU, dwPrivRD + CryptRD, dwPrivWR + CryptWR, dwPrivMS + CryptMS);
ErrorHandling(nRet);
uint32_t dwFlags = 0; // Check by bProg, bVer & dongle type flag
uint8_t byProg = 0; // Check by specified program number
uint32_t dwID = 0; // This search mode is not used
uint16_t wSN = 0; // This search mode is not used
uint8_t byVer = 0; // Check by specified version
uint16_t wMask = 0; // This search mode is not used
uint16_t wType = 0; // Type dongle
uint32_t dwModel = GrdFMM_ALL; // Any Guardant
uint32_t dwInterface = GrdFMI_ALL; // Any interface
// After execute constructor while creating GrdDongle object we can additionaly call one or more functions
// GrdSetAccessCodes(), GrdSetWorkMode() & GrdSetFindMode() for you not default modes & search parameters for example
printf("Setting dongle search conditions: ");
nRet = grdDongle.SetFindMode(dwRemoteMode, dwFlags, byProg, dwID, wSN, byVer, wMask, wType, dwModel, dwInterface);
ErrorHandling(nRet);
// Search for all specified dongles and print ID's
if (dwRemoteMode == GrdFMR_Remote)
printf("Searching for all specified remote dongles and print dongles info about it's\n");
else if (dwRemoteMode == GrdFMR_Local)
printf("Searching for all specified local dongles and print dongles info about it's\n");
else
printf("Searching for all specified local/remote dongles and print dongles info about it's\n");
TGrdFindInfo GrdFindInfo;
nRet = grdDongle.Find(GrdF_First, &dwID, &GrdFindInfo);
if( GrdE_OK != nRet)
{
PrintError("The Guardant dongle with this access codes not found!");
return nRet;
}