Using the Chilkat ActiveX in DataFlex

import the Chilkat automation library once, then use the generated cComChilkat… classes

Windows · DataFlex Studio · 32-bit and 64-bit programs · Chilkat ActiveX v11

DataFlex uses COM automation libraries through wrapper classes that the Studio generates. You import the Chilkat ActiveX once, and the Studio writes a package containing a class for every Chilkat class: cComChilkatHttp, cComChilkatJsonObject, cComChilkatCrypt2, and so on. Your code creates objects of those classes and calls Chilkat methods and properties with a Com prefix, such as ComQuickGetStr and ComLastErrorText.

The 60-second version

  1. Install the Chilkat ActiveX on your development computer: the 64-bit one for the Studio and 64-bit programs, plus the 32-bit one if you also build 32-bit programs.
  2. In the Studio choose File » New » Class, then Import COM automation, and select Chilkat ActiveX.
  3. Use the generated package and paste the first procedure.
  4. When you deploy, install the Chilkat ActiveX that matches your program's bitness.

On this page: Install Import First procedure Reading JSON Passing objects DataFlex tips Deploying Troubleshooting

Setup

1

Install the Chilkat ActiveX

The Chilkat ActiveX DLL must have the same bitness as the process that loads it. DataFlex 2021 and later compile programs as either 32-bit or 64-bit:

PurposeChilkat ActiveX needed
Importing the automation library in the StudioThe bitness of the platform selected in the import dialog (64-bit by default)
Running and debugging a 64-bit program64-bit
Running and debugging a 32-bit program32-bit

Installing both on your development computer covers every case; they coexist without problems.

v11.6.1 • 08-Sep-2026 • sha256: 23a6a3b9e18f7dd44753c1e4d4f0e170cf0807494be56e4385e69d529a694136
Chilkat 64-bit Per-Machine ActiveX MSI Installer

v11.6.1 • 08-Sep-2026 • sha256: 49402b7f5dfe0b39ee28fede63963bbc826c65693737f490c53afffa2c4bbbc5
Chilkat 32-bit Per-Machine ActiveX MSI Installer

v11.6.1 • 08-Sep-2026 • sha256: 8a38c7da817f640c7e34c3fe74a108c577f952e3a9141cbf179e129b2958ff4e
Chilkat 64-bit Per-User ActiveX MSI Installer

v11.6.1 • 08-Sep-2026 • sha256: 429f0e944f68780c9ba406202d9b8f35ab7f41d57c3528dcac244db24fb4eb0e
Chilkat 32-bit Per-User ActiveX MSI Installer

Per-machine installers register Chilkat for every user of the computer and need administrator rights; per-user installers register it only for the current user. Use per-machine for web applications and services, which run under other accounts. ZIP downloads with a register.bat script are on the ActiveX download page. Keep the DLL on a local drive. The downloads are the full version and are fully functional for a 30-day evaluation.

2

Import the Chilkat automation library

  1. Open your workspace in the Studio and choose File » New » Class.
  2. Choose Import COM automation (not Import COM ActiveX: Chilkat objects have no user interface).
  3. Check that the selected platform (32-bit or 64-bit) is the one your project needs. The dialog lists the COM objects registered for that platform.
  4. Select Chilkat ActiveX in the list. The entry's name includes the Chilkat version you installed.
  5. Finish the wizard. The Studio generates a package with a wrapper class for each Chilkat class.

The generated 32-bit and 64-bit classes are usually identical, so one package normally serves both. Chilkat's DataFlex examples use a package named ChilkatAx-win32.pkg. If the Studio gives your package a different name, change the Use statement in the examples to match. Re-import the library when you upgrade to a Chilkat version with new methods, so the package includes them.

Examples

Your first procedure: unlock Chilkat and fetch a URL

Chilkat must be unlocked once per process with UnlockBundle. During the 30-day trial any string works; after purchase, use your license code. Each Chilkat object is created with Create and then attached to a new COM object with CreateComObject:

Use ChilkatAx-win32.pkg

// Unlock once at program start.
Function ChilkatReady Returns Boolean
    Handle hoGlob
    Integer iSuccess
    String sErr

    Get Create (RefClass(cComChilkatGlobal)) To hoGlob
    If (Not(IsComObjectCreated(hoGlob))) Begin
        Send CreateComObject of hoGlob
    End
    Get ComUnlockBundle Of hoGlob "Anything for 30-day trial" To iSuccess
    If (iSuccess <> 1) Begin
        Get ComLastErrorText Of hoGlob To sErr
        Showln sErr
    End
    Send Destroy of hoGlob
    Function_Return (iSuccess = 1)
End_Function

Procedure HelloWorld
    Handle hoHttp
    String sText sErr
    Integer iOk

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Get ComQuickGetStr Of hoHttp "https://www.chilkatsoft.com/helloworld.txt" To sText
    Get ComLastMethodSuccess Of hoHttp To iOk
    If (iOk <> 1) Begin
        Get ComLastErrorText Of hoHttp To sErr
        Showln sErr
    End
    Else Begin
        Showln sText
    End

    Send Destroy of hoHttp
End_Procedure

