Hi paule32,
The problem is not the function itself, but what you are trying to do with its result.
The result of the function is a String (AnsiString). And you are trying to asign it to TCheckListBox.Checked[] property, which is of Boolean type.
You can not assign a String to a Boolean, hence the error.