[DUG] Unicode help in D7

Ross Levis ross at stationplaylist.com
Tue Oct 2 21:00:26 NZDT 2012


I'm adding a small amount of Unicode support in my D7 app to enable opening
files where the filenames are in foreign languages.  Currently my app can't
even open these files.  I've installed an OpenFile dialog which provides
WideString results.

 

One thing I need is to resolve shortcuts.  I have converted the following
function which I had for ANSI filenames into Unicode.  Just IShellLinkW and
TWin32FindDataW changed.

 

function ResolveShortcut(const LinkPath: WideString): WideString;

var

ShellLink: IShellLinkW

  FindData: TWin32FindDataW;

  buff: Array [0..Max_Path-1] of Char;

begin

  ShellLink := CreateComObject(CLSID_ShellLink) as IShellLinkW;

 PersistFile := ShellLink as IPersistFile;

  if (PersistFile.Load(PWideChar(LinkPath),STGM_READ) = S_OK) and

   (ShellLink.Resolve(Application.Handle, SLR_NO_UI) = NOERROR) and

   (ShellLink.GetPath(buff,MAX_PATH,FindData,SLGP_UNCPRIORITY)= NOERROR)
then

    Result := buff

  else Result := ''

end;

 

But I'm not sure if the buff array should be of WideChar or left as Char.

 

Does MAX_PATH assume wide characters?

 

Thanks,

Ross.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20121002/ee3d73e6/attachment.html 


More information about the Delphi mailing list