Page 1 sur 5

AAZ-Custo-Logon-Screen x86-x64 - V.finale- by Nash

Posté : ven. 22 juil. 2011 14:30
par Nash
CUSTO-LOGON-SCREEN


Custo-logon-screen est fait pour changer l'image de la fenetre de connexion et son logo en quelques clique...


-compatible x86 et x64 (merci sh@rp)
-Possibilité de remettre l'image d'origine de seven
-pas de restriction de taille pour vos images , si celles ci sont trop lourdes , elles seront automatiquement redimensionnées a la taille 1024*768 ...
-fonction ajouter au clique droit
-fonction apercu
ne fonctionne pour l'instant qu'avec le format jpg.


screen :[/size] Image lien :
Contenu caché
Vous devez être inscrit et connecté sur ce forum pour voir le contenu caché.

Merci a sh@rp pour son aide et ses conseils
Merci d'avance pour vos retour et possibilité d'ameliorations :)

Re: AAZ-Custo-Logon-Screen

Posté : ven. 22 juil. 2011 14:47
par gibe
Fonctionne nickel...normal j'y ai mis mes petites pepettes !
:lol:

Re: AAZ-Custo-Logon-Screen

Posté : ven. 22 juil. 2011 15:08
par yahyah206
ah ba je prends direct :inlove:
merci Nash pour ce super taf :clap: :clap:

Re: AAZ-Custo-Logon-Screen

Posté : ven. 22 juil. 2011 16:17
par Zinzin
nickel et +12 pour le " restore" ;)

Re: AAZ-Custo-Logon-Screen

Posté : ven. 22 juil. 2011 16:48
par Bobby2dallas
:clap: Merci Nash! beau travail, encore une fois ! :clap:

Re: AAZ-Custo-Logon-Screen

Posté : ven. 22 juil. 2011 17:05
par sh@rp
Bah voilà t'as réussi à faire ce prog. ;)

Mes critiques constructives :

-------------------------------------------------------Côté interface :

- Le filtre "Tous les fichiers(*.*)" dans ton "openfiledialog" est inutile
- Le titre "sélectionnez un fichier Jpeg" de fenêtre de ton "openfiledialog" contient des guillemets qui n'ont pas leur place.
- Le filtre "Fichiers jpeg(*.jpg) contient un guillemet qui n'a pas sa place non plus.
- Les "ToolStripMenuItem" de ton "MenuStrip1" pourraient être agrémentés d'icônes.

---------------------------------------------------------Côté code :

- Ton code pour ajouter ton soft au clic droit est chargé et redondant et de ce fait peut largement être diminuer de moitié (voir plus).
Q : Comment se rendre compte que le code est redondant (à répétitions) ?
R : Quand une certaine partie (des lignes) sont les mêmes que d'autres dans différents endroits d'une même méthode : procédure (Sub) ou fonction (Function).

Q : Que faire pour diminuer ce code redondant ?
R : On doit créer une méthode générique qui permettrait avec la partie redondante de ce code d'être appliquée pour les différents scénarios.

Q : Comment faire ?
R : En identifiant les variables : les valeurs qui sont visibles dans le code redondant. Ce sont ces valeurs qui font que le code n'est pas entièrement identique pour les différents scénarios.

Dans ton cas :

