elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Security Series.XSS. [Cross Site Scripting]


  Mostrar Mensajes
Páginas: 1 ... 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 [676] 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 ... 1236
6751  Programación / .NET (C#, VB.NET, ASP) / Re: ¿Qué es este warning? en: 31 Agosto 2014, 19:59 pm
El aviso dice no privado, no dice que la declaración deba ser 'Public', también podría ser otra declaración visible como 'Friend'.

según parece, intuyo que estás intentando parametizar un Type en la firma de algún método (u otro miembro, como podría ser un delegado) pero te está sugeriendo que no hagas visible dicho miembro ya que el Type de su firma no se podrá exponer al ser privado,
en inglés ayudaría más a entender el mensaje de error.

¿No te indica la linea donde se encuentra la firma del miembro que produce el conflicto?.

¿No puedes modificar la visibilidad de 'X?.

Postea el código de "X".

PD: Te sugiero usar la IDE en inglés, no vas a encontrar información para resolver warnings/errors en Castellano.

saludos!
6752  Programación / Scripting / Re: Ejecutar jre especifica desde .bat en: 31 Agosto 2014, 03:33 am
He intentado haciendo un
Código:
%cd%/jre7/java 

Puedes utilizar:
Código:
%~dp0\jre7\java

Todo argumento se debe encerrar con comillas dobles para prevenir error por posibles espacios en blanco como en este caso.

Ejemplos que puedes utilizar para referite a dicho directorio desde el directorio de trabajo actual:

Código:
"jre7\java"
Código:
".\jre7\java"
Código:
"%cd%\jre7\java"
Código:
"%~dp0\jre7\java"

Nota: en caso de que modifiques el directorio de trabajo del Batch-script entonces debes utilizar la última opción, que es la que dijo el compañeor @_TTFH_3500, pero añadiendole las comillas dobles, claro, de lo contrario te seguirá dando el mismo error.

Saludos!
6753  Programación / .NET (C#, VB.NET, ASP) / Re: Mis malas combinaciones :( en: 30 Agosto 2014, 20:16 pm
He probado el For con la secuencia que dijiste y no me da ningún error de tipo " Índice fuera de los límites de la matriz ", así que no le hice ninguna modificación al código, está todo correcto en este código? (fixedvalues, numstep, numlen, IndexCounter):

Código
  1. Public Class Form1
  2.  
  3.    ReadOnly Randomizer As New Random
  4.  
  5.    Private Sub Sumar(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Shown
  6.  
  7.        Dim Combo As List(Of Integer) = Nothing
  8.        Dim Combos As New List(Of List(Of Integer))
  9.  
  10.        Dim fixedvalues As Integer() = {2, 3, 11, 12, 16, 18, 25, 27, 28, 31, 40, 41, 43, 52, 53, 56, 57, 70, 77, 80}
  11.        Dim RandomValues As Integer() = Enumerable.Range(0, 99).ToArray
  12.  
  13.        Dim IndexCounter As Integer = fixedvalues.First ' 1
  14.        Dim LenCounter As Integer = 0I
  15.  
  16.        Const NumStep As Integer = 3I
  17.        Const NumLen As Integer = 10I
  18.  
  19.        Do Until IndexCounter > fixedvalues.Last
  20.  
  21.            Combo = New List(Of Integer)
  22.  
  23.            For Num As Integer = IndexCounter To (fixedvalues.Count - 1I) Step NumStep
  24.  
  25.                LenCounter += 1I
  26.                Combo.Add(fixedvalues(Num - 1I)) 'matrix fuersa
  27.  
  28.                If LenCounter >= NumLen Then
  29.                    Exit For
  30.                End If
  31.  
  32.            Next Num
  33.  
  34.            If LenCounter < NumLen Then
  35.  
  36.                For RandomNum As Integer = 1I To (NumLen - LenCounter)
  37.  
  38.                    Dim n As Integer = Randomizer.Next(RandomValues.First, RandomValues.Last)
  39.  
  40.                    Do Until Not Combo.Contains(n)
  41.                        n = Randomizer.Next(RandomValues.First, RandomValues.Last)
  42.                    Loop
  43.  
  44.                    Combo.Add(n)
  45.  
  46.                Next ' RandomNum
  47.  
  48.            End If ' LenCounter < NumLen
  49.  
  50.            Combo.Sort()
  51.            Combos.Add(Combo)
  52.            IndexCounter += 1I
  53.            LenCounter = 0I
  54.  
  55.        Loop ' IndexCounter >= FixedValues.Last
  56.  
  57.        Combos.ForEach(Sub(comb As List(Of Integer))
  58.  
  59.                           ' Convierto la Lista a 'String', le añado los ceros, y añado el string formateado al Listbox.
  60.                           ListBox1.Items.Add(String.Join(", ",
  61.                                                          From value As String In comb
  62.                                                          Select If(value.Length = 1I,
  63.                                                                    value.Insert(0I, "0"c),
  64.                                                                    value)))
  65.                           ListBox1.Sorted = True
  66.  
  67.  
  68.  
  69.                       End Sub)
  70.  
  71.    End Sub
  72.  
  73. End Class

saludos
6754  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Compartan aquí sus snippets) en: 30 Agosto 2014, 19:45 pm
Una versión actualizada de mi Reg-Editor

Contiene todo tipo de métodos para el manejo del registro de Windows.

Código
  1. ' ***********************************************************************
  2. ' Author           : Elektro
  3. ' Last Modified On : 08-30-2014
  4. ' ***********************************************************************
  5. ' <copyright file="Class1.vb" company="Elektro Studios">
  6. '     Copyright (c) Elektro Studios. All rights reserved.
  7. ' </copyright>
  8. ' ***********************************************************************
  9.  
  10. #Region " Usage Examples "
  11.  
  12. ' -----------
  13. ' Create Key:
  14. ' -----------
  15. ' RegEdit.CreateKey("HKCU\Software\MyProgram")                        ' Creates "HKCU\Software\MyProgram"
  16. ' RegEdit.CreateKey("HKEY_CURRENT_USER\Software\MyProgram\Settings\") ' Creates "HKCU\Software\MyProgram\Settings"
  17. '
  18. ' -----------
  19. ' Delete Key:
  20. ' -----------
  21. ' RegEdit.DeleteKey("HKLM\Software\7-zip")                ' Deletes the "7-zip" tree including subkeys
  22. ' RegEdit.DeleteKey("HKEY_LOCAL_MACHINE\Software\7-zip\") ' Deletes the "7-zip" tree including subkeys
  23. '
  24. ' -------------
  25. ' Delete Value:
  26. ' -------------
  27. ' RegEdit.DeleteValue("HKCU\Software\7-Zip", "Lang")               ' Deletes "Lang" Value
  28. ' RegEdit.DeleteValue("HKEY_CURRENT_USER\Software\7-Zip\", "Lang") ' Deletes "Lang" Value
  29. '
  30. ' ----------
  31. ' Get Value:
  32. ' ----------
  33. ' Dim Data As String = RegEdit.GetValue("HKCU\Software\MyProgram", "Value name"))
  34. ' Dim Data As String = RegEdit.GetValue("HKEY_CURRENT_USER\Software\MyProgram", "Value name"))
  35. '
  36. ' ----------
  37. ' Set Value:
  38. ' ----------
  39. ' RegEdit.SetValue("HKCU\Software\MyProgram", "Value name", "Data", Microsoft.Win32.RegistryValueKind.String)               ' Create/Replace "Value Name" with "Data" as string data
  40. ' RegEdit.SetValue("HKEY_CURRENT_USER\Software\MyProgram\", "Value name", "Data", Microsoft.Win32.RegistryValueKind.String) ' Create/Replace "Value Name" with "Data" as string data
  41. '
  42. ' -----------
  43. ' Export Key:
  44. ' -----------
  45. ' RegEdit.ExportKey("HKLM", "C:\HKLM.reg")                  ' Export entire "HKEY_LOCAL_MACHINE" Tree to "C:\HKLM.reg" file.
  46. ' RegEdit.ExportKey("HKLM\Software\7-zip\", "C:\7-zip.reg") ' Export entire "7-zip" Tree to "C:\7-zip.reg" file.
  47. '
  48. ' ------------
  49. ' Import File:
  50. ' ------------
  51. ' RegEdit.ImportRegFile("C:\Registry_File.reg") ' Install a registry file.
  52. '
  53. ' ------------
  54. ' Jump To Key:
  55. ' ------------
  56. ' RegEdit.JumpToKey("HKLM")                               ' Opens Regedit at "HKEY_LOCAL_MACHINE" Root.
  57. ' RegEdit.JumpToKey("HKEY_LOCAL_MACHINE\Software\7-zip\") ' Opens Regedit at "HKEY_LOCAL_MACHINE\Software\7-zip" tree.
  58. '
  59. ' -----------
  60. ' Exist Key?:
  61. ' -----------
  62. ' MsgBox(RegEdit.ExistKey("HKCU\software") ' Checks if "Software" Key exist.
  63.  
  64. ' -------------
  65. ' Exist Value?:
  66. ' -------------
  67. ' MsgBox(RegEdit.ExistValue("HKLM\software\7-zip", "Path") ' Checks if "Path" value exist.
  68. '
  69. ' ------------
  70. ' Exist Data?:
  71. ' ------------
  72. ' MsgBox(RegEdit.ExistData("HKLM\software\7-zip", "Path") ' Checks if "Path" value have empty data.
  73. '
  74. ' ---------
  75. ' Copy Key:
  76. ' ---------
  77. ' RegEdit.CopyKey("HKCU\Software\7-Zip", "HKCU\Software\7-zip Backup") ' Copies "HKCU\Software\7-Zip" to "HKCU\Software\7-zip Backup"
  78. '
  79. ' -----------
  80. ' Copy Value:
  81. ' -----------
  82. ' RegEdit.CopyValue("HKLM\software\7-zip", "path", "HKLM\software\7-zip", "path_backup") ' Copies "Path" value with their data to "HKLM\software\7-zip" "path_backup".
  83. '
  84. ' -------------------
  85. ' SetUserAccessKey:
  86. ' -------------------
  87. ' RegEdit.SetUserAccessKey("HKCU\Software\7-Zip", {RegEdit.ReginiUserAccess.Administrators_Full_Access})
  88. ' RegEdit.SetUserAccessKey("HKEY_CURRENT_USER\Software\7-Zip", {RegEdit.ReginiUserAccess.Administrators_Full_Access, RegEdit.ReginiUserAccess.Creator_Full_Access, RegEdit.ReginiUserAccess.System_Full_Access})
  89.  
  90. #End Region
  91.  
  92. #Region " Imports "
  93.  
  94. Imports Microsoft.Win32
  95. Imports System.IO
  96. Imports System.Text
  97.  
  98. #End Region
  99.  
  100. #Region " RegEdit "
  101.  
  102. ''' <summary>
  103. ''' Contains registry related methods.
  104. ''' </summary>
  105. Public Class RegEdit
  106.  
  107. #Region " Enumerations "
  108.  
  109.    ''' <summary>
  110.    ''' Specifies an User identifier for Regini.exe command.
  111.    ''' </summary>
  112.    Public Enum ReginiUserAccess As Integer
  113.  
  114.        Administrators_Full_Access = 1I
  115.  
  116.        Administrators_Read_Access = 2I
  117.  
  118.        Administrators_Read_and_Write_Access = 3I
  119.  
  120.        Administrators_Read_Write_and_Delete_Access = 4I
  121.  
  122.        Administrators_Read_Write_and_Execute_Access = 20I
  123.  
  124.        Creator_Full_Access = 5I
  125.  
  126.        Creator_Read_and_Write_Access = 6I
  127.  
  128.        Interactive_User_Full_Access = 21I
  129.  
  130.        Interactive_User_Read_and_Write_Access = 22I
  131.  
  132.        Interactive_User_Read_Write_and_Delete_Access = 23I
  133.  
  134.        Power_Users_Full_Access = 11I
  135.  
  136.        Power_Users_Read_and_Write_Access = 12I
  137.  
  138.        Power_Users_Read_Write_and_Delete_Access = 13I
  139.  
  140.        System_Full_Access = 17I
  141.  
  142.        System_Operators_Full_Access = 14I
  143.  
  144.        System_Operators_Read_and_Write_Access = 15I
  145.  
  146.        System_Operators_Read_Write_and_Delete_Access = 16I
  147.  
  148.        System_Read_Access = 19I
  149.  
  150.        System_Read_and_Write_Access = 18I
  151.  
  152.        World_Full_Access = 7I
  153.  
  154.        World_Read_Access = 8I
  155.  
  156.        World_Read_and_Write_Access = 9I
  157.  
  158.        World_Read_Write_and_Delete_Access = 10I
  159.  
  160.    End Enum
  161.  
  162. #End Region
  163.  
  164. #Region " Public Methods "
  165.  
  166. #Region " Create "
  167.  
  168.    ''' <summary>
  169.    ''' Creates a new registry key.
  170.    ''' </summary>
  171.    ''' <param name="Key">Indicates the registry key.</param>
  172.    Public Shared Sub CreateKey(ByVal Key As String)
  173.  
  174.        Using Reg As RegistryKey = GetRoot(Key)
  175.  
  176.            Reg.CreateSubKey(GetPath(Key), RegistryKeyPermissionCheck.Default, RegistryOptions.None)
  177.  
  178.        End Using
  179.  
  180.    End Sub
  181.  
  182. #End Region
  183.  
  184. #Region " Delete "
  185.  
  186.    ''' <summary>
  187.    ''' Deletes a registry key.
  188.    ''' </summary>
  189.    ''' <param name="Key">Indicates the registry key.</param>
  190.    Public Shared Sub DeleteKey(ByVal Key As String)
  191.  
  192.        Using Reg As RegistryKey = GetRoot(Key)
  193.  
  194.            Reg.DeleteSubKeyTree(GetPath(Key), throwOnMissingSubKey:=False)
  195.  
  196.        End Using
  197.  
  198.    End Sub
  199.  
  200.    ''' <summary>
  201.    ''' Delete a registry value.
  202.    ''' </summary>
  203.    ''' <param name="Key">Indicates the registry key.</param>
  204.    ''' <param name="Value">Indicates the registry value.</param>
  205.    Public Shared Sub DeleteValue(ByVal Key As String,
  206.                                  ByVal Value As String)
  207.  
  208.        Using Reg As RegistryKey = GetRoot(Key)
  209.  
  210.            Reg.OpenSubKey(GetPath(Key), writable:=False).
  211.                DeleteValue(Value, throwOnMissingValue:=False)
  212.  
  213.        End Using
  214.  
  215.    End Sub
  216.  
  217. #End Region
  218.  
  219. #Region " Get "
  220.  
  221.    ''' <summary>
  222.    ''' Gets the data of a registry value.
  223.    ''' </summary>
  224.    ''' <param name="Key">Indicates the registry key.</param>
  225.    ''' <param name="Value">Indicates the registry value.</param>
  226.    ''' <returns>The registry data.</returns>
  227.    Public Shared Function GetValue(ByVal Key As String,
  228.                                    ByVal Value As String) As Object
  229.  
  230.        Using Reg As RegistryKey = GetRoot(Key)
  231.  
  232.            Return Reg.OpenSubKey(GetPath(Key), writable:=False).
  233.                       GetValue(Value, defaultValue:=Nothing)
  234.  
  235.        End Using
  236.  
  237.    End Function
  238.  
  239. #End Region
  240.  
  241. #Region " Set "
  242.  
  243.    ''' <summary>
  244.    ''' Set the data of a registry value.
  245.    ''' If the Key or value doesn't exist it will be created.
  246.    ''' </summary>
  247.    ''' <param name="Key">Indicates the registry key.</param>
  248.    ''' <param name="Value">Indicates the registry value.</param>
  249.    ''' <param name="Data">Indicates the registry data.</param>
  250.    ''' <param name="DataType">Indicates the type of data.</param>
  251.    Public Shared Sub SetValue(ByVal Key As String,
  252.                               ByVal Value As String,
  253.                               ByVal Data As Object,
  254.                               Optional ByVal DataType As RegistryValueKind = RegistryValueKind.Unknown)
  255.  
  256.        Using Reg As RegistryKey = GetRoot(Key)
  257.  
  258.            Select Case DataType
  259.  
  260.                Case RegistryValueKind.Unknown
  261.                    Reg.OpenSubKey(GetPath(Key), writable:=True).
  262.                        SetValue(Value, Data)
  263.  
  264.                Case RegistryValueKind.Binary
  265.                    Reg.OpenSubKey(GetPath(Key), writable:=True).
  266.                        SetValue(Value, Encoding.ASCII.GetBytes(Data), RegistryValueKind.Binary)
  267.  
  268.                Case Else
  269.                    Reg.OpenSubKey(GetPath(Key), writable:=True).
  270.                        SetValue(Value, Data, DataType)
  271.  
  272.            End Select
  273.  
  274.        End Using
  275.  
  276.    End Sub
  277.  
  278. #End Region
  279.  
  280. #Region " Exist "
  281.  
  282.    ''' <summary>
  283.    ''' Determines whether a Key exists.
  284.    ''' </summary>
  285.    ''' <param name="Key">Indicates the registry key.</param>
  286.    ''' <returns><c>true</c> if key exist, <c>false</c> otherwise.</returns>
  287.    Public Shared Function ExistKey(ByVal Key As String) As Boolean
  288.  
  289.        Dim RootKey As RegistryKey = GetRoot(Key)
  290.        Dim KeyPath As String = GetPath(Key)
  291.  
  292.        If (RootKey Is Nothing) OrElse (String.IsNullOrEmpty(KeyPath)) Then
  293.            Return False
  294.        End If
  295.  
  296.        Using Reg As RegistryKey = RootKey
  297.  
  298.            Return RootKey.OpenSubKey(KeyPath, writable:=False) IsNot Nothing
  299.  
  300.        End Using
  301.  
  302.    End Function
  303.  
  304.    ''' <summary>
  305.    ''' Determines whether a value exists.
  306.    ''' </summary>
  307.    ''' <param name="Key">Indicates the registry key.</param>
  308.    ''' <param name="Value">Indicates the registry value.</param>
  309.    ''' <returns><c>true</c> if value exist, <c>false</c> otherwise.</returns>
  310.    Public Shared Function ExistValue(ByVal Key As String, ByVal Value As String) As Boolean
  311.  
  312.        Dim RootKey As RegistryKey = GetRoot(Key)
  313.        Dim KeyPath As String = GetPath(Key)
  314.  
  315.        If (RootKey Is Nothing) OrElse (String.IsNullOrEmpty(KeyPath)) Then
  316.            Return False
  317.        End If
  318.  
  319.        Using Reg As RegistryKey = RootKey
  320.  
  321.            Return RootKey.OpenSubKey(KeyPath, writable:=False).
  322.                           GetValue(Value, defaultValue:=Nothing) IsNot Nothing
  323.  
  324.        End Using
  325.  
  326.    End Function
  327.  
  328.    ''' <summary>
  329.    ''' Determines whether data exists in a registry value.
  330.    ''' </summary>
  331.    ''' <param name="Key">Indicates the registry key.</param>
  332.    ''' <param name="Value">Indicates the registry value.</param>
  333.    ''' <returns><c>true</c> if data exist, <c>false</c> otherwise.</returns>
  334.    Public Shared Function ExistData(ByVal Key As String, ByVal Value As String) As Boolean
  335.  
  336.        Dim RootKey As RegistryKey = GetRoot(Key)
  337.        Dim KeyPath As String = GetPath(Key)
  338.  
  339.        If (RootKey Is Nothing) OrElse (String.IsNullOrEmpty(KeyPath)) Then
  340.            Return False
  341.        End If
  342.  
  343.        Using Reg As RegistryKey = RootKey
  344.  
  345.            Return Not String.IsNullOrEmpty(RootKey.OpenSubKey(KeyPath, writable:=False).
  346.                                                    GetValue(Value, defaultValue:=Nothing))
  347.  
  348.        End Using
  349.  
  350.    End Function
  351.  
  352. #End Region
  353.  
  354. #Region " Copy "
  355.  
  356.    ''' <summary>
  357.    ''' Copy a key tree to another location on the registry.
  358.    ''' </summary>
  359.    ''' <param name="OldKey">Indicates the registry key to be copied from.</param>
  360.    ''' <param name="NewKey">Indicates the registry key to be pasted from.</param>
  361.    Public Shared Sub CopyKey(ByVal OldKey As String,
  362.                              ByVal NewKey As String)
  363.  
  364.        Using OldReg As RegistryKey = GetRoot(OldKey).OpenSubKey(GetPath(OldKey), writable:=False)
  365.  
  366.            CreateKey(NewKey)
  367.  
  368.            Using NewReg As RegistryKey = GetRoot(NewKey).OpenSubKey(GetPath(NewKey), writable:=True)
  369.  
  370.                CopySubKeys(OldReg, NewReg)
  371.  
  372.            End Using ' NewReg
  373.  
  374.        End Using ' OldReg
  375.  
  376.    End Sub
  377.  
  378.    ''' <summary>
  379.    ''' Copies a value with their data to another location on the registry.
  380.    ''' If the Key don't exist it will be created automatically.
  381.    ''' </summary>
  382.    ''' <param name="OldKey">Indicates the registry key to be copied from.</param>
  383.    ''' <param name="OldValue">Indicates the registry value to be copied from.</param>
  384.    ''' <param name="NewKey">Indicates the registry key to be pasted from.</param>
  385.    ''' <param name="NewValue">Indicates the registry value to be pasted from.</param>
  386.    Public Shared Sub CopyValue(ByVal OldKey As String,
  387.                                ByVal OldValue As String,
  388.                                ByVal NewKey As String,
  389.                                ByVal NewValue As String)
  390.  
  391.        CreateKey(Key:=NewKey)
  392.        SetValue(Key:=NewKey, Value:=NewValue, Data:=GetValue(OldKey, OldValue), DataType:=RegistryValueKind.Unknown)
  393.  
  394.    End Sub
  395.  
  396. #End Region
  397.  
  398. #Region " Process dependant methods "
  399.  
  400.    ''' <summary>
  401.    ''' Opens Regedit process and jumps at the specified key.
  402.    ''' </summary>
  403.    ''' <param name="Key">Indicates the registry key.</param>
  404.    Public Shared Sub JumpToKey(ByVal Key As String)
  405.  
  406.        Using Reg As RegistryKey = GetRoot(Key)
  407.  
  408.            SetValue(Key:="HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit",
  409.                     Value:="LastKey",
  410.                     Data:=String.Format("{0}\{1}", Reg.Name, GetPath(Key)),
  411.                     DataType:=RegistryValueKind.String)
  412.  
  413.        End Using
  414.  
  415.        Process.Start(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Regedit.exe"))
  416.  
  417.    End Sub
  418.  
  419.    ''' <summary>
  420.    ''' Imports a registry file.
  421.    ''' </summary>
  422.    ''' <param name="RegFile">The registry file to import.</param>
  423.    ''' <returns><c>true</c> if operation succeeds, <c>false</c> otherwise.</returns>
  424.    Public Shared Function ImportRegFile(ByVal RegFile As String) As Boolean
  425.  
  426.        Using proc As New Process With {
  427.            .StartInfo = New ProcessStartInfo() With {
  428.                  .FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "Reg.exe"),
  429.                  .Arguments = String.Format("Import ""{0}""", RegFile),
  430.                  .CreateNoWindow = True,
  431.                  .WindowStyle = ProcessWindowStyle.Hidden,
  432.                  .UseShellExecute = False
  433.                }
  434.            }
  435.  
  436.            proc.Start()
  437.            proc.WaitForExit()
  438.  
  439.            Return Not CBool(proc.ExitCode)
  440.  
  441.        End Using
  442.  
  443.    End Function
  444.  
  445.    ''' <summary>
  446.    ''' Exports a key to a registry file.
  447.    ''' </summary>
  448.    ''' <param name="Key">Indicates the registry key.</param>
  449.    ''' <param name="OutputFile">Indicates the output file.</param>
  450.    ''' <returns><c>true</c> if operation succeeds, <c>false</c> otherwise.</returns>
  451.    Public Shared Function ExportKey(ByVal Key As String, ByVal OutputFile As String) As Boolean
  452.  
  453.        Using Reg As RegistryKey = GetRoot(Key)
  454.  
  455.            Using proc As New Process With {
  456.                    .StartInfo = New ProcessStartInfo() With {
  457.                          .FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "Reg.exe"),
  458.                          .Arguments = String.Format("Export ""{0}\{1}"" ""{2}"" /y", Reg.Name, GetPath(Key), OutputFile),
  459.                          .CreateNoWindow = True,
  460.                          .WindowStyle = ProcessWindowStyle.Hidden,
  461.                          .UseShellExecute = False
  462.                        }
  463.                    }
  464.  
  465.                proc.Start()
  466.                proc.WaitForExit()
  467.  
  468.                Return Not CBool(proc.ExitCode)
  469.  
  470.            End Using
  471.  
  472.        End Using
  473.  
  474.    End Function
  475.  
  476.    ''' <summary>
  477.    ''' Modifies the user permissions of a registry key.
  478.    ''' </summary>
  479.    ''' <param name="Key">Indicates the registry key.</param>
  480.    ''' <param name="UserAccess">Indicates the user-access.</param>
  481.    ''' <returns><c>true</c> if operation succeeds, <c>false</c> otherwise.</returns>
  482.    Public Shared Function SetUserAccessKey(ByVal Key As String, ByVal UserAccess() As ReginiUserAccess) As Boolean
  483.  
  484.        Dim tmpFile As String = Path.Combine(Path.GetTempPath(), "Regini.ini")
  485.  
  486.        Dim PermissionString As String =
  487.            String.Format("[{0}]",
  488.                          String.Join(" "c, UserAccess.Cast(Of Integer)))
  489.  
  490.        Using TextFile As New StreamWriter(path:=tmpFile, append:=False, encoding:=Encoding.Default)
  491.  
  492.            Using Reg As RegistryKey = GetRoot(Key)
  493.  
  494.                TextFile.WriteLine(String.Format("""{0}\{1}"" {2}", Reg.Name, GetPath(Key), PermissionString))
  495.  
  496.            End Using ' Reg
  497.  
  498.        End Using ' TextFile
  499.  
  500.        Using proc As New Process With {
  501.            .StartInfo = New ProcessStartInfo() With {
  502.                   .FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "Regini.exe"),
  503.                   .Arguments = ControlChars.Quote & tmpFile & ControlChars.Quote,
  504.                   .CreateNoWindow = True,
  505.                   .WindowStyle = ProcessWindowStyle.Hidden,
  506.                   .UseShellExecute = False
  507.                }
  508.            }
  509.  
  510.            proc.Start()
  511.            proc.WaitForExit()
  512.  
  513.            Return Not CBool(proc.ExitCode)
  514.  
  515.        End Using
  516.  
  517.    End Function
  518.  
  519. #End Region
  520.  
  521. #End Region
  522.  
  523. #Region " Private Methods "
  524.  
  525. #Region " Get "
  526.  
  527.    ''' <summary>
  528.    ''' Gets the registry root of a key.
  529.    ''' </summary>
  530.    ''' <param name="Key">Indicates the registry key.</param>
  531.    ''' <returns>The registry root.</returns>
  532.    Private Shared Function GetRoot(ByVal Key As String) As RegistryKey
  533.  
  534.        Select Case Key.ToUpper.Split("\").First
  535.  
  536.            Case "HKCR", "HKEY_CLASSES_ROOT"
  537.                Return Registry.ClassesRoot
  538.  
  539.            Case "HKCC", "HKEY_CURRENT_CONFIG"
  540.                Return Registry.CurrentConfig
  541.  
  542.            Case "HKCU", "HKEY_CURRENT_USER"
  543.                Return Registry.CurrentUser
  544.  
  545.            Case "HKLM", "HKEY_LOCAL_MACHINE"
  546.                Return Registry.LocalMachine
  547.  
  548.            Case "HKEY_PERFORMANCE_DATA"
  549.                Return Registry.PerformanceData
  550.  
  551.            Case Else
  552.                Return Nothing
  553.  
  554.        End Select
  555.  
  556.    End Function
  557.  
  558.    ''' <summary>
  559.    ''' Returns the registry path of a key.
  560.    ''' </summary>
  561.    ''' <param name="Key">Indicates the registry key.</param>
  562.    ''' <returns>The registry path.</returns>
  563.    Private Shared Function GetPath(ByVal Key As String) As String
  564.  
  565.        If String.IsNullOrEmpty(Key) Then
  566.            Return String.Empty
  567.        End If
  568.  
  569.        Dim KeyPath As String = Key.Substring(Key.IndexOf("\"c) + 1I)
  570.  
  571.        If KeyPath.EndsWith("\"c) Then
  572.            KeyPath = KeyPath.Substring(0I, KeyPath.LastIndexOf("\"c))
  573.        End If
  574.  
  575.        Return KeyPath
  576.  
  577.    End Function
  578.  
  579. #End Region
  580.  
  581. #Region " Copy "
  582.  
  583.    ''' <summary>
  584.    ''' Copies the sub-keys of the specified registry key.
  585.    ''' </summary>
  586.    ''' <param name="OldKey">Indicates the old key.</param>
  587.    ''' <param name="NewKey">Indicates the new key.</param>
  588.    Private Shared Sub CopySubKeys(ByVal OldKey As RegistryKey, ByVal NewKey As RegistryKey)
  589.  
  590.        ' Copy Values
  591.        For Each Value As String In OldKey.GetValueNames()
  592.  
  593.            NewKey.SetValue(Value, OldKey.GetValue(Value))
  594.  
  595.        Next Value
  596.  
  597.        ' Copy Subkeys
  598.        For Each SubKey As String In OldKey.GetSubKeyNames()
  599.  
  600.            CreateKey(String.Format("{0}\{1}", NewKey.Name, SubKey))
  601.            CopySubKeys(OldKey.OpenSubKey(SubKey, writable:=False), NewKey.OpenSubKey(SubKey, writable:=True))
  602.  
  603.        Next SubKey
  604.  
  605.    End Sub
  606.  
  607. #End Region
  608.  
  609. #End Region
  610.  
  611. End Class
  612.  
  613. #End Region
6755  Foros Generales / Foro Libre / Ice Bucket Challenge, ¿Que opinas? en: 30 Agosto 2014, 02:41 am
¿Que opinais del Ice Bucket Challenge?



Hola, creo que aun no se ha hablado de este tema en el foro y me gusta ser el primero :D (a pesar de que ello signifique que soy el primer gilipollas en hablar de esta basura) xD

Yo pienso que la deficiencia intelectual mundial va en aumento y cada vez se denotan más pruebas de ello, pues para empezar creo que el dato más obvio sería que no es normal intentar hacer un reto que se llama "cubo de hielo" tirándote por encima un maldito cubo de agua fria (o templada, los que hagan trampa) y sin cubitos de hielo como los de la siguiente imagen, claro está:


Muchos no estarán deacuerdo con lo que voy a decir, pero a mi me parece absurdo que para realizar una donación debas dejarte en ridículo intencionadamente, puede que esa persona no sienta ridículo pero sabe perfectamente que estará provocando el ridículo en muchas personas que vean su "show", y si quieres donar pues donas, no tienes que exhibirte y justificarte con un "reto" ni intentar captar la atención de los demás para obtener tu minuto de gloria,
así que si este "reto" se hiciera sin donación u otra finalidad entonces creo que cualquier profesional de la psicología podria determinar que esa persona es RETRASADA, ¿entonces porque pensamos que existe una diferencia y que esta persona no es retrasada por hacer el ridículo intencionado simplemente porque lo hace con un fin, sea cual sea?, apoyo a los payasos (los profesionales) porque ellos hacen comedia, pero esto son otro tipo de payasos con un problema bien gordo de moralidad.


Aparte, no se porque los retos famosos de internet siempre se tienen que convertir en una especie de exhibición PORNO, ¿que cojones le pasa a la gente del siglo XI?, ¿porque parecen estar todas las mujeres chaladas?, ¿es que acaso el agua es un afrodisiaco para ellas y todavia no lo hemos descubierto?, si no sabeis a lo que me estoy refiriendo os hago saber que hay decenas (o cientos) de videos sobre este reto de la típica mujer casi en pelotas (mujer normal, mujer modelo, mujer playboy, mujer pu... de todo) exhibiendose con el cubito de agua (las hay tapadas, en bikini, desnudas, de todo también), es bonito y sexy de ver al principio (que duda nos cabe a nosotros xD), pero cuando lo piensas bien... ¡decadencia ajena!.


De verdad deseo con todas mis fuerzas que esta moda tóxica se acabe mañana mismo y a ser posible vengan unos hombres de negro y nos borren cualquier recuerdo de nuestras mentes para no recordar tal acontecimiento catastrófico de la historia de la involución evolución humana.


Lo dicho, no le veo sentido a intentar justificar "hacer el tonto" con la finalidad de donar, si el fín de tirarte hielo es sentirse identificado con el ELA pues creo que es más absurdo si cabe, como mínimo yo me sentiria muy ofendido si yo fuese un enfermo de esta enfermedad.

( aunque él no se sintió ofendido y vió como su familia se tiraban cubos de hielo agua )

La única conclusión a la que puedo llegar con todo esto es que el ser humano, a día de hoy, se toma el acto de Donar como una especie de reto o show, y no como una motivación propia para regalar/compartir. Que pena.




PD: Todo lo que he escrito (menos mi conclusión) lo he expresado de forma seria y quizás algo provocativa pero siempre con un tono de broma, porfavor que nadie se sienta ofendido por alguna de las palabras que empleé y si así ocurriese le pido disculpas, tómese mis palabras con humor... ¡ninguna va con mala intención! :P


Voy a dejar que el youtuber Dalas exprese su opinión también (os aviso, contiene bastante excentricismo y palabras indecentes por doquier xD):

Para los subnormales del #IceBucketChallenge (no pretendo insultar, pero es el título del video)











...
...
...


...


Un saludo!
Elektro
6756  Informática / Software / Re: Evitar doble click con click simple. (Fallo mecánico) en: 30 Agosto 2014, 01:06 am
@Saberuneko
A mi me pasa lo mismo, ¡ lo que has compartido es algo muy util !, te doy las gracias por que vas a alargar la vida de mi mouse actual (y de los próximos).




TL;DR:
No se como no se me habia ocurrido esto antes (a mi o a cualquier otra persona quiero decir), esto es algo muy práctico y por lo que veo autohotkey te lo expone de una manera muy sencilla (por algo se llama así el lenguaje) pero esto en otros lenguajes requeriría muchísimo más código (y experiencia con Windows), he estado buscando alguna alternativa más simple (en la WinAPI) pero al parecer no existe ninguna función nativa en Windows para asignar el intervalo mínimo en el sistema para que un doble-click se considere como tal (por el lado contrario, si que existe la función SetDoubleClickTime que sirve para especificar el intervalo máximo entre click y click para que se considere doble-click), todo esto lo comento porque me habria gustado compartir una versión del mismo código que has expuesto pero en otro lenguaje, el caso es que no es plan de compartir 500 lineas de un extenso código de un hook aquí y/o quitarle protagonismo a nadie sin querer, en autohotkey parece ser lo más práctico y en pocas lineas, sin duda un buen aporte y la mejor elección del lenguaje en el que llevarlo a cabo, ¡gracias de nuevo!.



Saludos!
6757  Programación / .NET (C#, VB.NET, ASP) / Re: Mis malas combinaciones :( en: 29 Agosto 2014, 18:16 pm
Hola pongo el código entero, lo de poner los números en la variable es como difícil sin tener que cortar el código, que como veras hace una serie de cálculos con 20 dígitos que introduzco y saber cuantos números salen de esa ecuación es un poco difícil

ya, el programa hace el cálculo, ¿pero para que pueda buscar el error no puedes ponerme algo así?:

Código:
Dim fixedvalues as integer() = {1,2,3 etc,...}

Si no no se con que números debería probar en el for...

cuando pueda le echo un ojo

saludos
6758  Programación / .NET (C#, VB.NET, ASP) / Re: Mis malas combinaciones :( en: 29 Agosto 2014, 17:33 pm
1) pon el código entero que estás usando

2) a la variable FixedValues asignale manualmente los numeros que tocan ( que no lo tenga q hacer yo porque no los se :-/ ) para probar el For.

3) pon el output que debería dar al menos las primeras 3 combinaciones para saber por donde corregir el problema...

saludos!
6759  Programación / .NET (C#, VB.NET, ASP) / Re: Mis malas combinaciones :( en: 29 Agosto 2014, 15:56 pm
Los índices empiezan por Cero en .Net, así que debes descontarle un 1 a FixedValues.Count (no debes aumentar nada)

Código
  1. For Num As Integer = IndexCounter To (FixedValues.Count - 1I) Step NumStep

Supongo que eso debería solucionar el problema, quizás haya más cosas a tener en cuenta (IndexCounter, NumStep), pero de momento prueba lo que te dije a ver si te da el resultado que tu esperas.

Saludos!
6760  Programación / .NET (C#, VB.NET, ASP) / Re: Mis malas combinaciones :( en: 29 Agosto 2014, 11:47 am
Código
  1.        FixedValues =
  2.            (Result1.Concat(Result2).Concat(Result3)).
  3.            Distinct.
  4.            Select(Function(Value As Integer)
  5.                       Return If(Value < MAX, Value, Rand.Next(0, MAX))
  6.                   End Function).ToArray

PD: esto ponlo fuera del sub
Citar
Código
  1.        Dim Rand As New Random
Páginas: 1 ... 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 [676] 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines