Page 1 of 2

Create desktop shortcut

Posted: Wed Oct 31, 2012 1:49 pm
by bpd2000
Sample to create desktop shortcut
new.rar
(606 Bytes) Downloaded 528 times
[u]Moderator Notes[/u] (Pablo César) wrote:Topic moved from Forum en Español.

Re: Create desktop shortcut

Posted: Wed Oct 31, 2012 2:36 pm
by esgici
bpd2000 wrote:Sample to create desktop shortcut
Hi Dave

Thank you, nice and useful share :arrow:

Regards

Re: Create desktop shortcut

Posted: Wed Oct 31, 2012 3:15 pm
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


Re: Create desktop shortcut

Posted: Wed Oct 31, 2012 4:19 pm
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

Re: Create desktop shortcut

Posted: Wed Oct 31, 2012 4:24 pm
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

Re: Create desktop shortcut

Posted: Wed Oct 31, 2012 4:52 pm
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!

Re: Create desktop shortcut

Posted: Wed Oct 31, 2012 5:14 pm
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

Re: Create desktop shortcut

Posted: Wed Oct 31, 2012 10:19 pm
by esgici
My suggestion is :
MakShCut.zip
Two functions : MakeFDirShortCut() and MakeInternetShortCut()
(920 Bytes) Downloaded 462 times
Regards

Re: Create desktop shortcut

Posted: Thu Nov 01, 2012 2:21 am
by Rathinagiri
Super cool Esgici. :)

Re: Create desktop shortcut

Posted: Fri Nov 02, 2012 9:21 am
by bpd2000
New example with shortcut remove function from desktop