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 FaceException An error has occurred during Face 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 = faceSDK.id3FaceLicense_GetExternalDriveHardwareCode(hardwareCodeType.value, pCode, pCodeSize, pExternalDrivePath ?? nullptr);
if (err == FaceError.insufficientBuffer.value) {
calloc.free(pCode);
pCode = calloc.allocate(pCodeSize.value);
err = faceSDK.id3FaceLicense_GetExternalDriveHardwareCode(hardwareCodeType.value, pCode, pCodeSize, pExternalDrivePath ?? nullptr);
if (err != FaceError.success.value) {
throw FaceException(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);
}
}
}