Wednesday, September 2, 2020

Create an Internet Shortcut (.URL) File Using Delphi

Make an Internet Shortcut (.URL) File Using Delphi In contrast to ordinary .LNK alternate ways (that point to a report or an application), Internet Shortcuts point to a URL (web record). Heres how to make a .URL record, or Internet Shortcut, utilizing Delphi. The Internet Shortcut object is utilized to make alternate routes to Internet locales or web records. Web alternate routes are various from normal easy routes (which contain information in a twofold record) that point to an archive or an application. Such content documents with a .URL expansion have their substance in INI record design. The most effortless approach to peer inside a .URL document is to open it inside Notepad. The substance (in its least difficult type) of an Internet Shortcut could resemble this: [InternetShortcut] URLhttp://delphi.about.com As should be obvious, .URL records have an INI document position. The URL speaks to the location area of the page to stack. It must determine a completely qualifying URL with the organization 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 webpage (or a web report) related with the alternate route. Heres a straightforward Delphi capacity to make a .URL document. The CreateInterentShortcut system makes a URL alternate way record with the gave document 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 chronicle) and afterward make a .URL easy route to have the option to get to a disconnected form 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 without much of a stretch concentrate the URL from an Internet Shortcut (.url) record. Determining the .URL Icon One of the neater highlights of the .URL document design is that you can change the easy routes 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 file 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 record position 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 document. You just need to indicate the record://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 system 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 way to your program: utilizes IniFiles, ShlObj;...function GetDesktopPath: string;//get the area of the Desktop foldervar   DesktopPidl: PItemIDList;   DesktopPath: cluster [0..MAX_PATH] of Char;begin   SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, DesktopPidl) ;   SHGetPathFromIDList(DesktopPidl, DesktopPath) ;   Result : IncludeTrailingPathDelimiter(DesktopPath) ; end; (*GetDesktopPath*) methodology CreateSelfShortcut;const   FileProtocol record://; 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,        Application.ExeName) ;  â finally     Free;  â end;end; (*CreateSelfShortcut*) Note: just call CreateSelfShortcut to make an easy route to your program on the Desktop. When to Use .URL Those convenient .URL records will be valuable for all intents and purposes each venture. 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.