问题:如何通过修改代码跳过dongle 实现compile code
已使用的方法: comment out 源代码中使用smart dongle 部分,出现了一下窗口。
软件版本: Microsoft visual studio 2019.
以下是包括smartdongle的代码 (App.cpp):
#include "smartdongle.h"
/*
....
....
*/
App::App()
{
unsigned __int64 P1, P2;
int error;
//char errorString[QTS_ERROR_STRING_LENGTH_MAX];
//SmartDongle Demo Keys
P1 = /* 没有展示的一串数字符*/;
P2 = /* 没有展示的一串数字符*/;
while (1)
{
error = SmartDongleRead(P1, P2, 0, NULL, 0);
if (error)
{
int userchoice = AfxMessageBox("A valid Dongle is not present\n", MB_RETRYCANCEL);
if(userchoice == IDCANCEL)
{
PostQuitMessage(0);
break;
}
// SmartDongleGetErrorString(errorString, error);
// AfxMessageBox(errorString);
}
else
{
break;
}
}
}
以下是部分 smartdongle.h
/*
smartdongle.h for SmartDongle API version 3.2
www.smartdongle.com
MicroWorks, Inc.
2808 North Cole Road
Boise, ID 83704
*/
#ifndef _DEFINED_2A39393E_C414_4F94_B623_3FBCE5A8190F
#define _DEFINED_2A39393E_C414_4F94_B623_3FBCE5A8190F
#ifndef _WINDOWS_
#include <Windows.h>
#endif
/*
Maximum string length returned from GetErrorString()
*/
#define QTS_ERROR_STRING_LENGTH_MAX 128
#if defined(__cplusplus) || defined(__cplusplus__)
extern "C" {
#endif
unsigned __int64 SmartDongleGetKeylessChallenge();
int SmartDongleSendKeylessResponse(unsigned __int64 response);
int SmartDongleKeylessRead(
unsigned int address,
unsigned char *buffer,
int size);
int SmartDongleKeylessWrite(
unsigned int address,
unsigned char *buffer,
int size);
/*
Given the correct keys, P1 and P2, will place the dongle into
the enabled state and read EEPROM into buffer.
Valid address is 0 to 32431
Note: Refer to sd_uskerr.h for returned errors.
*/
int SmartDongleRead (
unsigned __int64 P1,
unsigned __int64 P2,
unsigned int address,
unsigned char *buffer,
int size);
以下是部分smartdongle.c
/*
Given the correct keys, P1 and P2, will place the dongle into
the enabled state and read EEPROM into buffer.
Number of bytes read returned in size parameter.
Note: Refer to uskerr.h for returned errors.
*/
int SmartDongleRead(
unsigned __int64 P1,
unsigned __int64 P2,
unsigned int address,
unsigned char *buffer,
int size)
{
int status;
int bufferSize = size;
HANDLE m_UsbHandle = INVALID_HANDLE_VALUE;
status = OpenUsbDev(&m_UsbHandle);
if (status != USK_OK)
{
return status;
}
/*
Attempt to read user EEPROM space.
On failure, attempt to disable dongle and return error.
Number of bytes read returned in size parameter.
*/
status = ReadEepromUserSpace(
P1, P2, (unsigned short)address, buffer, &bufferSize, &m_UsbHandle);
if (status != USK_OK)
{
DisableUsk(&m_UsbHandle);
goto SD_ERROR;
}
/*
Lock SmartDongle.
*/
status = DisableUsk(&m_UsbHandle);
SD_ERROR:
if (m_UsbHandle != INVALID_HANDLE_VALUE)
{
CloseHandle(m_UsbHandle);
}
return status;
}