unit uMain;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TfrmDemo006 = class(TForm)<br> btn1: TButton;<br> OpenDialog1: TOpenDialog;<br> procedure btn1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br><br>function SHChangeIconDialogW(h:hwnd;filename
WideChar; Reserved:integer;var index:integer):integer;stdcall;<br><br>var<br> frmDemo006: TfrmDemo006;<br><br>implementation<br><br>function SHChangeIconDialogW;external 'shell32.dll' index 62;<br><br>{$R *.dfm}<br>function StrCopyW(Dest, Source: PWideChar): PWideChar;<br><br>// copies Source to Dest and returns Dest<br><br>asm<br> PUSH EDI<br> PUSH ESI<br> MOV ESI, EAX<br> MOV EDI, EDX<br> MOV ECX, 0FFFFFFFFH<br> XOR AX, AX<br> REPNE SCASW<br> NOT ECX<br> MOV EDI, ESI<br> MOV ESI, EDX<br> MOV EDX, ECX<br> MOV EAX, EDI<br> SHR ECX, 1<br> REP MOVSD<br> MOV ECX, EDX<br> AND ECX, 1<br> REP MOVSW<br> POP ESI<br> POP EDI<br>end;<br><br>procedure TfrmDemo006.btn1Click(Sender: TObject);<br>const<br> strtemp: WideString = '%s';<br>var<br> b:integer;<br> str: array [0..MAX_PATH] of WideChar;//: WideString;<br> TempStr: WideString;<br>begin<br> b:=0;<br> if opendialog1.Execute then<br> begin<br> WideFmtStr(TempStr, '%s', [opendialog1.filename]);<br> StrCopyW(str, PWideChar(TempStr));<br> shChangeIconDialogW(handle,str,SizeOf(str),b);<br> end;<br> showmessage(str);<br>end;<br><br><br>end.