Einzelnen Beitrag anzeigen

Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#2

Re: TResourceStream NUR Win32 API Funktion! (andere Möglichk

  Alt 6. Apr 2005, 20:40
Von Assarbad ist folgende Funktion:
Delphi-Quellcode:
{ following code is copied directly from Assarbad }

function putbinresto(binresname: string; path: string): boolean;
var
  ResSize, HG, HI, SizeWritten, hFileWrite: Cardinal;
begin
  result := false;
  //find resource
  HI := FindResource(hInstance, @binresname[1], 'BINRES');
  //if legal handle, go on
  if HI <> 0 then
  begin
    //load resource and check the handle
    HG := LoadResource(hInstance, HI);
    if HG <> 0 then
    begin
      //check resource size (needed to copy a block of data)
      ResSize := SizeOfResource(hInstance, HI);
      //create the file
      hFileWrite := CreateFile(@path[1], GENERIC_READ or GENERIC_WRITE,
        FILE_SHARE_READ or FILE_SHARE_WRITE, nil, CREATE_ALWAYS,
        FILE_ATTRIBUTE_ARCHIVE, 0);
      //if succeeded ...
      if hFileWrite <> INVALID_HANDLE_VALUE then
      try
        //write to it
        result := (WriteFile(hFileWrite, LockResource(HG)^, ResSize,
          SizeWritten, nil) and (SizeWritten = ResSize));
      finally
        //close file
        CloseHandle(hFileWrite);
      end;
    end;
  end;
end;
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat