FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Create shortcut for accessing URL
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM
Create shortcut for accessing URL
Posted: Sat Feb 08, 2025 06:25 PM

I'm trying to create a Windows shortcut in Harbour for accessing a URL with my browser.

Has anyone had success doing this?

Thanks in advance for any assistance.

Don Lowenstein
www.laapc.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Create shortcut for accessing URL
Posted: Sat Feb 08, 2025 08:35 PM
Dear Don,

Not sure if you mean this:
PROCEDURE CreateURLShortcut(cFileName, cURL)
   LOCAL hFile

   // Ensure the filename ends with .url
   IF AT(".url", LOWER(cFileName)) == 0
      cFileName += ".url"
   ENDIF

   // Create and write to the file
   hFile := FCreate(cFileName)
   IF hFile != -1
      FWrite(hFile, "[InternetShortcut]" + Chr(13) + Chr(10))
      FWrite(hFile, "URL=" + cURL + Chr(13) + Chr(10))
      FClose(hFile)
   ELSE
      ? "Error creating file:", cFileName
   ENDIF
RETURN

// Usage:
CreateURLShortcut("MyWebShortcut.url", "https://www.example.com")
or maybe this:
PROCEDURE CreateLNKShortcut(cLnkPath, cURL)
   LOCAL oShell, oShortcut

   // Initialize COM (if not already done)
   IF !Empty(GetActiveObject("WScript.Shell"))
      oShell := CreateObject("WScript.Shell")
   ELSE
      ? "COM initialization failed."
      RETURN
   ENDIF

   // Create the shortcut
   oShortcut := oShell:CreateShortcut(cLnkPath)
   oShortcut:TargetPath := "rundll32.exe"
   oShortcut:Arguments := "url.dll,FileProtocolHandler " + cURL
   oShortcut:Save()
RETURN

// Usage:
CreateLNKShortcut("MyWebShortcut.lnk", "https://www.example.com")
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Create shortcut for accessing URL
Posted: Sat Feb 08, 2025 09:27 PM
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM
Re: Create shortcut for accessing URL
Posted: Sat Feb 08, 2025 11:45 PM

Thanks for the suggestions.

I'll test them on Monday.

Antonio, it's good to hear from you. I hope all is well with you and yours.

Don

Don Lowenstein
www.laapc.com
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM
Re: Create shortcut for accessing URL
Posted: Sat Feb 08, 2025 11:50 PM

I noticed that all three of us on this thread joined the FiveTech forum in October 2005.

That's a testament to how good the Fivewin libraries and community are.

I feel privileged to be part of it.

Sincerely, Don

Don Lowenstein
www.laapc.com
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM
Re: Create shortcut for accessing URL
Posted: Mon Feb 10, 2025 02:18 PM

PROCEDURE CreateURLShortcut(cFileName, cURL)

This worked perfectly - Thanks.

Don Lowenstein
www.laapc.com

Continue the discussion