Code : Tout sélectionner

    Dim objArray As Object()
    Dim box As TextBox
    Dim objArray2 As Object()
    Dim flagArray As Boolean()
   If Operators.ConditionalCompareObjectEqual(Me.ComboBox1.SelectedItem, "Haut", False) Then
        Me.AppPath = Application.ExecutablePath
        Me.TextBox1.Text = Me.AppPath
        Me.WshShell = RuntimeHelpers.GetObjectValue(Interaction.CreateObject("WScript.Shell", ""))
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", New Object() { "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\", "NCLS", "REG_SZ" }, Nothing, Nothing, Nothing, True)
        objArray = New Object(3  - 1) {}
        objArray(0) = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\icon"
        box = Me.TextBox1
        objArray(1) = box.Text
        objArray(2) = "REG_SZ"
        objArray2 = objArray
        flagArray = New Boolean() { False, True, False }
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", objArray2, Nothing, Nothing, flagArray, True)
        If flagArray(1) Then
            box.Text = CStr(Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray2(1)), GetType(String)))
        End If
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", New Object() { "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\Position", "Top", "REG_SZ" }, Nothing, Nothing, Nothing, True)
        objArray2 = New Object(3  - 1) {}
        objArray2(0) = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\command\"
        box = Me.TextBox1
        objArray2(1) = box.Text
        objArray2(2) = "REG_SZ"
        objArray = objArray2
        flagArray = New Boolean() { False, True, False }
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", objArray, Nothing, Nothing, flagArray, True)
        If flagArray(1) Then
            box.Text = CStr(Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray(1)), GetType(String)))
        End If
    ElseIf Operators.ConditionalCompareObjectEqual(Me.ComboBox1.SelectedItem, "Milieu", False) Then
        Me.AppPath = Application.ExecutablePath
        Me.TextBox1.Text = Me.AppPath
        Me.WshShell = RuntimeHelpers.GetObjectValue(Interaction.CreateObject("WScript.Shell", ""))
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", New Object() { "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\", "NCLS", "REG_SZ" }, Nothing, Nothing, Nothing, True)
        objArray2 = New Object(3  - 1) {}
        objArray2(0) = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\icon"
        box = Me.TextBox1
        objArray2(1) = box.Text
        objArray2(2) = "REG_SZ"
        objArray = objArray2
        flagArray = New Boolean() { False, True, False }
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", objArray, Nothing, Nothing, flagArray, True)
        If flagArray(1) Then
            box.Text = CStr(Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray(1)), GetType(String)))
        End If
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", New Object() { "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\Position", "Center", "REG_SZ" }, Nothing, Nothing, Nothing, True)
        objArray2 = New Object(3  - 1) {}
        objArray2(0) = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\command\"
        box = Me.TextBox1
        objArray2(1) = box.Text
        objArray2(2) = "REG_SZ"
        objArray = objArray2
        flagArray = New Boolean() { False, True, False }
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", objArray, Nothing, Nothing, flagArray, True)
        If flagArray(1) Then
            box.Text = CStr(Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray(1)), GetType(String)))
        End If
    ElseIf Operators.ConditionalCompareObjectEqual(Me.ComboBox1.SelectedItem, "Bas", False) Then
        Me.AppPath = Application.ExecutablePath
        Me.TextBox1.Text = Me.AppPath
        Me.WshShell = RuntimeHelpers.GetObjectValue(Interaction.CreateObject("WScript.Shell", ""))
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", New Object() { "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\", "NCLS", "REG_SZ" }, Nothing, Nothing, Nothing, True)
        objArray2 = New Object(3  - 1) {}
        objArray2(0) = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\icon"
        box = Me.TextBox1
        objArray2(1) = box.Text
        objArray2(2) = "REG_SZ"
        objArray = objArray2
        flagArray = New Boolean() { False, True, False }
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", objArray, Nothing, Nothing, flagArray, True)
        If flagArray(1) Then
            box.Text = CStr(Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray(1)), GetType(String)))
        End If
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", New Object() { "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\Position", "Bottom", "REG_SZ" }, Nothing, Nothing, Nothing, True)
        objArray2 = New Object(3  - 1) {}
        objArray2(0) = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\command\"
        box = Me.TextBox1
        objArray2(1) = box.Text
        objArray2(2) = "REG_SZ"
        objArray = objArray2
        flagArray = New Boolean() { False, True, False }
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", objArray, Nothing, Nothing, flagArray, True)
        If flagArray(1) Then
            box.Text = CStr(Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray(1)), GetType(String)))
        End If
    End If

On remarque vite la redondance de cette partie de code :

Code : Tout sélectionner

        Me.AppPath = Application.ExecutablePath
        Me.TextBox1.Text = Me.AppPath
        Me.WshShell = RuntimeHelpers.GetObjectValue(Interaction.CreateObject("WScript.Shell", ""))
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", New Object() { "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\", "NCLS", "REG_SZ" }, Nothing, Nothing, Nothing, True)
        objArray = New Object(3  - 1) {}
        objArray(0) = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\icon"
        box = Me.TextBox1
        objArray(1) = box.Text
        objArray(2) = "REG_SZ"
        objArray2 = objArray
        flagArray = New Boolean() { False, True, False }
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", objArray2, Nothing, Nothing, flagArray, True)
        If flagArray(1) Then
            box.Text = CStr(Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray2(1)), GetType(String)))
        End If
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", New Object() { "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\Position", "Top", "REG_SZ" }, Nothing, Nothing, Nothing, True)
        objArray2 = New Object(3  - 1) {}
        objArray2(0) = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\command\"
        box = Me.TextBox1
        objArray2(1) = box.Text
        objArray2(2) = "REG_SZ"
        objArray = objArray2
        flagArray = New Boolean() { False, True, False }
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", objArray, Nothing, Nothing, flagArray, True)
        If flagArray(1) Then
            box.Text = CStr(Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray(1)), GetType(String)))
        End If

