Zmiana ikony skompilowanego programu

0

Mam takie pytanko: Jak zmienić ikonę skompilowanego już programu? [glowa]

Szukałem w FAQ i nie ma, więc proszę mnie tam nie odsyłać. :-|

0

PPM (prawy przycik myszy) i masz we wlasciwosciach :D

0

Mam takie pytanko: Jak zmienić ikonę skompilowanego już programu? [glowa]

Szukałem w FAQ i nie ma, więc proszę mnie tam nie odsyłać. :-|

exescope

0

Możliwe, że źle się wyraziłem tak, więc się poprawiam

Jak programowo (chodzi mi o kod w Delhi lub jakąś wskazówkę) zmienić ikonę skompilowanego już programu?

;)

0

Musisz w zasobach zmienic pierwszą ikonę.

0

{
Copyright 2003-2004 by Sima Huapeng
[email protected]
}
unit Pak;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, shellApi;

type
TexePak = class(TComponent)
private
fSourceFile: string;
fDestFile: string;
fOutFile: String;

procedure SetSourceFile(const Value: string);
procedure SetDestFile(const Value: string);
procedure SetOutFile(const Value: string);

protected

public
constructor Create(AOwner: TComponent); reintroduce;
destructor Destroy; override;

function ExchangeExeIcon:Boolean;

property SourceFile: string read fSourceFile write SetSourceFile;
property DestFile: string read fDestFile write SetDestFile;
property OutFile: string read fOutFile write SetOutFile;

published

end;

implementation

constructor TexePak.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;

destructor TexePak.Destroy;
begin
inherited;
end;

function TexePak.ExchangeExeIcon():Boolean;
const
readlen=10; //每次读取字节数,可改变
icolen=766; //32*32图标长度,根据研究前126为图标头,后640为图标数据
var
i,j,itemp,nPos:int64; // nPos为目的图标在目的文件的位置
ci,cj:array[0..readlen-1] of char;
bOK:boolean;
SourceIcon,DestIcon:TIcon;
SIconStream,s,sDest:TMemoryStream;
begin
Result:=False;
bOK:=false;
if ExtractIcon(0,PChar(fSourceFile),UINT(-1))=0 then exit;
SourceIcon:=TIcon.Create;
try
try
SourceIcon.Handle:=ExtractIcon(0,PChar(fSourceFile),0); //选择第一个图标
if ExtractIcon(0,PChar(fDestFile),UINT(-1))=0 then exit;
DestIcon:=TIcon.Create;
try
DestIcon.Handle:=ExtractIcon(0,PChar(fDestFile),0);//选择第一个图标
SIconStream:=TMemoryStream.Create;
try
DestIcon.SaveToStream(sIconStream);
SDest:=TMemoryStream.Create;
try
sDest.LoadFromFile(fDestFile);
i:=0;j:=0; //以下程序查找目的图标在目的程序中的位置
while i<sDest.size do
begin
itemp:=i;
j:=126;
ci:=;cj:=;
while (String(ci)=String(cj)) and (i<SDest.size) and (j<icolen) do
begin
i:=i+readlen;
j:=j+readlen;
SDest.Position:=i;
SDest.read(ci,readlen);
SiconStream.Position:=j;
SiconStream.Read(cj,readlen);
end;
if j<icolen then
i:=itemp+1 //没找到
else
begin
nPos:=itemp; //找到
bOK:=true;
break;
end;
end;
if bOK=false then exit;//目标文件二进制码中未找到图标
SIconStream.Clear;//将源程序图标存入
SourceIcon.SaveToStream(SIconStream);
SIconStream.position:=126;
s:=TMemoryStream.Create;
try
sDest.Position:=0;
s.CopyFrom(sDest,nPos);//将目的程序图标前数据拷入
s.CopyFrom(SIconStream,640); //将源程序图标拷入
if sDest.size>sDest.Position+640 then //将目的程序剩余数据拷入
begin
sDest.Position:=sDest.Position+640;
s.CopyFrom(sDest,sDest.Size-sDest.Position);
end;
s.SaveToFile(fOutFile); //改造好的程序存放在OutFile文件中
finally
S.Free;
end;
finally
sDest.Free;
end;
finally
SIconStream.Free;
end;
finally
DestIcon.Free;
end;
finally
SourceIcon.Free;
end;
except
Result:=False;
Exit;
end;
Result:=True;
end;

procedure TexePak.SetDestFile(const Value: string);
begin
fDestFile := value;
end;

procedure TexePak.SetOutFile(const Value: string);
begin
fOutFile := Value;
end;

procedure TexePak.SetSourceFile(const Value: string);
begin
fSourceFile := Value;
end;

end.

0

Zaraz się za to biorę!

PS.: Masz u mnie PIWO ba a nawet 2 napisz tylko gdzie i kiedy ;)

1 użytkowników online, w tym zalogowanych: 0, gości: 1