begin process at 2012 02 11 05:43:25
  Trouver un code source :
 
dans
 
Accueil > Forum > 

C++ & C++ .NET

 > 

Windows

 > 

Autre

 > 

Creation d'un programme d'installation


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Creation d'un programme d'installation

mardi 11 juillet 2006 à 12:47:41 | Creation d'un programme d'installation

demorex6

Bonjour a tous.
Je voudrais savoir comment créer un programme qui fait les actions suivantes:
1) verification de l'existence d'un repertoire "C:\ALABA"
    - s'il existe le supprimer avec tout son contenu
    - sinon Executer le programme "Alabama" qui se trouve dans le repertoire courant.
2) Renommer le programme "alabama.exe"  qui se trouve dans "C:\ALABA" en un autre nom
que l'on aura entré au clavier.
3) créer un raccourcis du programme renommé dans "C:\Documents and Settings\All Users\Menu Démarrer\Programmes\Démarrage"

Merci.

mardi 11 juillet 2006 à 13:30:38 | Re : Creation d'un programme d'installation

ben92600

peu etre en utilisant une comment exec qui te renvera -1 ou 1 en fonction de la reussite ou pas de ton execution ,avec un ls ou un truc comme sa
mardi 11 juillet 2006 à 13:30:57 | Re : Creation d'un programme d'installation

ben92600

comment -> commande
mardi 11 juillet 2006 à 15:48:20 | Re : Creation d'un programme d'installation

AlexN

Quelques installateurs logiciel scriptables :

Inno Setup : [ Lien ]
Nullsoft Scriptable Installer System : [ Lien ]

Pour ma part le préféré est NSIS, parce son style de script est proche de la syntaxe assembleur ce que je trouve curieux et amusant.
[ Lien ]
mardi 11 juillet 2006 à 16:06:42 | Re : Creation d'un programme d'installation

demorex6

J'ai essayé NSIS mais je ne trove pas de manuel d'utilisation:
pouvez vous me donner un lien sur l'utilisation de NSIS?
Merci
mardi 11 juillet 2006 à 16:24:55 | Re : Creation d'un programme d'installation

AlexN

Réponse acceptée !
Le programme est fourni avec un chm et plein d'exemples

Sinon voir ici : [ Lien ]
nsis en fr : [ Lien ]


[ Lien ]
mardi 11 juillet 2006 à 16:37:14 | Re : Creation d'un programme d'installation

AlexN

Réponse acceptée !
il existe aussi une GUI (free for personnal use) : Venis IX
mercredi 12 juillet 2006 à 11:59:42 | Re : Creation d'un programme d'installation

demorex6

Merci pour tes reponses AlexN
vendredi 14 juillet 2006 à 02:04:17 | Re : Creation d'un programme d'installation

AlexN

Si cela peut t'être utile, voilà quelques fonctions qui montrent les possibilités d'interface avec le système de fichiers en appelant les fonctions de l'API Win32 depuis nsis et des fonctions de manipulation de chaines de caractères :

Certaines fonctions utilisent la LogicLib, pour simplifier le code. Il faudra insérer un :
!include LogicLib.nsh ; Logic structures and functions

;************************
; File System functions *
;************************