Donc pour diminuer en grande partie tout ca il suffit d'identifier les variables (Haut, milieu, bas (Top, Center, Bottom).
) qui font que chaque partie redondantes sont différentes afin de les passer en argument à une procédure.

-->Le nom de ta procédure pourrait s'appeler : CreateRightClic()
-->L'argument à passer à ta procédure serait : La variable de la position de l'item qu'on pourrait nommer "Posit".

-->La procédure s'écrit donc ainsi :

Code : Tout sélectionner

Private sub CreateRightClic (Byval Posit as string)
'Tu places ici ton code redondant et ta variable "Posit" là ou il est nécessaire de l'utiliser
End sub
-->Et voilà la procédure complète :

Code : Tout sélectionner

Private sub CreateRightClic (Byval Posit as string)
        Dim objArray As Object()
        Dim box As TextBox
        Dim objArray2 As Object()
        Dim flagArray As Boolean()
        Me.AppPath = Application.ExecutablePath
        Me.TextBox1.Text = Me.AppPath
        Me.WshShell = RuntimeHelpers.GetObjectValue(Interaction.CreateObject("WScript.Shell", ""))
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", New Object() { "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\", "NCLS", "REG_SZ" }, Nothing, Nothing, Nothing, True)
        objArray = New Object(3  - 1) {}
        objArray(0) = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\icon"
        box = Me.TextBox1
        objArray(1) = box.Text
        objArray(2) = "REG_SZ"
        objArray2 = objArray
        flagArray = New Boolean() { False, True, False }
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", objArray2, Nothing, Nothing, flagArray, True)
        If flagArray(1) Then
            box.Text = CStr(Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray2(1)), GetType(String)))
        End If
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", New Object() { "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\Position", Posit, "REG_SZ" }, Nothing, Nothing, Nothing, True)
        objArray2 = New Object(3  - 1) {}
        objArray2(0) = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\command\"
        box = Me.TextBox1
        objArray2(1) = box.Text
        objArray2(2) = "REG_SZ"
        objArray = objArray2
        flagArray = New Boolean() { False, True, False }
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", objArray, Nothing, Nothing, flagArray, True)
        If flagArray(1) Then
            box.Text = CStr(Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray(1)), GetType(String)))
        End If

End sub
-->Il ne faut pas oublier que lorsque l'utilisateur sélectionne une valeur dans la Combobox qu'il choisit entre celleslà :

- Haut
- Milieu
- Bas

Il faut donc établir une correspondance pour que la valeur qui sera envoyé en tant qu'argument dans ta procédure "CreateRightClic()" c'est à dire l'argument "Posit" arrive dans le corps de ta procédure en tant que valeur qui sera inscrite comme cela dans le registre :

- Top
- Center
- Bottom

Pour se faire tu peux utiliser une conditionnel (If ...Elseif...Elseif... End if) ou un connecteur de sélection (Select ....Case....Case...Case... End Select) :

---> Voilà enfin la procédure finale à placer dans ton "form1" :

Code : Tout sélectionner

