Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Dim sRegPath As String = System.IO.Path.Combine(System.IO.Path.GetTempPath, "tmp_reg_vb9.reg") My.Computer.FileSystem.WriteAllBytes(sRegPath, My.Resources.Monreg, False) System.Diagnostics.Process.Start(sRegPath) End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Dim sRegPath As String = System.IO.Path.Combine(System.IO.Path.GetTempPath, "tmp_reg_vb6.reg") My.Computer.FileSystem.WriteAllText(sRegPath, My.Resources.MonReg, False) System.Diagnostics.Process.Start("regedit.exe", sRegPath) End Sub
'http://www.codyx.org/snippet_recuperer-chemin-fichier-format-short-meme-si-fichier_443.aspx#1521 <System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError:=True, _ CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _ Private Shared Function GetShortPathName(ByVal Path As String, _ ByVal ShortPath As System.Text.StringBuilder, _ ByVal ShortPathLength As Integer) As Integer End Function Shared Function GetShortPathName(ByVal Path As String) As String Dim shortPath As New System.Text.StringBuilder(255) GetShortPathName(Path, shortPath, shortPath.Capacity) Return shortPath.ToString() End Function
Shared Function GetShortPathName_CreateDestroy(ByVal Path As String) As String Dim fCreate As Boolean = Not System.IO.File.Exists(Path) If fCreate Then System.IO.File.Create(Path).Dispose() Dim shortPath As String = GetShortPathName(Path) If fCreate Then System.IO.File.Delete(Path) Return shortPath End Function Shared Function GetShortPathName(ByVal Path As String) As String Dim shortPath As New System.Text.StringBuilder(255) GetShortPathName(Path, shortPath, shortPath.Capacity) Return shortPath.ToString() End Function <System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError:=True, _ CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _ Private Shared Function GetShortPathName(ByVal Path As String, _ ByVal ShortPath As System.Text.StringBuilder, _ ByVal ShortPathLength As Integer) As Integer End Function ' Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sRegPath As String = System.IO.Path.Combine(System.IO.Path.GetTempPath, "Codeur.reg") My.Computer.FileSystem.WriteAllText(sRegPath, My.Resources.Codeur, False) 'System.Diagnostics.Process.Start(GetShortPathName(sRegPath)) *Celui ci ouvre le fichier avec notepad je l'ai donc "forcer". System.Diagnostics.Process.Start("regedit.exe", GetShortPathName(sRegPath)) End Sub
Windows Registry Editor Version 5.00 ; Test Registre Codeur ; Codeur Registre Test
tu veux faire quoi?
écrire dans le registre en passant par un fichier pour ne pas avoir à utiliser la classe registre du framework?
MonRegInstall.reg Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\TestBoutonRegistre] @= "oO Test Bouton Registre Oo" [HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\TestBoutonRegistre\command] @="cmd.exe"
MonRegUninstall.reg Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\TestBoutonRegistre] @="oO Test Bouton Registre Oo" [-HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\TestBoutonRegistre\command] @="cmd.exe"
Imports System Imports System.IO Public Class Form1 'Action Bouton 1 inscrire dans le registre Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Shell("Regedit .\MonChemin\MonRegInstall.reg") End Sub 'Action Bouton 2 désinscrire du registre Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Shell("Regedit .\MonChemin\MonRegUninstall.reg") End Sub End Class
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim sRegPath As String = System.IO.Path.Combine(System.IO.Path.GetTempPath, "tmp_MonRegUninstall.reg") My.Computer.FileSystem.WriteAllText(sRegPath, My.Resources.MonRegUninstall, False) System.Diagnostics.Process.Start("regedit.exe", GetShortPathName(sRegPath)) End Sub
Imports System Imports System.IO Public Class Form1 Shared Function GetShortPathName_CreateDestroy(ByVal Path As String) As String Dim fCreate As Boolean = Not System.IO.File.Exists(Path) If fCreate Then System.IO.File.Create(Path).Dispose() Dim shortPath As String = GetShortPathName(Path) If fCreate Then System.IO.File.Delete(Path) Return shortPath End Function Shared Function GetShortPathName(ByVal Path As String) As String Dim shortPath As New System.Text.StringBuilder(255) GetShortPathName(Path, shortPath, shortPath.Capacity) Return shortPath.ToString() End Function <System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError:=True, _ CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _ Private Shared Function GetShortPathName(ByVal Path As String, _ ByVal ShortPath As System.Text.StringBuilder, _ ByVal ShortPathLength As Integer) As Integer End Function 'Action Bouton 1 Inscrire dans le registre Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Shell("Regedit .\MonChemin\MonRegInstall.reg") End Sub 'Action Bouton 2 Désinscrire du registre Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Shell("Regedit .\MonChemin\MonRegUninstall.reg") End Sub 'Action Bouton 3 Désinscrire du registre (ressource incorporé) Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim sRegPath As String = System.IO.Path.Combine(System.IO.Path.GetTempPath, "tmp_MonRegUninstall.reg") My.Computer.FileSystem.WriteAllText(sRegPath, My.Resources.MonRegUninstall, False) System.Diagnostics.Process.Start("regedit.exe", GetShortPathName(sRegPath)) End Sub End Class