Function FileRequest
;Here is a function to open up the standard Windows File Save/Open dialog.
;This can be called from a Section or Function "forcing" the user to Save/Open a file before the installation continues.
;
;Usage :
;
;Push "0xA01800" ;flags (see below) separated by commas [,]
;Push "open" ;use "open" or "save"
;Push "Zip Files (*.zip)|*.zip" ;file type 1
;Push "All Files (*.*)|*.*" ;file type 2
;Push "Select Zip file to install" ;dialog title
;Call FileRequest
;Pop $R0
;
;$R0 = Selected file or "error" for cancelled
;
;Flags :
;
;    * OFN_READONLY 0x00000001
;    * OFN_OVERWRITEPROMPT 0x00000002
;    * OFN_HIDEREADONLY 0x00000004
;    * OFN_NOCHANGEDIR 0x00000008
;    * OFN_SHOWHELP 0x00000010
;    * OFN_ENABLEHOOK 0x00000020
;    * OFN_ENABLETEMPLATE 0x00000040
;    * OFN_ENABLETEMPLATEHANDLE 0x00000080
;
;    * OFN_NOVALIDATE 0x00000100
;    * OFN_ALLOWMULTISELECT 0x00000200
;    * OFN_EXTENSIONDIFFERENT 0x00000400
;    * OFN_PATHMUSTEXIST 0x00000800
;    * OFN_FILEMUSTEXIST 0x00001000
;    * OFN_CREATEPROMPT 0x00002000
;    * OFN_SHAREAWARE 0x00004000
;    * OFN_NOREADONLYRETURN 0x00008000
;
;    * OFN_NOTESTFILECREATE 0x00010000
;    * OFN_NONETWORKBUTTON 0x00020000
;    * OFN_NOLONGNAMES 0x00040000 ; force no long names for 4.x modules
;    * OFN_EXPLORER 0x00080000 ; new look commdlg
;    * OFN_NODEREFERENCELINKS 0x00100000
;    * OFN_LONGNAMES 0x00200000 ; force long names for 3.x modules
;    * OFN_ENABLEINCLUDENOTIFY 0x00400000 ; send include message to callback
;    * OFN_ENABLESIZING 0x00800000
;
;    * OFN_DONTADDTORECENT 0x02000000
;    * OFN_FORCESHOWHIDDEN 0x10000000 ; Show All files including System and hidden files
;
;Thanks brainsucker and Kichik for help.
;
;-Stu
;
; gaijin : some code fixing
;
    Exch $0  ;title
    Exch
    Exch $1  ;sort type 1
    Exch 2
    Exch $2  ;sort type 2
    Exch 2
    Exch 3
    Exch $R4 ;save/open
    Exch 3
    Exch 4
    Exch $R5 ;flag
    Exch 4   ; At this point, stack status is from top : $1 $0 $2 $R4 $R5
   
    Exch     ; Fix : At this point, stack status is from top : $0 $1 $2 $R4 $R5
    Exch 4   ; Fix : At this point, stack status is from top : $R5 $0 $2 $R4 $0
   
    Push $3
    Push $4
    Push $5  ;type 1 / 1
    Push $6  ;tupe 1 / 2
    Push $7  ;type 2 / 1
    Push $8  ;type 2 / 2
    Push $9
    Push $R0 ;len 1 / 1
    Push $R1 ;len 1 / 2
    Push $R2 ;len 2 / 1
    Push $R3 ;len 2 / 2
 
    StrCmp $R5 "" 0 +2
    StrCpy $R5 0xA01800
 
    StrCpy $9 $0 ;title
 
    StrCpy $3 0
    loop1:
        IntOp $3 $3 - 1
        StrCpy $4 $2 1 $3
        StrCmp $4 "" error
        StrCmp $4 "|" 0 loop1
       
    StrCpy $5 $2 $3
    IntOp $3 $3 + 1
    StrCpy $6 $2 "" $3
 
    StrCpy $3 0
    loop2:
        IntOp $3 $3 - 1
        StrCpy $4 $1 1 $3
        StrCmp $4 "" error
        StrCmp $4 "|" 0 loop2

    StrCpy $7 $1 $3
    IntOp $3 $3 + 1
    StrCpy $8 $1 "" $3
 
    StrLen $R0 $5
    IntOp $R0 $R0 + 1
    StrLen $R1 $6
    IntOp $R1 $R1 + 1
    StrLen $R2 $7
    IntOp $R2 $R2 + 1
    StrLen $R3 $8
    IntOp $R3 $R3 + 1
    StrCpy $4 '(&l4, i, i 0, i, i 0, i 0, i 0, t, i ${NSIS_MAX_STRLEN}, t, i ${NSIS_MAX_STRLEN}, t, t, i, &i2, &i2, t, i 0, i 0, i 0) i'
    System::Call '*(&t$R0 "$5" , &t$R1 "$6", &t$R2 "$7", &t$R3 "$8", &i1 0) i.r0'
    System::Call '*$4(, $HWNDPARENT,, r0,,,,"",,"",, i 0, "$9", $R5,,,,,,) .r1'
    System::Call 'comdlg32::Get$R4FileNameA(i r1) i .r2'
    System::Call '*$1$4(,,,,,,,.r3)'
    System::Free $1
    System::Free $0
    StrCmp $2 0 0 +2

    error:
    StrCpy $3 error
    StrCpy $0 $3
 
    Pop $R3
    Pop $R2
    Pop $R1
    Pop $R0
    Pop $9
    Pop $8
    Pop $7
    Pop $6
    Pop $5
    Pop $4
    Pop $3
    Pop $R5 ; Fix : Retrieve appropriate register value in the messed stack
    Pop $1  ; Fix : Retrieve appropriate register value in the messed stack
    Pop $2
    Pop $R4 ; Fix : Retrieve appropriate register value in the messed stack
    Exch $0

