FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ZLINK
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
ZLINK
Posted: Fri Jun 09, 2017 05:31 PM

Someone have this class run on win 7 or win 10 ?
or have a function to create lnk on desktop ? thanks

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: ZLINK
Posted: Fri Jun 09, 2017 05:42 PM
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: ZLINK
Posted: Fri Jun 09, 2017 07:00 PM

not run

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: ZLINK
Posted: Fri Jun 09, 2017 08:16 PM
Code (fw): Select all Collapse
// Criar Icone de Atalho no Desktop ********************************************
FUNCTION CriarIconeDesktop( cTitulo )
LOCAL aShortCut, oWSHShell
 
IF FILE( GETENV('HOMEDRIVE') + GETENV('HOMEPATH') + "\Desktop\" + cTitulo + ".lnk")
  RETURN NIL
ENDIF
 
IF !MsgYesNo( "Não foi localizado o Ícone do Sistema no DeskTop !" + CRLF + CRLF + "Deseja Criar Agora ?", "Aviso do Sistema" )
RETURN NIL
ENDIF
 
TRY
 
oWSHShell := CreateObject( "WScript.Shell" )
 
CATCH error
 
  MsgStop( "Não foi possível criar o Ícone do Sistema no DeskTop !" + CRLF + CRLF + "Entre em Contato com o Administrador do Sistema.", "Erro de Criação" )
RETURN .F.
 
END TRY
 
IF !IsDirectory( GETENV("HOMEDRIVE") + GETENV("HOMEPATH") + "\Desktop" )
RELEASE oWSHShell
RETURN .F.
ENDIF
 
aShortCut := oWSHShell:CreateShortcut( GETENV('HOMEDRIVE') + GETENV('HOMEPATH') + "\Desktop\" + cTitulo + ".lnk" )
aShortCut:TargetPath := CaminhoExecutavel() + "\" + NomeExecutavel()
aShortCut:WorkingDirectory := CaminhoExecutavel() + "\"
aShortCut:Save()
 
RELEASE oWSHShell
 
IF !FILE( GETENV('HOMEDRIVE') + GETENV('HOMEPATH') + "\Desktop\" + cTitulo + ".lnk" )
RETURN .F.
ENDIF
 
RETURN .T.
 
FUNCTION NomeExecutavel( lPath )
LOCAL nPos, cRet
 
IF EMPTY(lpath)
 
nPos := RAT( "\", hb_Argv(0) )
cRet := SUBS( hb_Argv(0), nPos+1 )
 
ELSE
 
cRet := hb_Argv(0)
 
ENDIF
 
RETURN cRet
 
FUNCTION CaminhoExecutavel()
RETURN SUBS( NomeExecutavel( .T. ), 1, ( LEN( NomeExecutavel( .T. ) ) - LEN( NomeExecutavel() ) ) - 1 )
// Criar Icone de Atalho no Desktop ********************************************
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: ZLINK
Posted: Fri Jun 09, 2017 08:21 PM
Code (fw): Select all Collapse
FUNCTION Main()

   LOCAL cTitulo := "Nome do Seu Aplicativo"

   CriarIconeDesktop( cTitulo )

RETURN NIL

    // Criar Icone de Atalho no Desktop ********************************************
FUNCTION CriarIconeDesktop( cTitulo )
LOCAL aShortCut, oWSHShell, strDesktop := ""
        oReg := TReg32():New( HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" )
        strDesktop := oReg:Get("Desktop")
    oReg:Close()
        IF LEFT(strDesktop,1) == "%"
        strDesktop := GETENV('USERPROFILE') + "\Desktop\"
    ENDIF
        IF FILE( strDesktop + "\" + cTitulo + ".lnk" )
       RETURN NIL
    ENDIF
        IF !MsgYesNo( "Não foi localizado o Ícone do Sistema no DeskTop !" + CRLF + CRLF + "Deseja Criar Agora ?", "Aviso do Sistema" )
        RETURN NIL
    ENDIF
        TRY
            oWSHShell := CreateObject( "WScript.Shell" )
        CATCH error
           MsgStop( "Não foi possível criar o Ícone do Sistema no DeskTop !" + CRLF + CRLF + "Entre em Contato com o Administrador do Sistema.", "Erro de Criação" )
        RETURN .F.
        END TRY
        aShortCut := oWSHShell:CreateShortcut( strDesktop + "\" + cTitulo + ".lnk" )
        aShortCut:TargetPath := CaminhoExecutavel() + "\" + NomeExecutavel()
        aShortCut:WorkingDirectory := CaminhoExecutavel() + "\"
        aShortCut:Description := "Aplicativo para Gerenciamento Administrativo"
        aShortCut:WindowStyle := 1
    aShortCut:Save()

    RELEASE oWSHShell
    RELEASE aShortCut

RETURN .T.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: ZLINK
Posted: Fri Jun 09, 2017 08:26 PM

iMUST WRITE A COMAND WITH PARAMETERS
SAMPLE

TEST.EXE XXXX XXXX

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: ZLINK
Posted: Fri Jun 09, 2017 08:44 PM
it create the link but write the command bad
I explain you

aShortCut := oWSHShell:CreateShortcut( strDesktop + "\" + cTitulo + ".lnk" )
aShortCut:Description := "EasyBus 1.00"
aShortCut:WindowStyle := 1
aShortCut:IconLocation := 'C:\work\errori\tavoli\bus.ico'
aShortCut:WorkingDirectory := 'C:\work\errori\tavoli\'
aShortCut:TargetPath := 'C:\work\errori\tavoli\test.exe 1024 700'


this line aShortCut:TargetPath := 'C:\work\errori\tavoli\test.exe 1024 700'

write the command 'C:\work\errori\tavoli\test.exe 1024 700' with "

but if I eraseit with hand on lnk then the lnk run ok
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: ZLINK resolves !!!
Posted: Fri Jun 09, 2017 09:13 PM

resolved !!!
now run ok

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: ZLINK
Posted: Mon Jun 12, 2017 05:35 PM

Very well. In the future, test before you complain. It is very difficult to understand your questions. Greetings.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: ZLINK
Posted: Mon Jun 12, 2017 05:47 PM
I resolved seeing on https://stackoverflow.com
the problem was the parameters give to exe

I correct your source
see aShortCut:Arguments := cArguments

Code (fw): Select all Collapse
#include "FiveWin.ch"

// creare le icone sul desktop

#define HKEY_CURRENT_USER 2147483649
#define HKEY_LOCAL_MACHINE 2147483650


FUNCTION Main()

   Local cTitle                := "EasyBus 1.00"
   Local cFile                 := 'C:\work\errori\tavoli\test.exe'
   ]Local cArguments            := "1024 700"
   Local cWorkingDirectory     := 'C:\work\errori\tavoli\'
   Local cIconPath             := 'C:\work\errori\tavoli\bus.ico'
   Local cDescription          := "EasyBus 1.00"
   Local nWindowsStyle         := 6

   CreateIconeDesktop(cTitle,cFile,cDescription,cArguments,cIconPath,cWorkingDirectory,nWindowsStyle)

   RETURN NIL
 //------------------------------------------------------------------------------------------------//

   Function CreateIconeDesktop(cTitle,cFile,cDescription,cArguments,cIconPath,cWorkingDirectory,nWindowsStyle)
    LOCAL aShortCut, oWSHShell, strDesktop := ""

     oReg := TReg32():New( HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" )
     strDesktop := oReg:Get("Desktop")
      oReg:Close()

      IF LEFT(strDesktop,1) == "%"
        strDesktop := GETENV('USERPROFILE') + "\Desktop\"
    ENDIF

     IF FILE( strDesktop + "\" + cTitle + ".lnk" )
       RETURN NIL
    ENDIF

     IF !MsgYesNo( "Non è stato trovato nella icona di sistema desktop" + CRLF + CRLF + "Desideri crearlo ora ?", "Attenzione" )
        RETURN NIL
    ENDIF

     TRY
        oWSHShell := CreateObject( "WScript.Shell" )

        CATCH error
           MsgStop( "Impossibile creare l'icona di sistema sul desktop !", "Errore" )
        RETURN .F.
     END TRY

     aShortCut := oWSHShell:CreateShortcut( strDesktop + "\" + cTitle + ".lnk" )

   IF !Empty( nWindowsStyle )
    aShortCut:Description      := cDescription
 Endif

    IF !Empty( nWindowsStyle )
       aShortCut:WindowStyle      := nWindowsStyle
    else
       aShortCut:WindowStyle      := 4
    Endif

     IF !Empty( cIconPath )
           aShortCut:IconLocation     := cIconPath
       Endif

    IF !Empty( cWorkingDirectory )
       aShortCut:WorkingDirectory := cWorkingDirectory
     Endif

     aShortCut:TargetPath       := cFile


        If !empty(cArguments)
             aShortCut:Arguments        := cArguments
          Endif


    aShortCut:Save()

    RELEASE oWSHShell
    RELEASE aShortCut

RETURN .T.
//--------------------------------------------------------------------------------------------------------//
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: ZLINK
Posted: Mon Jun 12, 2017 07:00 PM

Very good!! Congratulations.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion