Forum > Other OS

DeleteFile doesn't work

<< < (2/2)

marcov:

--- Quote from: rvk on June 01, 2015, 09:16:00 pm ---And please note that the Windows.DeleteFile() is linked with the DeleteFileA Windows-api.

--- End quote ---

There is no DeleteFileA  API on wince, and WinCE defines FPC_UNICODE_OS, so Windows unit is compiled with -W by default.

At least 3.x is. 2.x is too long ago for me:-)

rvk:

--- Quote from: marcov on June 01, 2015, 10:08:57 pm ---
--- Quote from: rvk on June 01, 2015, 09:16:00 pm ---And please note that the Windows.DeleteFile() is linked with the DeleteFileA Windows-api.

--- End quote ---

There is no DeleteFileA  API on wince, and WinCE defines FPC_UNICODE_OS, so Windows unit is compiled with -W by default.

--- End quote ---

Ok... If that's the case the string would first need to be converted to Widestring.

So this should do the trick:

--- Code: ---DeleteFile(PWideChar(UTF8Decode(fLogDir + sr.Name)));

--- End code ---
(UTF8Decode for converting the UTF8 to Unicodestring/Widestring)

(Or is the string-type in lazarus/wince also already Unicode ???)

HermanR:
SOLVED

fLogDir = \My Documents\Log\
sr = TSearchRec

I tested all you guys adviced and reduced the solution to the next line.

DeleteFile(PWideChar(WideString(fLogDir + sr.Name)));

The conversion to WideString before making the pointer did the trick

Thanks all
Herman

Navigation

[0] Message Index

[*] Previous page

Go to full version