Create shortcut for accessing URL

Post Reply
User avatar
don lowenstein
Posts: 201
Joined: Mon Oct 17, 2005 9:09 pm
Been thanked: 3 times
Contact:

Create shortcut for accessing URL

Post by don lowenstein »

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
User avatar
Antonio Linares
Site Admin
Posts: 42548
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 78 times
Contact:

Re: Create shortcut for accessing URL

Post by Antonio Linares »

Dear Don,

Not sure if you mean this:

Code: Select all | Expand

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:

Code: Select all | Expand

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
User avatar
leandro
Posts: 1752
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Has thanked: 38 times
Been thanked: 10 times
Contact:

Re: Create shortcut for accessing URL

Post by leandro »

o te refieres a esto?

viewtopic.php?p=274664#p274664
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 24.09 ] [ xHarbour 64 bits) ]
User avatar
don lowenstein
Posts: 201
Joined: Mon Oct 17, 2005 9:09 pm
Been thanked: 3 times
Contact:

Re: Create shortcut for accessing URL

Post by don lowenstein »

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
User avatar
don lowenstein
Posts: 201
Joined: Mon Oct 17, 2005 9:09 pm
Been thanked: 3 times
Contact:

Re: Create shortcut for accessing URL

Post by don lowenstein »

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
User avatar
don lowenstein
Posts: 201
Joined: Mon Oct 17, 2005 9:09 pm
Been thanked: 3 times
Contact:

Re: Create shortcut for accessing URL

Post by don lowenstein »

PROCEDURE CreateURLShortcut(cFileName, cURL)

This worked perfectly - Thanks.
Don Lowenstein
www.laapc.com
Post Reply