Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UpdateResource on a .res file

Status
Not open for further replies.

bascy

Programmer
Mar 6, 2001
53
NL
Hi all,

we're trying to update the version info that is contained in a .res file from an external application. I've tried opening the .res file with BeginUpdateResource but this always gives 0 in return, indicating the file wasnt opened. Getlasterror gfives a 0 too!

What are we doing wrong?

Code:
function UpdateResFile(const ResFile: Pchar; const arVersion: TByteArray):Boolean;
var
  AHandle : THandle ;
  KbCode : Longword;
  Size1 , Size2 : DWORD;
  Pt1:Pointer;

begin
    Pt1 :=  Addr(arVersion);
    KbCode  := (SUBLANG_ENGLISH_US shl 10) or LANG_ENGLISH;
    AHandle := BeginUpdateResource(ResFile , False);
    if aHandle = 0 then
      ShowMessage('Error: ' + IntToStr(GetLastError) )
    else
    begin
      Windows.UpdateResource( AHandle , RT_VERSION , '',KBCode, Pt1 , Size1);
      result := EndUpdateResource(AHandle , False);
    end;
end;

Bascy
Software developer at
 
Are you getting the error when running the exe from a command line or while in the IDE?

Does the res file belong to the currently running executable or any other running application?

Roo
Delphi Rules!
 
There is no error, the BeginUpdate just doesnt return a handle.

And the res file belongs to a different project, not running or open at the time

Bascy
Software developer at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top