Create desktop shortcut

HMG Samples and Enhancements

Moderator: Rathinagiri

User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Create desktop shortcut

Post by bpd2000 »

Sample to create desktop shortcut
new.rar
(606 Bytes) Downloaded 504 times
[u]Moderator Notes[/u] (Pablo César) wrote:Topic moved from Forum en Español.
BPD
Convert Dream into Reality through HMG
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Create desktop shortcut

Post by esgici »

bpd2000 wrote:Sample to create desktop shortcut
Hi Dave

Thank you, nice and useful share :arrow:

Regards
Viva INTERNATIONAL HMG :D
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Create desktop shortcut

Post by Rathinagiri »

Fantastic!

Can we have a User Defined Function for the next version HFCL?

Code: Select all

*------------------------------------------------------------------------------*
FUNCTION CreateDesktopShortcut( cTarget, cTitle, cDescription, lFile )
*------------------------------------------------------------------------------*
	default lFile := .t.
	local WshShell := CreateObject("WScript.Shell")
	local DesktopFolder := WshShell:SpecialFolders("Desktop")
   local lSuccess := .f.
   
   do case
   case lFile
      FileShortcut := WshShell:CreateShortcut(DesktopFolder + "\" + cTitle + ".lnk" )
      FileShortcut:TargetPath := cTarget
      FileShortcut:Description := cDescription
      FileShortcut:WorkingDirectory := DesktopFolder
      FileShortcut:Save()
      lSuccess := .t.
   otherwise 
	   URLShortcut := WshShell:CreateShortcut(DesktopFolder + "\" + cTitle + ".url" )
	   URLShortcut:TargetPath := cTarget
      URLShortcut:Save()
      lSuccess := .t.
   endcase
  
	WshShell := Nil

RETURN lSuccess

East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Create desktop shortcut

Post by esgici »

rathinagiri wrote:Can we have a User Defined Function for the next version HFCL?
It will be nice and useful :arrow:

Does will be more useful two separate function instead of one :

Code: Select all

FUNCTION DTopShCutFil( cTarget, cTitle, cDescription )
   LOCAL lSuccess := .F.
   IF FILE( cTarget )
       ...
       lSuccess := FILE( cTarget + ".LNK" )
   ENDIF
RETURN lSuccess

FUNCTION DTopShCutURL( cTarget, cTitle, cDescription )
    LOCAL lSuccess := .F.
    IF IsURL( cTarget )    // I don't know how will be this  IsURL() :(
        ...
        lSuccess := FILE( cTarget + ".URL" )
   ENDIF
RETURN lSuccess 
Regards
Viva INTERNATIONAL HMG :D
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Create desktop shortcut

Post by bpd2000 »

rathinagiri wrote:Fantastic!

Can we have a User Defined Function for the next version HFCL?
Addition to HFCL will be very useful to HMG users
BPD
Convert Dream into Reality through HMG
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Create desktop shortcut

Post by mol »

Very fine functions!
But, if I can ask, please, do not shorten the names of these function - old 10-char long names are the past!
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Create desktop shortcut

Post by esgici »

mol wrote:old 10-char long names are the past!
Hi Marek,

You are right :arrow:

Old men doesn't forget easly their old habits ;)

By the way;

Code: Select all

  lSuccess := FILE( cTarget + ".LNK" )
   ...
  lSuccess := FILE( cTarget + ".URL" )
aren't correct :(

Please supply correct file name instead of cTarget .

Regards
Viva INTERNATIONAL HMG :D
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Create desktop shortcut

Post by esgici »

My suggestion is :
MakShCut.zip
Two functions : MakeFDirShortCut() and MakeInternetShortCut()
(920 Bytes) Downloaded 432 times
Regards
Viva INTERNATIONAL HMG :D
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Create desktop shortcut

Post by Rathinagiri »

Super cool Esgici. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Create desktop shortcut

Post by bpd2000 »

New example with shortcut remove function from desktop
Attachments
LinkCreate.rar
(758 Bytes) Downloaded 426 times
Last edited by bpd2000 on Fri Nov 02, 2012 3:23 pm, edited 1 time in total.
BPD
Convert Dream into Reality through HMG
Post Reply