getExternalDriveHardwareCode static method
- LicenseHardwareCodeType hardwareCodeType,
- String? externalDrivePath
Retrieves the hardware code of the external drive you run the library on. This function works on Windows only.
param hardwareCodeType The requested hardware code type. Must be windowsUsb. param externalDrivePath On Windows to activate a license on a USB device, it must contain the path to the requested USB drive (e.g 'G:'). return The device hardware code. throws BiosealException An error has occurred during Bioseal Library execution.
Implementation
static String getExternalDriveHardwareCode(LicenseHardwareCodeType hardwareCodeType, String? externalDrivePath) {
Pointer<Char> pCode = calloc.allocate(256);
Pointer<Int> pCodeSize = calloc.allocate(1);
pCodeSize[0] = 256;
Pointer<Char>? pExternalDrivePath = externalDrivePath?.toNativeUtf8().cast<Char>();
try {
var err = biosealSDK.id3BiosealLicense_GetExternalDriveHardwareCode(hardwareCodeType.value, pCode, pCodeSize, pExternalDrivePath ?? nullptr);
if (err == BiosealError.insufficientBuffer.value) {
calloc.free(pCode);
pCode = calloc.allocate(pCodeSize.value);
err = biosealSDK.id3BiosealLicense_GetExternalDriveHardwareCode(hardwareCodeType.value, pCode, pCodeSize, pExternalDrivePath ?? nullptr);
if (err != BiosealError.success.value) {
throw BiosealException(err);
}
}
final vCode = utf8.decode(Uint8List.fromList(pCode.cast<Uint8>().asTypedList(pCodeSize.value)));
return vCode;
} finally {
calloc.free(pCode);
calloc.free(pCodeSize);
if (pExternalDrivePath != null) {
calloc.free(pExternalDrivePath);
}
}
}