Sample code for 30+ languages & platforms
C Requires Chilkat v11.7.0+

Get the QR Code Capabilities of the Chilkat Version in Use

See more QR Code Examples

Demonstrates the capabilities operation, which describes what the installed version of Chilkat can do: the range of QR versions, the error-correction levels, the operations, the image formats and the limits. A program can check for a feature here instead of testing for a Chilkat version number. The request can be an empty JSON object.

Chilkat C Downloads

C
#include <C_CkJsonObject.h>
#include <C_CkFormats.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkJsonObject json;
    HCkFormats fmt;
    HCkJsonObject jsonOut;
    int i;
    int n;

    success = FALSE;

    //  This example requires the Chilkat API to have been previously unlocked.
    //  See Global Unlock Sample for sample code.

    json = CkJsonObject_Create();
    fmt = CkFormats_Create();
    jsonOut = CkJsonObject_Create();
    success = CkFormats_QrCode(fmt,"capabilities",json,jsonOut);
    if (success == FALSE) {
        printf("%s\n",CkFormats_lastErrorText(fmt));
        CkJsonObject_Dispose(json);
        CkFormats_Dispose(fmt);
        CkJsonObject_Dispose(jsonOut);
        return;
    }

    printf("Chilkat version: %s\n",CkJsonObject_stringOf(jsonOut,"productVersion"));
    printf("symbology: %s\n",CkJsonObject_stringOf(jsonOut,"symbologies[0].id"));
    printf("QR versions: %d to %d\n",CkJsonObject_IntOf(jsonOut,"symbologies[0].encoding.version.min"),CkJsonObject_IntOf(jsonOut,"symbologies[0].encoding.version.max"));
    printf("structured append, most symbols: %d\n",CkJsonObject_IntOf(jsonOut,"symbologies[0].structuredAppend.maxSymbols"));

    n = CkJsonObject_SizeOfArray(jsonOut,"symbologies[0].encoding.errorCorrection");
    for (i = 0; i <= n - 1; i++) {
        CkJsonObject_putI(jsonOut,i);
        printf("error correction: %s\n",CkJsonObject_stringOf(jsonOut,"symbologies[0].encoding.errorCorrection[i]"));
    }

    //  The operations this version implements.
    n = CkJsonObject_SizeOfArray(jsonOut,"operations");
    for (i = 0; i <= n - 1; i++) {
        CkJsonObject_putI(jsonOut,i);
        if (CkJsonObject_BoolOf(jsonOut,"operations[i].available") == TRUE) {
            printf("operation: %s\n",CkJsonObject_stringOf(jsonOut,"operations[i].name"));
        }

    }

    n = CkJsonObject_SizeOfArray(jsonOut,"imageFormats.output");
    for (i = 0; i <= n - 1; i++) {
        CkJsonObject_putI(jsonOut,i);
        printf("image format: %s\n",CkJsonObject_stringOf(jsonOut,"imageFormats.output[i]"));
    }

    printf("default timeout: %d ms\n",CkJsonObject_IntOf(jsonOut,"limits.timeoutMs.default"));
    printf("default largest image: %d pixels\n",CkJsonObject_IntOf(jsonOut,"limits.maxPixels.default"));

    //  Sample output:

    //  Chilkat version: 11.7.0
    //  symbology: qr
    //  QR versions: 1 to 40
    //  structured append, most symbols: 16
    //  error correction: auto
    //  error correction: L
    //  error correction: M
    //  error correction: Q
    //  error correction: H
    //  operation: generate
    //  operation: measure
    //  operation: validate
    //  operation: capabilities
    //  image format: png
    //  image format: svg
    //  default timeout: 10000 ms
    //  default largest image: 16777216 pixels


    CkJsonObject_Dispose(json);
    CkFormats_Dispose(fmt);
    CkJsonObject_Dispose(jsonOut);

    }