음...
나이렉스의 샛별 하영재입니다...
흑흑... 그렇게 서운 하셨군요...
그런줄도 모르고... 간단히 예제를 만들어 봤습니다...
참고하세요...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button2: TButton;
OpenDialog1: TOpenDialog;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
ComObj, ActiveX, ShlObj;
{$R *.DFM}
const
IID_IPersistFile: TGUID = ( D1:$0000010B;D2:$0000;D3:$0000;D4:($C0,$00,$00,$00,$00,$00,$00,$46));
function CreateLink(lpszPathObj,lpszPathLink, lpszDesc:PChar):HRESULT;
var
psl:IShellLink;
ppf:IPersistFile;
wsz:array[0..MAX_PATH-1] of word;
begin
Result := CoCreateInstance( CLSID_ShellLink, nil, CLSCTX_INPROC_SERVER, IID_IShellLinkA, psl );
if ( SUCCEEDED( result ) ) then
begin
psl.SetDescription(lpszDesc);
Result := psl.QueryInterface( IID_IPersistFile,ppf );
if ( SUCCEEDED( result ) ) then
begin
Result := psl.SetIconLocation( lpszPathObj, 0 );
if ( SUCCEEDED( result ) ) then
begin
MultiByteToWideChar( CP_ACP, 0, lpszPathLink, -1, @wsz, MAX_PATH );
result := ppf.Save( @wsz, TRUE );
end;
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Soo: String;
begin
OpenDialog1.Execute;
Soo:= ExtractFileName(OpenDialog1.FileName);
Soo := 'C:\WINDOWS\바탕 화면\' + Soo + '.lnk';
CreateLink(PChar(OpenDialog1.FileName), PChar(Soo), '');
end;
end.
여기서는 해당되는 파일의 아이콘을 얻어오질 않습니다.
그 부분은 직접 구현하시면 되고요...
더 궁금한 점 있으심 또 질문주세요...
그럼...
|