Archived Forum Post

Index of archived forum posts

Question:

using function ck returning HCkString

Nov 05 '14 at 01:41

When I use ck dll functions returning HCkString (like ckSTR := CkImap__selectedMailbox(Imap) ) How should I convert it to normal string ? (OleStrToString ?) Do I need to free ckSTR at end ? , is it memoryleak safe ?


Answer

Each Delphi DLL method or property that returns a string has two forms. The upper-case form returns the string in an output-only HCkString in the last argument. The lower-case form returns the string directly as a System.PWideChar. The lowercase form uses a double-underscore and for properties, omits the "get".

For example:

procedure CkImap_getSelectedMailbox(objHandle: HCkImap; outPropVal: HCkString); stdcall;

function CkImap__selectedMailbox(objHandle: HCkImap): PWideChar; stdcall;

If the uppercase form is used, the HCkString object must first be instantiated by the app, and afterwards disposed (just like any Chilkat object).