FunctionEnd

Function GetFileSize
   
;Usage :
;Push "${NSISDIR}\makensis.exe" ; Input full path of the file
;Call "FileSize" ; Call the function
;Pop $0 = filesize in Kb
;
    ClearErrors
    Exch $R0 ;Grab the Inputed path file
    Push $0
    Push $1
    Push $2
   
    ${If} ${FileExists} $R0
        System::Call 'kernel32::_lopen(t "$R0", i 0) i .r0' ; Call the API to open the file
        System::Call 'kernel32::GetFileSize(i $0, i) i .r1' ; Call API to read file size
        System::Call 'kernel32::_lclose(i $0) i' ; API to close the opened file
        StrCpy $R0 $1
    ${Else}
        SetErrors
        StrCpy $R0 -1
    ${EndIf}
   
    Pop $2
    Pop $1
    Pop $0
    Exch $R0
   
FunctionEnd
 
Function GetParentPath
 
    ; GetParentPath
    ; In  : Top of stack = Path (C:\Program Files\Dummy)
    ; Out : Top of stack = Parent Path (C:\Program Files)

    Exch $R0
    Push $R1
    Push $R2
    Push $R3
   
    StrCpy $R1 0
    StrLen $R2 $R0
  
    loop:
        IntOp $R1 $R1 + 1
        IntCmp $R1 $R2 get 0 get
        StrCpy $R3 $R0 1 -$R1
        StrCmp $R3 "\" get
        Goto loop
  
    get:
        StrCpy $R0 $R0 -$R1
       
        Pop $R3
        Pop $R2
        Pop $R1
        Exch $R0
    
FunctionEnd

Function GetFilenameWithoutExtension
   
    ; In  : Top of stack = Absolute Filename (C:\Program Files\Dummy.ext)
    ; Out : Top of stack = Short Filename (Dummy)

    Exch $R0
    Push $R1
    Push $R2
    Push $R3
    Push $R4
    Push $R5
   
    StrCpy $R1 0
    StrLen $R2 $R0
    StrCpy $R5 "."
   
    loop:
        IntOp $R1 $R1 + 1
        IntCmp $R1 $R2 get 0 get
        IntOp $R4 $R2 - $R1
        StrCpy $R3 $R0 1 $R4       
        StrCmp $R3 "\" get
        ${If} $R3 == "."
        ${AndIf} $R5 == "."
            StrCpy $R5 $R4
        ${EndIf}           
        Goto loop
  
    get:
        IntOp $R4 $R4 + 1
        StrCpy $R0 $R0 $R1 $R4
   
        IntOp $R5 $R2 - $R5
        StrCpy $R0 $R0 -$R5
       
        Pop $R5
        Pop $R4
        Pop $R3
        Pop $R2
        Pop $R1
        Exch $R0
    
FunctionEnd


Function GetFilePath
;   
    ;Section
    ; $R0 = Result
    ; $R1 = full filename
    ; ${GetFilePath} $R0 $R1
    ; $R0="C:\ftp"
    ;SectionEnd
    ;
    !define GetFilePath `!insertmacro GetFilePathCall`
 
    !macro GetFilePathCall _RESULT _FILENAME
        Push ${_FILENAME}
        Call GetFilePath
        Pop ${_RESULT}
    !macroend
 
    Exch $0
    Push $1
    Push $2
   
    ClearErrors
    ${If} ${FileExists} $0
        System::Call 'kernel32::GetLongPathNameA(t r0, t .r1, i 1024)i .r2'
        StrCmp $2 error GetFilePathError
        StrCpy $0 $1
    ${Else}
    GetFilePathError:
        SetErrors
        StrCpy $0 -1
    ${EndIf}
   
    Pop $2
    Pop $1
    Exch $0
   
