1. Müll entfernt, aber wenn du jetzt gehst FreeMem(Buffer), wirft es auf einen Fehler - invalid pointer operation, plus einen Speicherverlust.
Delphi-Quellcode:
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses WIMGAPI;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const
created: DWORD = 1;
var
FileHandle: THandle;
dwError: DWORD;
Size: Integer;
Buffer: PWideChar;
Pot: PDWORD;
begin
InitWIMGAPI;
FileHandle := WIMCreateFile
(PWideChar('
d:\Wim_Image\x86\sources\install.wim'),
WIM_GENERIC_READ, WIM_OPEN_EXISTING, WIM_FLAG_SHARE_WRITE,
WIM_COMPRESS_XPRESS, 0);
if (FileHandle = 0)
then
begin
dwError := GetLastError;
ShowMessage('
Error Open ' + IntToStr(GetLastError));
Exit;
end
else
begin
Size := 10000;
GetMem(Buffer, Size);
Pot := @Size;
Memo1.Clear;
if (
not WIMGetImageInformation(FileHandle, @Buffer, Pot))
Then
begin
dwError := GetLastError;
ShowMessage('
Error Info ' + IntToStr(GetLastError));
Exit;
end
else
begin
Memo1.Lines.Add(Buffer);
WIMCloseHandle(FileHandle);
FreeMem(Buffer);
//invalid pointer operation
end;
end;
end;
end.
2. Wie schnell und schön zu analysieren Daten auf alle Bilder
* und ziehen in Memo?
<NAME>Windows 7 HOMEBASIC</NAME> = Windows 7 HOMEBASIC;
<NAME>Windows 7 ULTIMATE</NAME> = Windows 7 ULTIMATE;