Unicode problems with Delphi 2009 / 2010 and windows API calls

Posted by Charles Faiga on Stack Overflow See other posts from Stack Overflow or by Charles Faiga
Published on 2009-09-14T10:41:59Z Indexed on 2010/03/27 9:23 UTC
Read the original article Hit count: 735

Filed under:
|
|

Hi I have been using this function in Delphi 2006, but now with D2010 it throws an error. I think it is related to the switch to Unicode.

  Function TWinUtils.GetTempFile(Const Extension: STRING): STRING;
  Var
     Buffer: ARRAY [0 .. MAX_PATH] OF char;
  Begin
    Repeat
      GetTempPath(SizeOf(Buffer) - 1, Buffer);
      GetTempFileName(Buffer, '~~', 0, Buffer);
      Result := ChangeFileExt(Buffer, Extension);
    Until not FileExists(Result);
  End;

What should I do to make it work?

EDIT

I get an 'access violation' when the ChangeFileExt is called

© Stack Overflow or respective owner

Related posts about delphi

Related posts about delphi-2010