Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.
Do more with
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
BitmapResLanguage: Word;
function EnumResLangProc(hModule: HMODULE; lpType, lpName: PChar; wIDLanguage: Word;
lParam: Longint): BOOL; stdcall;
begin
BitmapResLanguage := wIDLanguage;
Result := False;
end;
function ChangeBitmapResource(ModulePath, ResourceName, BitmapPath: String): Boolean;
var
hUpdate: THandle;
Data: Pointer;
fs: TFileStream;
begin
Result := True;
fs := TFileStream.Create(BitmapPath, fmOpenRead);
Data := AllocMem(fs.Size - SizeOf(TBitmapFileHeader));
try
try
{ Starts copying data excluding the bitmap header }
fs.Position := SizeOf(TBitmapFileHeader);
fs.Read(Data^, fs.Size);
EnumResourceLanguages(GetModuleHandle(PChar(ModulePath)), RT_BITMAP, PChar(ResourceName),
@EnumResLangProc, 0);
hUpdate := BeginUpdateResource(PChar(ModulePath), False);
if hUpdate = 0 then
RaiseLastOSError;
if not UpdateResource(hUpdate, RT_BITMAP, 'BITMAP1', BitmapResLanguage, Data, fs.Size) then
RaiseLastOSError;
if not EndUpdateResource(hUpdate, False) then
RaiseLastOSError;
except
Result := False;
end;
finally
FreeMem(Data);
fs.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ChangeBitmapResource('C:\TEMP\Project1.exe', 'BITMAP1', 'C:\TEMP\another_bitmap.bmp');
end;
end.
Premium Content
You need an Expert Office subscription to comment.Start Free Trial