Call ChilkatReady once when the program starts, then Send HelloWorld. The output is Hello World!. Showln writes to the console or the Studio's output; in a Windows program, show text with Send Info_Box sText instead.

Read a JSON response

This procedure downloads a small JSON document, parses it with cComChilkatJsonObject, and lists each member. The same pattern works for any REST API: send the request with cComChilkatHttp or cComChilkatRest, then read the fields with ComStringOf, ComIntOf, and ComSizeOfArray.

Procedure ListFruit
    Handle hoHttp hoJson
    String sJson sName sValue sErr
    Integer iOk i iCount

    // {"apple":"red", "lime":"green", "banana":"yellow", ...}
    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End
    Get ComQuickGetStr Of hoHttp "https://www.chilkatsoft.com/exampledata/sample.json" To sJson
    Get ComLastMethodSuccess Of hoHttp To iOk
    If (iOk <> 1) Begin
        Get ComLastErrorText Of hoHttp To sErr
        Showln sErr
        Send Destroy of hoHttp
        Procedure_Return
    End
    Send Destroy of hoHttp

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComLoad Of hoJson sJson To iOk
    If (iOk <> 1) Begin
        Get ComLastErrorText Of hoJson To sErr
        Showln sErr
    End
    Else Begin
        Get ComSize Of hoJson To iCount
        For i From 0 To (iCount - 1)
            Get ComNameAt Of hoJson i To sName
            Get ComStringAt Of hoJson i To sValue
            Showln sName ": " sValue
        Loop
    End
    Send Destroy of hoJson
End_Procedure

Passing a Chilkat object to a method

Many Chilkat methods take another Chilkat object as an argument, for example HttpStr fills a HttpResponse. Pass the underlying COM object, which you get from the wrapper's pvComObject property, rather than the DataFlex object handle:

Handle hoResp
Variant vResp

Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
If (Not(IsComObjectCreated(hoResp))) Begin
    Send CreateComObject of hoResp
End
Get pvComObject of hoResp To vResp

Get ComHttpStr Of hoHttp "POST" sUrl sBody "utf-8" "application/json" vResp To iOk

A method that returns a Chilkat object returns a Variant. To call methods on it, create a wrapper object and attach it with Set pvComObject of hoWrapper to vResult.

Things to know when calling Chilkat from DataFlex

TopicWhat to do
Success valuesChilkat methods that report success, and properties such as ComLastMethodSuccess, return 1 for success and 0 for failure. These match DataFlex's True and False, so either an Integer or a Boolean variable works.
ErrorsChilkat doesn't raise DataFlex errors for ordinary failures. Check the return value (or ComLastMethodSuccess for methods that return a string or object) and read ComLastErrorText, which explains exactly what went wrong.
Object lifetimeObjects created with Create stay alive until you Send Destroy them, which also releases the Chilkat COM object. Destroy them when you're done, especially inside loops.
Declared objectsYou can also declare a Chilkat object in an Object … End_Object block and call Send CreateComObject in its OnCreate or before first use, as with any DataFlex automation object.
Large stringsIf a large response or document comes back truncated, check DataFlex's string argument size limit (Set_Argument_Size in the DataFlex documentation). Alternatively, keep the data inside Chilkat with cComChilkatStringBuilder or cComChilkatBinData and Chilkat's file-based methods.
Web applicationsUnlock Chilkat in each web application process (for example, when the process starts), and install the per-machine Chilkat ActiveX on the server so the process's account can see it.
Chilkat v9.5 codeCode written for Chilkat v9.5 uses a package imported from the v9.5 ActiveX. Import the v11 library to use v11; both versions can be installed side by side. See Chilkat ActiveX v11 and v9.5 on the same computer.

Deploying a DataFlex program

The generated package is compiled into your program, but the Chilkat ActiveX DLL is not. On each computer where the program runs:

  • Install and register the Chilkat ActiveX with the same bitness as your compiled program. Running Chilkat's per-machine MSI from your setup is the simplest way.
  • If your installer registers the DLL itself, use regsvr32 for the right bitness; the ActiveX DLL Registration Tutorial explains the details.
  • Install the DLL to a local folder and don't move it after registering.

Troubleshooting

SymptomCause and fix
Chilkat ActiveX isn't listed in the Import COM automation dialog No Chilkat ActiveX is registered for the platform selected in the dialog. Check the 32-bit/64-bit selection, and install the Chilkat ActiveX of that bitness (the per-machine installer, if the Studio runs as administrator).
An error when CreateComObject runs The Chilkat ActiveX isn't registered for this program. Usually its bitness doesn't match the program's, or it's registered per-user and the program runs as another account or elevated. Install the matching MSI.
The compiler reports an unknown class or method, such as cComChilkatHttp The package isn't in the Use statement, its name differs from the one in the code, or it was imported from an older Chilkat version that lacks the method. Fix the Use statement, or re-import the library.
A method that takes a Chilkat object fails or reports a type mismatch A DataFlex object handle was passed instead of the COM object. Pass pvComObject.
A Chilkat method returns 0 or an empty string The operation itself failed (a network error, a bad password, an invalid file path, and so on). Read ComLastErrorText; it names the cause.

Next Steps

DataFlex is a trademark of Data Access Worldwide.