Wednesday, September 2, 2020

Create an Internet Shortcut (.URL) File Using Delphi

Make an Internet Shortcut (.URL) File Using Delphi In contrast to normal .LNK alternate routes (that point to an archive or an application), Internet Shortcuts point to a URL (web report). Heres how to make a .URL document, or Internet Shortcut, utilizing Delphi. The Internet Shortcut object is utilized to make easy routes to Internet destinations or web reports. Web alternate ways are differing from standard easy routes (which contain information in a twofold record) that point to a report or an application. Such content documents with a .URL augmentation have their substance in INI record group. The least demanding approach to peer inside a .URL document is to open it inside Notepad. The substance (in its most straightforward type) of an Internet Shortcut could resemble this: [InternetShortcut] URLhttp://delphi.about.com As should be obvious, .URL records have an INI document group. The URL speaks to the location area of the page to stack. It must indicate a completely qualifying URL with the arrangement convention://server/page.. Basic Delphi Function to Create a .URL File You can without much of a stretch automatically make an Internet easy route in the event that you have the URL of the page to which you need to connect. At the point when double tapped, the default program is propelled and shows the website (or a web record) related with the easy route. Heres a straightforward Delphi capacity to make a .URL document. The CreateInterentShortcut strategy makes a URL easy route document with the gave record name (FileName boundary) for the given URL (LocationURL), overwriting any current Internet Shortcut with a similar name. utilizes IniFiles;...procedure CreateInternetShortcut(const FileName, LocationURL : string) ;start  â with TIniFile.Create(FileName) do  â try     WriteString(        InternetShortcut,        URL,        LocationURL) ;  â finally     Free;  end;end; (*CreateInterentShortcut*) Heres an example use: /make a .URL document named About Delphi Programming/in the root envelope of the C drive/let it point to http://delphi.about.com CreateInterentShortcut(c:About Delphi Programming.URL , http://delphi.about.com ) ; A couple of notes: You could spare a site page as MHT (web file) and afterward make a .URL alternate route to have the option to get to a disconnected variant of a web document.You must give a full record name, alongside the .URL augmentation, for the FileName parameter.If you as of now have an Internet Shortcut you are keen on, you can undoubtedly extricate the URL from an Internet Shortcut (.url) record. Determining the .URL Icon One of the neater highlights of the .URL document position is that you can change the alternate ways related symbol. As a matter of course the .URL will convey the symbol of the default program. On the off chance that you need to change the symbol, you just need to add two extra fields to the .URL record, as in: [InternetShortcut] URLhttp://delphi.about.com IconIndex0 IconFileC:MyFolderMyDelphiProgram.exe The IconIndex and IconFile fields let you determine the symbol for the .URL easy route. The IconFile could highlight your applications exe record (IconIndex is the list of the symbol as an asset inside the exe). Web Shortcut to Open a Regular Document or an Application Being called an Internet Shortcut, a .URL document group doesn't allow you to utilize it for something different, for example, a standard application alternate route. Note that the URL field must be indicated in the convention://server/page group. For instance, you could make an Internet Shortcut symbol on the Desktop that focuses to your projects exe record. You just need to determine the document://for the convention. At the point when you double tap on such a .URL record, your application will be executed. Heres a case of such an Internet Shortcut: [InternetShortcut] URL record://c:MyAppsMySuperDelphiProgram.exe IconIndex 0 IconFile C:MyFolderMyDelphiProgram.exe Heres a strategy that puts an Internet Shortcut on the Desktop, the alternate route focuses to the *current* application. You can utilize this code to make an alternate route to your program: utilizes IniFiles, ShlObj;...function GetDesktopPath: string;//get the area of the Desktop foldervar   DesktopPidl: PItemIDList;   DesktopPath: exhibit [0..MAX_PATH] of Char;begin   SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, DesktopPidl) ;   SHGetPathFromIDList(DesktopPidl, DesktopPath) ;   Result : IncludeTrailingPathDelimiter(DesktopPath) ; end; (*GetDesktopPath*) method CreateSelfShortcut;const   FileProtocol document://; var   ShortcutTitle : string;begin   ShortcutTitle : Application.Title .URL;  â with TIniFile.Create(GetDesktopPath ShortcutTitle) do  â try     WriteString(        InternetShortcut,        URL,        FileProtocol Application.ExeName) ;     WriteString(        InternetShortcut,        IconIndex,  â â â â â â 0) ;     WriteString(        InternetShortcut,        IconFile,        App lication.ExeName) ;  â finally     Free;  â end;end; (*CreateSelfShortcut*) Note: essentially call CreateSelfShortcut to make an alternate route to your program on the Desktop. When to Use .URL Those helpful .URL records will be valuable for all intents and purposes each undertaking. At the point when you make an arrangement for your applications, incorporate a .URL alternate route inside the Start menu-let clients have the most advantageous approach to visit your site for updates, models, or help documents.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.