FunctionEnd

;*******************
; String functions *
;*******************

Function StrStr
   
    ; StrStr
    ; entrée, haut de la pile = chaine a rechercher
    ;         haut de la pile-1 = chaine dans laquelle chercher
    ; sortie, haut de la pile (remplacement avec la portion de la chaine restante)
    ; ne modifie aucune autre variable.
    ;
    ; Usage:
    ;   Push "c'est une putain de longue chaine" ; Original string
    ;   Push "putain" ; pattern to search for
    ;   Call StrStr
    ;   Pop $R0
    ;  ($R0 at this point is "putain de longue chaine")
   
    Exch $R1    ; st=tete,vieux$R1, $R1=pointeur
    Exch            ; st=vieux$R1,tete
    Exch $R2    ; st=vieux$R1,vieux$R2, $R2=tete
    Push $R3
    Push $R4
    Push $R5
    StrLen $R3 $R1
    StrCpy $R4 0
        $R1=pointeur
        $R2=tete
        $R3=taille(pointeur)
        $R4=cnt
        $R5=tmp
    loop:
        StrCpy $R5 $R2 $R3 $R4
        StrCmp $R5 $R1 done
        StrCmp $R5 "" done
        IntOp $R4 $R4 + 1
        Goto loop
    done:
    StrCpy $R1 $R2 "" $R4
    Pop $R5
    Pop $R4
    Pop $R3
    Pop $R2
    Exch $R1
   
FunctionEnd

Function AddStringToString
   
    ; Add a new string to an initial one separated by newline if initial string was not empty
    ; In  : Top of stack = initial string
    ;       2nd of stack = string to add
    ; Out : Top of stack = new string
   
    ; Save registers
    Exch $0 ; Get initial string
    Exch
    Exch $1 ; Get string to add

    ${If} $1 != ""
        ${If} $0 == ""
            StrCpy $0 $1
        ${Else}
            StrCpy $0 "$0$\n$1."
        ${EndIf}
    ${EndIf}
   
    ; Restore registers and stack result
    Pop $1
    Exch $0

FunctionEnd



Cette discussion est classée dans : créer, programme, installation, creation, repertoire


Répondre à ce message

Sujets en rapport avec ce message

Prog d'installation [ par sitesref ] Voilà je m'adresse à celles et ceux d'entre vous qui veulent distribuer leur création (y'en a sûrement plein).Je mets au point depuis plus d'un an un Creation de dll [ par dindin2000 ] Bonjour à tous, Depuis déjà plusieurs semaines, j'essais de créer une dll sous visual studio6 (en cpp), et de l'utiliser sous builder C++5. Mhum, je v creation d'un soft agissant sur un autre [ par kalf2000 ] Bonjour,Voilà mon problème, je dois travailler sur un soft a environnement DOS, ce soft affiche une liste qui est rafraîchie lors de l'appui de la tou Creation de repertoire sous borland [ par iexid ] bonjour je suis debutant sous borland et plus generalement en C++ (mais pas en Prog objet) et je voudrais savoir comment creer un repertoire .en fait comment créer une interface graphique simplement pour un programme en C sous linux [ par zarzar ] bonjourje dois écrire un programme de traitement d'image BMP en C sous linux qui pour l'instant doit tourner en "ligne de commande"j'ai des fonctions chemin d'installation [ par neo888 ] Bonjour,J'ai créer un programme et je desire l'inserer dans un programme d'installation, pour qu'il puisse etre installer n'importe où (avec setup gen construction d'objets dans des blocs "if" [ par kaktuss ] Petit pb...J'ai un programme comportant plusieurs classes . Je souhaite créer des objets selon des conditions "if" (tel objet construit avec telle cla Fichier d'installation [ par gagah1 ] Salut à tous.Je voudrais créer un fichier d'installation (SETUP.EXE), sur lequel je voudrais savoir comment on fait pour donner l'ordre à WINDOWS qu'u creation d'un fichier avi avec plusieur avi [ par gregbds ] bonjour je voudrais créer un fichier video avi à partir de plusieur morceaux de fichier avi mis bout à bout. Je recherche se petit programme pour l'in


Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 7,675 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales