# activateSerialKeyBuffer static method

Uint8List activateSerialKeyBuffer(

1. String? hardwareCode,
2. String? serialKey,
3. String? commentary

)

Activates a license using a serial key and returns the license in a data buffer.

param hardwareCode The hardware code on which the license file will be attached, to be retrieved using the GetHostHardwareCode function. param serialKey The id3 serial key. param commentary Commentary associated to this license activation. return The license data buffer. throws DocumentException An error has occurred during Document Library execution.

## Implementation

    static Uint8List activateSerialKeyBuffer(String? hardwareCode, String? serialKey, String? commentary) {
      Pointer<Char>? pHardwareCode = hardwareCode?.toNativeUtf8().cast<Char>();
      Pointer<Char>? pSerialKey = serialKey?.toNativeUtf8().cast<Char>();
      Pointer<Char>? pCommentary = commentary?.toNativeUtf8().cast<Char>();
      Pointer<UnsignedChar> pLicenseFileBuffer = calloc.allocate(2048);
      Pointer<Int> pLicenseFileBufferSize = calloc.allocate(1);
      pLicenseFileBufferSize[0] = 2048;
      try {
        var err = documentSDK.id3DocumentLicense_ActivateSerialKeyBuffer(pHardwareCode ?? nullptr, pSerialKey ?? nullptr, pCommentary ?? nullptr, pLicenseFileBuffer, pLicenseFileBufferSize);
        if (err == DocumentError.insufficientBuffer.value) {
          calloc.free(pLicenseFileBuffer);
          pLicenseFileBuffer = calloc.allocate(pLicenseFileBufferSize.value);
          err = documentSDK.id3DocumentLicense_ActivateSerialKeyBuffer(pHardwareCode ?? nullptr, pSerialKey ?? nullptr, pCommentary ?? nullptr, pLicenseFileBuffer, pLicenseFileBufferSize);
        }
        if (err != DocumentError.success.value) {
          throw DocumentException(err);
        }
        final vLicenseFileBuffer = Uint8List.fromList(pLicenseFileBuffer.cast<Uint8>().asTypedList(pLicenseFileBufferSize.value));
        return vLicenseFileBuffer;
      } finally {
        if (pHardwareCode != null) {
          calloc.free(pHardwareCode);
        }
        if (pSerialKey != null) {
          calloc.free(pSerialKey);
        }
        if (pCommentary != null) {
          calloc.free(pCommentary);
        }
        calloc.free(pLicenseFileBuffer);
        calloc.free(pLicenseFileBufferSize);
      }
    }