FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Creating and editing shortcuts
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM

Creating and editing shortcuts

Posted: Sat Sep 12, 2015 09:49 AM

Hello,

Is there anyone who can create of change a shortcut in a FWH-application?
Does anyone have a working example?

Thanks a lot in advance.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 1446
Joined: Mon Oct 10, 2005 02:38 PM

Re: Creating and editing shortcuts

Posted: Sat Sep 12, 2015 02:49 PM
driessen wrote:Hello,

Is there anyone who can create of change a shortcut in a FWH-application?
Does anyone have a working example?

Thanks a lot in advance.


Try this:

Code (fw): Select all Collapse
/* ***************************************** */
/*
Function     : pLnk()
Descripcion  : Crear accesos directos
Autor        : Carles Aubia
Fecha        : 04.07.2006
Modificacion : 22.11.2010
Observaciones: El acceso es via CreateObject()...
*/


/* Testing...

FUNCTION Main()

   MsgInfo( pLnk( 'c:\windows\system32\calc.exe' ) )

   MsgInfo( pLnk( 'c:\windows\system32\calc.exe',;
                  'c:\calc2.lnk',, 'calc.exe,0'  ) )

RETU NIL

*/


*---------------------------------------------------
FUNCTION pLnk( cFile, cNameLnk, cWorkingDir, cIcon, cParameters )
*---------------------------------------------------
    LOCAL oShell, oLnk

    DEFAULT cFile        := ''
    DEFAULT cNameLnk     := ''
    DEFAULT cWorkingDir  := ''
    DEFAULT cIcon        := ''

    IF !File( cFile )
       RETU .F.
    ENDIF

    IF Empty( cNameLnk )

       cNameLnk := cFilePath( cFile ) + cFileNoExt( cFile ) + '.lnk'

    ENDIF

    IF Empty( cWorkingDir )

       cWorkingDir := cFilePath( cFile )

    ENDIF

    TRY
      oShell := CreateObject( "Wscript.Shell" )
     CATCH
      MsgAlert( 'Error Create object WScript.Shell', 'Error' )
      RETU  .F.
    END

    oLnk                  := oShell:CreateShortcut( cNameLnk )

    oLnk:TargetPath       := cFile

    If !Empty(cParameters)
        oLnk:Arguments := cParameters
    //  Else
    //    oLnk:TargetPath       := cFile + '"' + cParameters
    EndIf

    oLnk:WindowStyle      := 3

    IF !Empty( cIcon )
        oLnk:IconLocation     := cIcon
    ENDIF

    IF !Empty( cWorkingDir )
        oLnk:WorkingDirectory := cWorkingDir
    ENDIF

*    oLnk:Description      := 'Hola calc...'
*    oLnk:Hotkey           := "CTRL+ALT+SHIFT+X"

    oLnk:Save()


RETU .T.
/* ***************************************** */


Thansk to Carles Aubia.

Un Saludo

Carlos G.



FiveWin 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM

Re: Creating and editing shortcuts

Posted: Sat Sep 12, 2015 04:47 PM

Thanks a lot.

I'll try it out.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Continue the discussion