Help with OLE Automation and Unicode lazarus / 34-Windows ---------------------------------------------------------------------- mudah · 2011-07-24 07:54 Hello, I have problem using OLE Automation and Unicode input. Below code used to get object count for given folder. It's working fine with ASCII folder name but not on folder name with  UTF-8 / Unicode character (Thai, Japanese, Tamil). Code: [Select]function getFolderItemCount (sFolder: variant): integer; var    vServer, vFolder, vFolderItem: variant;    iResult: integer; begin     CoInitialize(nil);     try     vServer := CreateOleObject('shell.application');     except         ShowMessage('error');     end;     vFolder := vServer.NameSpace(sFolder);     vFolderItem := vFolder.Items; //<-- Error Here: Exception Class External SIGSEGV     iResult:= vFolderItem.Count;     CoUnInitialize;     Result:= iResult end; Please help me! Thanks. ---------------------------------------------------------------------- Laksen · 2011-07-24 11:37 I get the error. But it's because NameSpace returns nil. I guess something about the encodings aren't done correctly Code: [Select]   vFolder := vServer.NameSpace(sFolder);    if not VarIsClear(vFolder) then    begin       vFolderItem := vFolder.Items;       iResult:= vFolderItem.Count;    end; ---------------------------------------------------------------------- mudah · 2011-07-24 15:41 Thanks Laksen I tried to convert param to unicode/utf8 before sending to the function. But still can't get trough. Example.. var callingVar: widestring; begin ShowMessage(IntToStr(getFolderItemCount(callingVar)); end; Also var callingVar: string; begin ShowMessage(IntToStr(getFolderItemCount(UTF8ToSys(callingVar))); end; Any proper solution to correctly parse unicode/utf8 to OLE variant?