Получаем информацию о ярлыке
Получаем информацию о ярлыке
Получаем информацию о ярлыке shlobj, comobj, activex, commctrl; type pshelllinkinfostruct = ^tshelllinkinfostruct; tshelllinkinfostruct = record fullpathandnameoflinkfile: array[0..max_path] of char; fullpathandnameoffiletoexecute: array[0..max_path] of char; paramstringsoffiletoexecute: array[0..max_path] of char; fullpathandnameofworkingdirectroy: array[0..max_path] of char; description: array[0..max_path] of char; fullpathandnameoffilecontiningicon: array[0..max_path] of char; iconindex: integer; hotkey: word; showcommand: integer; finddata: twin32finddata; end; procedure getlinkinfo(lpshelllinkinfostruct: pshelllinkinfostruct); var shelllink: ishelllink; persistfile: ipersistfile; anobj: iunknown; begin // access to the two interfaces of the object anobj := createcomobject(clsid_shelllink); shelllink := anobj as ishelllink; persistfile := anobj as ipersistfile; // opens the specified file and initializes an object from the file contents. persistfile.load(pwchar(widestring(lpshelllinkinfostruct^.fullpathandnameoflinkfile)), 0); with shelllink do begin // retrieves the path and file name of a shell link object. getpath(lpshelllinkinfostruct^.fullpathandnameoffiletoexecute, sizeof(lpshelllinkinfostruct^.fullpathandnameoflinkfile), lpshelllinkinfostruct^.finddata, slgp_uncpriority); // retrieves the description string for a shell link object. getdescription(lpshelllinkinfostruct^.description, sizeof(lpshelllinkinfostruct^.description)); // retrieves the command-line arguments associated with a shell link object. getarguments(lpshelllinkinfostruct^.paramstringsoffiletoexecute, sizeof(lpshelllinkinfostruct^.paramstringsoffiletoexecute)); // retrieves the name of the working directory for a shell link object. getworkingdirectory(lpshelllinkinfostruct^.fullpathandnameofworkingdirectroy, sizeof(lpshelllinkinfostruct^.fullpathandnameofworkingdirectroy)); // retrieves the location (path and index) of the icon for a shell link object. geticonlocation(lpshelllinkinfostruct^.fullpathandnameoffilecontiningicon, sizeof(lpshelllinkinfostruct^.fullpathandnameoffilecontiningicon), lpshelllinkinfostruct^.iconindex); // retrieves the hot key for a shell link object. gethotkey(lpshelllinkinfostruct^.hotkey); // retrieves the show (sw_) command for a shell link object. getshowcmd(lpshelllinkinfostruct^.showcommand); end; end; procedure tform1.button1click(sender: tobject); const br = #13#10; var linkinfo: tshelllinkinfostruct; s: string; begin fillchar(linkinfo, sizeof(linkinfo), #0); linkinfo.fullpathandnameoflinkfile := 'c:winntprofilesuserdesktopfilename.lnk'; getlinkinfo(@linkinfo); with linkinfo do s := fullpathandnameoflinkfile + br + fullpathandnameoffiletoexecute + br + paramstringsoffiletoexecute + br + fullpathandnameofworkingdirectroy + br + description + br + fullpathandnameoffilecontiningicon + br + inttostr(iconindex) + br + inttostr(lobyte(hotkey)) + br + inttostr(hibyte(hotkey)) + br + inttostr(showcommand) + br + finddata.cfilename + br + finddata.calternatefilename; memo1.lines.add(s); end;