Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
Delphi 10.2 Tokyo Professional
|
Re: TMemoryStream zu CreateFile ummodeln.. -.-
7. Sep 2009, 19:05
Hi,
Also hab mal was gebaut.. Das hier geht:
Delphi-Quellcode:
function OpenFile(FName: String): Pointer;
var h: hFile;
len: Cardinal;
begin
Result := nil;
h := CreateFile(PChar(FName),GENERIC_READ,FILE_SHARE_READ,
nil,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
if h <> INVALID_HANDLE_VALUE then
begin
len := GetFileSize(h,nil);
GetMem(Result,len);
ReadFile(h,Result^,len,len,nil);
CloseHandle(h);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// Zu Testzwecken wird auf guten Stil verzichtet :)
Memo1.Text := PChar(OpenFile('C:\bsp.ini'));
end;
Michael "Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
|
|
Zitat
|