<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=41450&amp;view=findpost&amp;p=269669</guid>
        <pubDate>Wed, 24 Dec 2003 14:27:44 +0000</pubDate>
        <title>Читаем файлы .LNK</title>
        <link>https://forum.sources.ru/index.php?showtopic=41450&amp;view=findpost&amp;p=269669</link>
        <description><![CDATA[Vit:  <!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b></b> </td></tr><tr><td id='CODE'><!--ec1-->uses &nbsp;<br>&nbsp; ShlObj, &nbsp;<br>&nbsp; ComObj, &nbsp;<br>&nbsp; ActiveX, &nbsp;<br>&nbsp; CommCtrl; &nbsp;<br><br>type &nbsp;<br>&nbsp; PShellLinkInfoStruct = ^TShellLinkInfoStruct; &nbsp;<br>&nbsp; TShellLinkInfoStruct = record &nbsp;<br>&nbsp; &nbsp; FullPathAndNameOfLinkFile&#58; array&#91;0..MAX_PATH&#93; of Char; &nbsp;<br>&nbsp; &nbsp; FullPathAndNameOfFileToExecute&#58; array&#91;0..MAX_PATH&#93; of Char; &nbsp;<br>&nbsp; &nbsp; ParamStringsOfFileToExecute&#58; array&#91;0..MAX_PATH&#93; of Char; &nbsp;<br>&nbsp; &nbsp; FullPathAndNameOfWorkingDirectroy&#58; array&#91;0..MAX_PATH&#93; of Char; &nbsp;<br>&nbsp; &nbsp; Description&#58; array&#91;0..MAX_PATH&#93; of Char; &nbsp;<br>&nbsp; &nbsp; FullPathAndNameOfFileContiningIcon&#58; array&#91;0..MAX_PATH&#93; of Char; &nbsp;<br>&nbsp; &nbsp; IconIndex&#58; Integer; &nbsp;<br>&nbsp; &nbsp; HotKey&#58; Word; &nbsp;<br>&nbsp; &nbsp; ShowCommand&#58; Integer; &nbsp;<br>&nbsp; &nbsp; FindData&#58; TWIN32FINDDATA; &nbsp;<br>&nbsp; end; &nbsp;<br><br>procedure GetLinkInfo&#40;lpShellLinkInfoStruct&#58; PShellLinkInfoStruct&#41;; &nbsp;<br>var &nbsp;<br>&nbsp; ShellLink&#58; IShellLink; &nbsp;<br>&nbsp; PersistFile&#58; IPersistFile; &nbsp;<br>&nbsp; AnObj&#58; IUnknown; &nbsp;<br>begin &nbsp;<br>&nbsp; // access to the two interfaces of the object &nbsp;<br>&nbsp; AnObj &nbsp; &nbsp; &nbsp; &#58;= CreateComObject&#40;CLSID_ShellLink&#41;; &nbsp;<br>&nbsp; ShellLink &nbsp; &#58;= AnObj as IShellLink; &nbsp;<br>&nbsp; PersistFile &#58;= AnObj as IPersistFile; &nbsp;<br><br>&nbsp; // Opens the specified file and initializes an object from the file contents. &nbsp;<br>&nbsp; PersistFile.Load&#40;PWChar&#40;WideString&#40;lpShellLinkInfoStruct^.FullPathAndNameOfLinkFile&#41;&#41;, 0&#41;; &nbsp;<br>&nbsp; with ShellLink do &nbsp;<br>&nbsp; begin &nbsp;<br>&nbsp; &nbsp; // Retrieves the path and file name of a Shell link object. &nbsp;<br>&nbsp; &nbsp; GetPath&#40;lpShellLinkInfoStruct^.FullPathAndNameOfFileToExecute, &nbsp;<br>&nbsp; &nbsp; &nbsp; SizeOf&#40;lpShellLinkInfoStruct^.FullPathAndNameOfLinkFile&#41;, &nbsp;<br>&nbsp; &nbsp; &nbsp; lpShellLinkInfoStruct^.FindData, &nbsp;<br>&nbsp; &nbsp; &nbsp; SLGP_UNCPRIORITY&#41;; &nbsp;<br><br>&nbsp; &nbsp; // Retrieves the description string for a Shell link object. &nbsp;<br>&nbsp; &nbsp; GetDescription&#40;lpShellLinkInfoStruct^.Description, &nbsp;<br>&nbsp; &nbsp; &nbsp; SizeOf&#40;lpShellLinkInfoStruct^.Description&#41;&#41;; &nbsp;<br><br>&nbsp; &nbsp; // Retrieves the command-line arguments associated with a Shell link object. &nbsp;<br>&nbsp; &nbsp; GetArguments&#40;lpShellLinkInfoStruct^.ParamStringsOfFileToExecute, &nbsp;<br>&nbsp; &nbsp; &nbsp; SizeOf&#40;lpShellLinkInfoStruct^.ParamStringsOfFileToExecute&#41;&#41;; &nbsp;<br><br>&nbsp; &nbsp; // Retrieves the name of the working directory for a Shell link object. &nbsp;<br>&nbsp; &nbsp; GetWorkingDirectory&#40;lpShellLinkInfoStruct^.FullPathAndNameOfWorkingDirectroy, &nbsp;<br>&nbsp; &nbsp; &nbsp; SizeOf&#40;lpShellLinkInfoStruct^.FullPathAndNameOfWorkingDirectroy&#41;&#41;; &nbsp;<br><br>&nbsp; &nbsp; // Retrieves the location &#40;path and index&#41; of the icon for a Shell link object. &nbsp;<br>&nbsp; &nbsp; GetIconLocation&#40;lpShellLinkInfoStruct^.FullPathAndNameOfFileContiningIcon, &nbsp;<br>&nbsp; &nbsp; &nbsp; SizeOf&#40;lpShellLinkInfoStruct^.FullPathAndNameOfFileContiningIcon&#41;, &nbsp;<br>&nbsp; &nbsp; &nbsp; lpShellLinkInfoStruct^.IconIndex&#41;; &nbsp;<br><br>&nbsp; &nbsp; // Retrieves the hot key for a Shell link object. &nbsp;<br>&nbsp; &nbsp; GetHotKey&#40;lpShellLinkInfoStruct^.HotKey&#41;; &nbsp;<br><br>&nbsp; &nbsp; // Retrieves the show &#40;SW_&#41; command for a Shell link object. &nbsp;<br>&nbsp; &nbsp; GetShowCmd&#40;lpShellLinkInfoStruct^.ShowCommand&#41;; &nbsp;<br>&nbsp; end; &nbsp;<br>end; &nbsp;<br><br>procedure TForm1.Button1Click&#40;Sender&#58; TObject&#41;; &nbsp;<br>const &nbsp;<br>&nbsp; br = #13#10; &nbsp;<br>var &nbsp;<br>&nbsp; LinkInfo&#58; TShellLinkInfoStruct; &nbsp;<br>&nbsp; s&#58; string; &nbsp;<br>begin &nbsp;<br>&nbsp; FillChar&#40;LinkInfo, SizeOf&#40;LinkInfo&#41;, #0&#41;; &nbsp;<br>&nbsp; LinkInfo.FullPathAndNameOfLinkFile &#58;= &#39;C&#58;&#092;WINNT&#092;Profiles&#092;user&#092;Desktop&#092;FileName.lnk&#39;; &nbsp;<br>&nbsp; GetLinkInfo&#40;@LinkInfo&#41;; &nbsp;<br>&nbsp; with LinkInfo do &nbsp;<br>&nbsp; &nbsp; s &#58;= FullPathAndNameOfLinkFile + br + &nbsp;<br>&nbsp; &nbsp; &nbsp; FullPathAndNameOfFileToExecute + br + &nbsp;<br>&nbsp; &nbsp; &nbsp; ParamStringsOfFileToExecute + br + &nbsp;<br>&nbsp; &nbsp; &nbsp; FullPathAndNameOfWorkingDirectroy + br + &nbsp;<br>&nbsp; &nbsp; &nbsp; Description + br + &nbsp;<br>&nbsp; &nbsp; &nbsp; FullPathAndNameOfFileContiningIcon + br + &nbsp;<br>&nbsp; &nbsp; &nbsp; IntToStr&#40;IconIndex&#41; + br + &nbsp;<br>&nbsp; &nbsp; &nbsp; IntToStr&#40;LoByte&#40;HotKey&#41;&#41; + br + &nbsp;<br>&nbsp; &nbsp; &nbsp; IntToStr&#40;HiByte&#40;HotKey&#41;&#41; + br + &nbsp;<br>&nbsp; &nbsp; &nbsp; IntToStr&#40;ShowCommand&#41; + br + &nbsp;<br>&nbsp; &nbsp; &nbsp; FindData.cFileName + br + &nbsp;<br>&nbsp; &nbsp; &nbsp; FindData.cAlternateFileName; &nbsp;<br>&nbsp; Memo1.Lines.Add&#40;s&#41;; &nbsp;<br>end; &nbsp;<!--c2--></td></tr></table><div class='postcolor'><!--ec2--> ]]></description>
        <author>Vit</author>
        <category>Системные функции, WinAPI, работа с железом</category>
      </item>
	
      </channel>
      </rss>
	