Q&A

  • 단축아이콘의 실제경로를 알려면...
단축아이콘의 실제 경로를 알려면 어떤식으로 하면 되는지...

제능력으로는 너무나 어렵네요...^^





1  COMMENTS
  • Profile
    공성환 2000.08.25 20:42
    ofoot@yahoo.co.kr 님의 알려주셨습니다...

    //////////

    IShellLink를 이용하라는 군요. 다음은 유즈넷에서

    퍼온 겁니다. 참조하셔요... 그럼....



    uses

    ComObj, ShlObj, ActiveX;

    {$R *.DFM}

    function uoGetShortcutInfo(const shortCutPath: string; aHWnd: HWnd;

    var description, arguments, workingDir, iconFile: string;

    var hotKey: word; var showCmd, iconIndex: integer): string;

    // Given the full path to a shortcut (typically something like

    // c:windowsdesktopsomething.lnk), returns all of the info about

    // that shortcut.

    var

    hRes: longInt;

    aISL: IShellLink;

    aIPF: IPersistFile;

    wfd: TWin32FindData;

    shortCutPathW: WideString;

    begin

    result := ''; // Fall-through value



    // Get a pointer to the IShellLink interface.

    hres := CoCreateInstance(CLSID_ShellLink, nil,

    CLSCTX_INPROC_SERVER, IID_IShellLinkA, aISL);

    if (SUCCEEDED(hres)) then

    begin

    // Get a pointer to the IPersistFile interface.

    aIPF := (aISL as IPersistFile);

    if assigned(aIPF) then

    begin

    shortCutPathW := shortCutPath;

    // Load the shortcut

    hres := aIPF.Load(PWideChar(shortCutPathW), STGM_READ);

    if SUCCEEDED(hres) then

    begin

    // Resolve the link.

    if (aHWnd = $FFFFFFFF) then // -1 means no UI wanted

    hres := aISL.Resolve(aHWnd, SLR_NO_UI)

    else // Windows search dialog will appear if necessary

    hres := aISL.Resolve(aHWnd, SLR_ANY_MATCH);

    if SUCCEEDED(hres) then

    begin

    // Get the path to the link target.

    SetLength(result, MAX_PATH);

    hres := aISL.GetPath(PChar(result),

    MAX_PATH, wfd,

    SLGP_SHORTPATH );

    if (not SUCCEEDED(hres)) then

    begin

    // We didn't get the path. Reset the length of result

    SetLength(result, 0)

    end

    else

    begin

    // Set the correct length in the path

    SetLength(result, strLen(PChar(result)));



    // Now, on to the other information

    // The description

    SetLength(description, MAX_PATH);

    hres := aISL.GetDescription(PChar(description), MAX_PATH);

    if SUCCEEDED(hres) then

    SetLength(description, strLen(PChar(description)))

    else

    SetLength(description, 0);

    // If the interface didn't give us a description, use the title

    // of the link itself

    if (length(description) = 0) then

    begin

    description := ExtractFileName(shortCutPath);

    description := ChangeFileExt(description, '');

    end;



    // The working directory

    SetLength(workingDir, MAX_PATH);

    hres := aISL.GetWorkingDirectory(PChar(workingDir), MAX_PATH);

    if SUCCEEDED(hres) then

    SetLength(workingDir, strLen(PChar(workingDir)))

    else

    SetLength(workingDir, 0);



    // The arguments

    SetLength(arguments, MAX_PATH);

    hres := aISL.GetArguments(PChar(arguments), MAX_PATH);

    if SUCCEEDED(hres) then

    SetLength(arguments, strLen(PChar(arguments)))

    else

    SetLength(arguments, 0);



    // The icon file and index

    SetLength(iconFile, MAX_PATH);

    hres := aISL.GetIconLocation(PChar(iconFile), MAX_PATH, iconIndex);

    if SUCCEEDED(hres) then

    SetLength(iconFile, strLen(PChar(iconFile)))

    else

    SetLength(iconFile, 0);



    // The SHOWCOMMAND

    aISL.GetShowCmd(showCmd);



    // The hotkey

    aISL.GetHotkey(hotKey);

    end;

    end;

    end;

    end;

    end;

    end;



    procedure TForm1.Button1Click(Sender: TObject);

    var

    description,

    arguments,

    workingDir,

    iconFile : string;

    hotKey : word;

    showCmd,

    iconIndex : integer;

    begin

    uoGetShortcutInfo( 'C:WINDOWS바탕 화면kanlis.exe의 바로 가기.lnk', handle,

    description, arguments, workingDir, iconFile,

    hotKey, showCmd, iconIndex) ;



    Memo1.Lines.Clear;

    Memo1.Lines.Add( description );

    Memo1.Lines.Add( arguments );

    Memo1.Lines.Add( workingDir );

    Memo1.Lines.Add( iconFile );



    end;