Q&A

  • lnk 파일.. 실행파일명과 경로를 구하는 함수좀 알려주세요...
바탕화면에 바로가기 파일을 만들고 나서..
바탕화면 바로가기 파일을 검색한후 바로가기 파일이 없으면 생성하려고 합니다.  그런데  바로가기 이름을 바꾸면 찾지 못하여. 바로가기 파일의 실행파일 경로를 구해 프로그램 실행 파일과 비교하여 없으면  바로가를 생성하고 싶습니다. 그런데 실행파일 경로를 알지 못해서....
2  COMMENTS
  • Profile
    넘버3 2003.01.08 03:50
    다음 함수를 이용하세요.그럼 즐프~~~~

    function ExtractFileDir(const FileName: string): string;

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      showmessage(ExtractFilePath(ParamStr(0)));
    end;


  • Profile
    KDDG_ZZOM 2003.01.08 03:44
    예전에 어떤분이 알려주신건데 성함을 잘모르겠네요...^^
    즐프하세요...

    unit Unit1;

    interface

    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      ComObj, ShlObj, ActiveX, StdCtrls;


    type
      TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;

    implementation

    {$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바탕 화면StarCraft.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;

    end.


    • 강재규
    • 2003.01.09 03:11
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 정종필
      2003.01.09 20:29
      저도 델파이 잘 하진 못하지만.. 제 짧은 소견으로는.. 에러메세지에 나온 그대도.. 확보 해 놓지 않은 (...
    • 김용덕
      2003.01.09 06:12
      안녕하세요. 제가보기에는 좀 문제가 있어 보이는군요. 핸들값이 일정치 않게 바뀐다고 하셨는데요. 제...
    • JJH
    • 2003.01.09 01:37
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 임형호
      2003.01.09 02:53
      OpenDialog.Files.Count
    • 세라핌
    • 2003.01.08 21:31
    • 0 COMMENTS
    • /
    • 0 LIKES
    • 포맷
    • 2003.01.08 20:36
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 구창민
      2003.01.08 22:24
      안녕하세여~ 구창민입니다. 1. Windows.pas 에 선언되어 있습니다. 2. WaitFor 함수의 Result 겠군여...
    • 포맷
      2003.01.08 23:01
      1.  windows.pas에  INFINITE = DWORD($FFFFFFFF);     { Infini...
    • 김만구
    • 2003.01.08 20:34
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 구창민
      2003.01.08 21:26
      안녕하세요~ 구창민입니다. SetValue 프로시져에서 FloatToStr 로 치환해서 대입해보세요. Self.Text...
    • 김만구
      2003.01.09 02:48
      정말 감사합니다...^^
    • shem
    • 2003.01.08 20:06
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 구창민
      2003.01.08 21:07
      안녕하세용 구창민입니다. 코드 어디에선가 무한루프를 돌지 않는지 확인해보세요. F7, F8 을 이용해...
    • 김수경
      2003.01.08 20:53
      뾰족한 답이 없는 질문이네염 ^^; stack overflow 에러는 말 그대로 Stack이 모자란 경우입니다. 일반...
    • Galaxy
    • 2003.01.08 20:02
    • 5 COMMENTS
    • /
    • 0 LIKES
    • 최용일
      2003.01.08 20:36
      안녕하세요. 최용일입니다. 비교하실때 Checkbox1.Checked를 비교해보시면 되겠네요... if (FlatEdit...
    • 김수경
      2003.01.08 20:40
      CheckBox1MouseUp 즉, OnMouseUp Event에서 처리하는 것도 한 방법일 것 같습니다. 참고하시구여~
    • Galaxy
      2003.01.08 21:08
      답변에 너무너무 감사 드립니다. 한가지 더 질문이 있어서 이렇게 질문을 합니다. 이럴 경우에는 어떻...
    • 최용일
      2003.01.08 22:03
      안녕하세요. 최용일입니다. 아까와 같은 경우입니다. DateEdit1.Clear; 를 하시면 DateEdit1가 변경...
    • Galaxy
      2003.01.08 23:42
    • (_^^)~U
    • 2003.01.08 19:21
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 프리맨
      2003.01.08 19:53
      용량 줄이시려면 압축률을 조정하시면 되구요... 보간법으로 줄이실때는 가장 크기가 비슷한(보다 큰) ...
    • (_^^)~U
      2003.01.08 20:18
      답변 감사 합니다. 밑에 소스가 델마당에서 가져온 소스거든요 제가 이미지 처음 다뤄봐서 그러거든요 ...
    • 최은하
    • 2003.01.08 18:58
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 최용일
      2003.01.08 20:41
      안녕하세요. 최용일입니다. List := IdTCPServer1.Threads.LockList;    위 부분이 주석...
    • 최은하
      2003.01.09 20:08
           이제서야 뭔가가........... 정말 고맙습니다.   또.. 질문한다는...
    • 전원이
    • 2003.01.08 18:15
    • 3 COMMENTS
    • /
    • 0 LIKES
    • 최용일
      2003.01.08 20:44
      안녕하세요. 최용일입니다. 말 그대로입니다. 양쪽 컴퓨터의 FlatStyle컴포넌트가 다르나 보네요... ...
    • 전원이
      2003.01.08 21:04
      양쪽 컴포넌트는 똑같거든요... 그쪽 컴에 있는거 복사해서 설치했고... 또한 인터넷에서 받아서도 설치...
    • 최용일
      2003.01.08 21:58
      안녕하세요. 최용일입니다. 델파이의 에러메세지는 믿을만 합니다. 터보C와는 달리 정확합니다... RP...
    • 최호석
    • 2003.01.08 09:12
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 박장용
      2003.01.08 20:06
      win2000이나 xp에서 개발된 프로그램을 98에서 실행할 경우 한글폰트에 문제가 발생합니다. 영문 Charset...
    • 임청택
    • 2003.01.08 07:34
    • 0 COMMENTS
    • /
    • 0 LIKES
    • 미리내
    • 2003.01.08 03:44
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 고재남
      2003.01.08 19:31
      @^^; 저도 초보라 답변이 될런지... qrshape component를 detail band에 놓으시고 qrshape property...
    • 류병삼
    • 2003.01.08 03:39
    • 2 COMMENTS
    • /
    • 1 LIKES
    • 넘버3
      2003.01.08 03:50
      다음 함수를 이용하세요.그럼 즐프~~~~ function ExtractFileDir(const FileName: string): string; ...
    • KDDG_ZZOM
      2003.01.08 03:44
      예전에 어떤분이 알려주신건데 성함을 잘모르겠네요...^^ 즐프하세요... unit Unit1; interface ...
    • 하병준
    • 2003.01.08 03:06
    • 0 COMMENTS
    • /
    • 0 LIKES
    • 채경수
    • 2003.01.08 02:32
    • 0 COMMENTS
    • /
    • 0 LIKES