| |
| Calling DeleteFile function |
 |
I want to call the Windows DeleteFile() function, but I get the error "Incompatible types: 'string' and 'Pointer'" when compiling. How can I get around this?
The DeleteFile() procedure is declared both in the SysUtils unit and the Windows unit. The following example demonstrates calling both procedures. The version declared in the SysUtils unit accepts strings, and the Windows version accepts PChars.
procedure TForm .Button Click(Sender: TObject);
var
s : string;
a : array[0..MAX_PATH - ] of char;
begin
s := 'C:\SomeFile';
SysUtils.DeleteFile(s);
a := 'C:\SomeFile';
Windows.DeleteFile(@a);
end;
|
|
| Hits/month |
2,500,000+ |
Downloads (Since May 2000) |
7,393,709 |
| Total Files |
6,023 |
| Forum msgs |
7,670 |
| Articles/FAQs |
70+/900+ |
Top Selling Software at Amazon
|