Private sub CreateRightClic (Byval Posit as string)
Dim Posit as string = Posit
  Select Case Posit
            Case "Haut"
              Posit = "Top"
            Case "Milieu"
              Posit = "Center"          
            Case "Bas"
              Posit = "Bottom"
  End Select
        Dim objArray As Object()
        Dim box As TextBox
        Dim objArray2 As Object()
        Dim flagArray As Boolean()
        Me.AppPath = Application.ExecutablePath
        Me.TextBox1.Text = Me.AppPath
        Me.WshShell = RuntimeHelpers.GetObjectValue(Interaction.CreateObject("WScript.Shell", ""))
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", New Object() { "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\", "NCLS", "REG_SZ" }, Nothing, Nothing, Nothing, True)
        objArray = New Object(3  - 1) {}
        objArray(0) = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\icon"
        box = Me.TextBox1
        objArray(1) = box.Text
        objArray(2) = "REG_SZ"
        objArray2 = objArray
        flagArray = New Boolean() { False, True, False }
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", objArray2, Nothing, Nothing, flagArray, True)
        If flagArray(1) Then
            box.Text = CStr(Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray2(1)), GetType(String)))
        End If
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", New Object() { "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\Position", Posit, "REG_SZ" }, Nothing, Nothing, Nothing, True)
        objArray2 = New Object(3  - 1) {}
        objArray2(0) = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\NCLS\command\"
        box = Me.TextBox1
        objArray2(1) = box.Text
        objArray2(2) = "REG_SZ"
        objArray = objArray2
        flagArray = New Boolean() { False, True, False }
        NewLateBinding.LateCall(Me.WshShell, Nothing, "RegWrite", objArray, Nothing, Nothing, flagArray, True)
        If flagArray(1) Then
            box.Text = CStr(Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray(1)), GetType(String)))
        End If
End sub
---> Et voilà enfin ton code diminué de 2/3 :

Code : Tout sélectionner

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    If Operators.ConditionalCompareObjectEqual(Me.ComboBox1.SelectedItem, "Haut", False) Then
         CreateRightClic(Me.ComboBox1.SelectedItem) 
    ElseIf Operators.ConditionalCompareObjectEqual(Me.ComboBox1.SelectedItem, "Milieu", False) Then
         CreateRightClic(Me.ComboBox1.SelectedItem)
    ElseIf Operators.ConditionalCompareObjectEqual(Me.ComboBox1.SelectedItem, "Bas", False) Then
         CreateRightClic(Me.ComboBox1.SelectedItem)
    End If
End sub
Voilà le raisonnement. On otpimise le code en supprimant le superflux. ;)

Maintenant ton code pour ajouter un menu contextuel est très lourd, il y a plus simple mais c'est ton choix...Tu préfères toujours utiliser le shell de vbs tu déclares une multitude de variables alors qu'elles inutiles et consommatrices de mémoire...OO
J'espère que tu tireras un trait sur cette méthode car le framework offre bien plus de possibilités et qui sont bien plus simples à mettre en place. ;) *

Bonne continuation.

Re: AAZ-Custo-Logon-Screen

Posté : ven. 22 juil. 2011 17:24
par Nash
Voilà le raisonnement. On otpimise le code en supprimant le superflux.

Maintenant ton code pour ajouter un menu contextuel est très lourd, il y a plus simple mais c'est ton choix...Tu préfères toujours utiliser le shell de vbs tu déclares une multitude de variables alors qu'elles inutiles et consommatrices de mémoire...OO
J'espère que tu tireras un trait sur cette méthode car le framework offre bien plus de possibilités et qui sont bien plus simples à mettre en place. *
tout d'abords , merci d'avoir pris le temps de jeter un oeil sur mon code ;)

oui , j'ai cherché un bout de temps pour le clique droit , et c'est la seule facon que j'a itrouver lollll
je vais donc analyser ton code a tete reposé , et a premiere vue , c'est clair que ca parait bien plus propre ;)

je corrige les quelques "erreurs" qui traine dans le we :) et essaierai de comprendre un peu plus ta methode , car la , j'ai plus fait des essaies en cherchant une methode qui marchait :)

merci pour tout ;)

merci encore ;)

ps: la vache lol , tu as l'oeil , javais meme pas vu guillemets dans openfilediag :D

Re: AAZ-Custo-Logon-Screen V 1.1 by Nash

Posté : ven. 22 juil. 2011 17:55
par Nash
maj v 1.1

-ajouts d'icones dans menu
-retrait des guillemets inutiles ;)

Re: AAZ-Custo-Logon-Screen V 1.1 by Nash

Posté : ven. 22 juil. 2011 18:08
par jeff64
Salut et merci ;)
Bravo au développeur et à son aide..... :D

Re: AAZ-Custo-Logon-Screen x86-x64 - V 1.1 by Nash

Posté : sam. 23 juil. 2011 21:46
par Prof
:clap: :clap: :clap: