ZLINK

ZLINK

Postby Silvio.Falconi » Fri Jun 09, 2017 5: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6765
Joined: Thu Oct 18, 2012 7:17 pm

Re: ZLINK

Postby cnavarro » Fri Jun 09, 2017 5: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
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: ZLINK

Postby Silvio.Falconi » Fri Jun 09, 2017 7:00 pm

not run
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6765
Joined: Thu Oct 18, 2012 7:17 pm

Re: ZLINK

Postby karinha » Fri Jun 09, 2017 8:16 pm

Code: Select all  Expand view

// 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
User avatar
karinha
 
Posts: 7206
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: ZLINK

Postby karinha » Fri Jun 09, 2017 8:21 pm

Code: Select all  Expand view

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
User avatar
karinha
 
Posts: 7206
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: ZLINK

Postby Silvio.Falconi » Fri Jun 09, 2017 8: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6765
Joined: Thu Oct 18, 2012 7:17 pm

Re: ZLINK

Postby Silvio.Falconi » Fri Jun 09, 2017 8: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6765
Joined: Thu Oct 18, 2012 7:17 pm

Re: ZLINK resolves !!!

Postby Silvio.Falconi » Fri Jun 09, 2017 9:13 pm

resolved !!!
now run ok
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6765
Joined: Thu Oct 18, 2012 7:17 pm

Re: ZLINK

Postby karinha » Mon Jun 12, 2017 5: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
User avatar
karinha
 
Posts: 7206
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: ZLINK

Postby Silvio.Falconi » Mon Jun 12, 2017 5: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: Select all  Expand view

#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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6765
Joined: Thu Oct 18, 2012 7:17 pm

Re: ZLINK

Postby karinha » Mon Jun 12, 2017 7:00 pm

Very good!! Congratulations.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7206
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 10 guests