Einzelnen Beitrag anzeigen

SlpLow

Registriert seit: 4. Nov 2013
28 Beiträge
 
#4

AW: Hilfe beim Übersetzen von C zu Delphi

  Alt 19. Nov 2013, 01:02
Versuchte...

Versuchte...
Speichert keine!

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
const
  CR = #13#10;
var
  WimHandle, ImageHandle: THandle;
  Created, ImageIdx: DWORD;
  WimName, MyTemp, pName, pDesc, aall, aa, bb, dd, cc, ns, ds, ErrCode: string;
  ImgInfoBuf, NewInfoBuf: PWideChar;
  pre: Integer;
begin
  InitWIMGAPI;

  WimName := 'd:\Project\sources\install.wim';
  ImageIdx := 1;
  MyTemp := 'd:\Project\Temp';
  pName := 'Windows 7 HOMEBASIC (x64)';
  pDesc := 'Windows 7 HOMEBASIC (x64) AllDrivers';

  // Open file
  WimHandle := WIMCreateFile(PWideChar(WimName), WIM_GENERIC_READ,
    WIM_OPEN_EXISTING, WIM_FLAG_SHARE_WRITE, WIM_COMPRESS_XPRESS, @Created);

  if WimHandle = 0 then
  begin
    ShowMessage('Error Open ' + IntToStr(GetLastError));
    Exit;
  end
  else
  begin
    // Set temp
    if (not WIMSetTemporaryPath(WimHandle, PWideChar(MyTemp))) then
    begin
      ShowMessage('Error set temp ' + IntToStr(GetLastError));
      Exit;
    end
    else
    begin
      // Load image
      ImageHandle := WIMLoadImage(WimHandle, ImageIdx);

      if ImageHandle = 0 then
      begin
        ShowMessage('Error load image ' + IntToStr(GetLastError));
        Exit;
      end
      else
      begin
        if (not WIMGetImageInformation(ImageHandle, @ImgInfoBuf, @pre)) then
        begin
          ShowMessage('Error get info ' + IntToStr(GetLastError));
          Exit;
        end
        else
        begin
          aall := ImgInfoBuf;
          Memo1.Lines.Clear;
          // Parsing
          bb := '<IMAGE INDEX="' + IntToStr(ImageIdx) + '">';
          aa := Copy(aall, 1, Pos(bb, aall) - 1);
          bb := '<NAME>';
          aa := Copy(aall, 1, Pos(bb, aall) - 1);
          bb := '<FLAGS>';
          cc := ' ' + Copy(aall, Pos(bb, aall), Length(aall));
          ns := '<NAME>' + pName + '</NAME>' + CR;
          ds := ' <DESCRIPTION>' + pDesc + '</DESCRIPTION>' + CR;
          aall := aa + ns + ds + cc;
          NewInfoBuf := PWideChar(aall);
          // if (not WIMGetImageInformation(ImageHandle, @ImgInfoBuf, @pre)) then
          if (not WIMSetImageInformation(ImageHandle, ImgInfoBuf, pre)) then
          begin
            ShowMessage('Error set info ' + IntToStr(GetLastError));
            Exit;
          end
          else
            Memo1.Lines.Add(aall);
        end;
      end;
    end;
  end;
  WIMCloseHandle(ImageHandle);
  WIMCloseHandle(WimHandle);
end;

Geändert von SlpLow (19. Nov 2013 um 05:58 Uhr)
  Mit Zitat antworten Zitat