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

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


  Mostrar Mensajes
Páginas: 1 ... 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 [922] 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 ... 1235
9211  Programación / Scripting / Re: Acciones sobre archivos de texto. [Batch] en: 17 Abril 2013, 00:18 am
Lo que quiero es que en la ventana cmd pueda escribir el texto a añadir a todas las lineas del texto.
El que tu me pones la ventana cmd me pide el nombre del archivo de texto.

La idea es que partiendo del archivo frutero.txt (u otro nombre) la ventana cmd pida el texto a añadir a las lineas de ese archivo de texto.

Fíjate en el código, puedes pedir el texto a introducir exáctamente de la misma manera que se puede pedir el archivo de texto en el script que te he puesto de ejemplo. Te quise poner un ejemplo de las dos maneras.

Código:
Set /P /?

Citar
El modificador /P permite establecer el valor de una variable para una línea
de entrada escrita por el usuario. Muestra la cadena del símbolo del sistema
antes de leer la línea de entrada. La cadena del símbolo del sistema puede
estar vacía.

Saludos!
9212  Informática / Software / Re: [APORTE] MEGA-PACK para iniciarse en VS2012 x64 (Instalador + Recursos + Tools) en: 17 Abril 2013, 00:02 am
¡ Llegó la nueva versión del instalador !

He corregido un error que sufrieron algunas personas con la carpeta de instalación del VS en la version antigua de este instalador...
Además lo he optimizado tanto en el sistema de la instalación de los componentes, como en su desinstalación... ...Y contiene más librerías, más controles, y más snippets!


La instalación completa y la instalación por defecto han sido testeadas en Windows 7 de 32 y 64 Bits, en Windows XP tampoco debería haber problemas.



LO PUEDEN DESCARGAR DE FORMA DIRECTA EN EL COMENTARIO PRINCIPAL DE ESTE HILO.



         
9213  Informática / Software / Re: [APORTE] MEGA-PACK para iniciarse en VS2012 x64 (Instalador + Recursos + Tools) en: 17 Abril 2013, 00:00 am
De nada, eh? xD

Me ha hecho mucha gracia el video, es un tutorial express xD

"...Y después de instalar esto le pinchamos aquí para abrir el .NET, que tarda unas 400 horas en abrirse, pero yo ya lo tenia abierto así que..." X'D

Gracias por el video.

PD: El idioma por defecto de la IDE es Inglés, para poder elegir Español (como comentas en tu tuto) hay que instalar el idioma español para la IDe (Que va incluida en el instalador).
9214  Programación / Scripting / Re: Acciones sobre archivos de texto. [Batch] en: 16 Abril 2013, 22:32 pm
...Es decir: Como añadir un string al final de cada línea de un archivo de texto.

Pues así:

Código
  1. @Echo OFF
  2. Title Frutero
  3.  
  4. Set /P "InputText=Arrastra el archivo de texto... >> "
  5. Set "String= tiene fruta"
  6. Call :Writter "%InputText%" "%String%" ".\Frutero.txt"
  7. Pause&Exit
  8.  
  9. :Writter
  10. ((FOR /F "Usebackq Tokens=*" %%@ IN ("%~1") DO (Echo %%@%~2)) > %3) & (GOTO:EOF)


Saludos!
9215  Programación / .NET (C#, VB.NET, ASP) / Re: Ayuda en ejercicio basico en: 16 Abril 2013, 20:20 pm
Te está diciendo que intentas usar una variable que no tiene ningún valor asignado.

Asígnale un valor, y listo:

Código
  1. float primernumero = 0;
  2. float segundonumero = 0;
  3. float resultado = 0;
  4. string operacion = null;

El ¿porque?, pues me imagino que porque C# es así de restrictivo, no sé, no manejo C#... :P

Saludos!
9216  Programación / .NET (C#, VB.NET, ASP) / Re: Problema accediendo a un objecto en un Form !! en: 16 Abril 2013, 20:12 pm
Reference to a non-shared member requires an object reference.

este es el error que me atormenta

Pues no tienes que atormentarte xD, simplemente declara las cosas como compartidas (Shared), y listo.

Ejemplo:

Código
  1. Public Class Class1
  2.  
  3.    Public Shared SharedVar As String = "Test" ' Esta la podrás leer
  4.    Public Var As String = "Test"' Esta no la podrás leer
  5.  
  6. End Class

Código
  1. Imports WindowsApplication1.Class1
  2.  
  3. Public Class Form1
  4.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  5.        MsgBox(SharedVar) ' String: "Test"
  6.        MsgBox(Var) ' Exception: Reference to a non-shared member requires an object reference
  7.    End Sub
  8. End Class

Saludos!
9217  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 16 Abril 2013, 16:38 pm
· Devuelve el valor de un nombre de un Enum

Código
  1. #Region " Get Enum Value "
  2.  
  3.    ' [ Get Enum Value Function ]
  4.    '
  5.    ' Examples :
  6.    ' MsgBox(Get_Enum_Value(DayOfWeek.Sunday)) ' Result: 0
  7.    ' MsgBox(Get_Enum_Value(DayOfWeek.Monday)) ' Result: 1
  8.  
  9.    Function Get_Enum_Value(Of T)(Byval ValueName As T) As Int32
  10.        Return Convert.ToInt32(ValueName)
  11.    End Function
  12.  
  13. #End Region




· Devuelve el nombre de un valor de un Enum

Código
  1. #Region " Get Enum Name "
  2.  
  3.    ' [ Get Enum ValueName Function ]
  4.    '
  5.    ' Examples :
  6.    ' MsgBox(Get_Enum_Name(Of DayOfWeek)(0)) ' Result: Sunday
  7.    ' MsgBox(Get_Enum_Name(Of DayOfWeek)(1)) ' Result: Monday
  8.  
  9.    Private Function Get_Enum_Name(Of T)(EnumValue As Integer) As String
  10.        Return [Enum].GetName(GetType(T), EnumValue)
  11.    End Function
  12.  
  13. #End Region





· Comparar dos archivos:

Código
  1. #Region " Compare Files "
  2.  
  3.    ' [ Compare Files Function ]
  4.    '
  5.    ' Examples :
  6.    ' MsgBox(Compare_Files("C:\File1.txt", "C:\File2.txt"))
  7.  
  8.    Private Function Compare_Files(ByVal File1 As String, ByVal File2 As String) As Boolean
  9.  
  10.        ' Set to true if the files are equal; false otherwise
  11.        Dim FilesAreEqual As Boolean = False
  12.  
  13.        With My.Computer.FileSystem
  14.  
  15.            ' Ensure that the files are the same length before comparing them line by line.
  16.            If .GetFileInfo(File1).Length = .GetFileInfo(File2).Length Then
  17.                Using file1Reader As New FileStream(File1, FileMode.Open), _
  18.                      file2Reader As New FileStream(File2, FileMode.Open)
  19.                    Dim byte1 As Integer = file1Reader.ReadByte()
  20.                    Dim byte2 As Integer = file2Reader.ReadByte()
  21.  
  22.                    ' If byte1 or byte2 is a negative value, we have reached the end of the file.
  23.                    While byte1 >= 0 AndAlso byte2 >= 0
  24.                        If (byte1 <> byte2) Then
  25.                            FilesAreEqual = False
  26.                            Exit While
  27.                        Else
  28.                            FilesAreEqual = True
  29.                        End If
  30.  
  31.                        ' Read the next byte.
  32.                        byte1 = file1Reader.ReadByte()
  33.                        byte2 = file2Reader.ReadByte()
  34.                    End While
  35.  
  36.                End Using
  37.            End If
  38.        End With
  39.  
  40.        Return FilesAreEqual
  41.    End Function
  42.  
  43. #End Region
9218  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 16 Abril 2013, 15:31 pm
· Un AppActivate distinto, en mi opinión mejor, se usa por el nombre del proceso, con posibilidad de seleccionar el proceso por el título de la ventana de dicho proceso:

Código
  1. #Region " Activate APP "
  2.  
  3.    ' [ Activate APP Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' ActivateAPP("notepad.exe")
  9.    ' ActivateAPP("notepad.exe", "Notepad Sub-Window Title")
  10.    ' MsgBox(ActivateAPP("notepad"))
  11.  
  12.    Private Function ActivateAPP(ByVal ProcessName As String, _
  13.                                 Optional ByVal WindowTitle As String = Nothing) As Boolean
  14.  
  15.        If ProcessName.ToLower.EndsWith(".exe") Then ProcessName = ProcessName.Substring(0, ProcessName.Length - 4)
  16.        Dim ProcessTitle As String = Nothing
  17.        Dim ProcessArray = Process.GetProcessesByName(ProcessName)
  18.  
  19.        If ProcessArray.Length = 0 Then : Return False ' ProcessName not found
  20.  
  21.        ElseIf ProcessArray.Length > 1 AndAlso Not WindowTitle Is Nothing Then
  22.            For Each Title In ProcessArray
  23.                If Title.MainWindowTitle.Contains(WindowTitle) Then _
  24.                   ProcessTitle = Title.MainWindowTitle
  25.            Next
  26.  
  27.        Else : ProcessTitle = ProcessArray(0).MainWindowTitle
  28.        End If
  29.  
  30.        AppActivate(ProcessTitle)
  31.        Return True ' Window activated
  32.  
  33.    End Function
  34.  
  35. #End Region




· Escribe texto en un Log

Código
  1. #Region " Write Log "
  2.  
  3.    ' [ Write Log Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' WriteLog("Application started", InfoType.Information)
  9.    ' WriteLog("Application got mad", InfoType.Critical)
  10.  
  11.    Dim LogFile = CurDir() & "\" & System.Reflection.Assembly.GetExecutingAssembly.GetName().Name & ".log"
  12.  
  13.    Public Enum InfoType
  14.        Information
  15.        Exception
  16.        Critical
  17.        None
  18.    End Enum
  19.  
  20.    Private Function WriteLog(ByVal Message As String, ByVal InfoType As InfoType) As Boolean
  21.        Dim LocalDate As String = My.Computer.Clock.LocalTime.ToString.Split(" ").First
  22.        Dim LocalTime As String = My.Computer.Clock.LocalTime.ToString.Split(" ").Last
  23.        Dim LogDate As String = "[ " & LocalDate & " ] " & " [ " & LocalTime & " ]  "
  24.        Dim MessageType As String = Nothing
  25.  
  26.        Select Case InfoType
  27.            Case InfoType.Information : MessageType = "Information: "
  28.            Case InfoType.Exception : MessageType = "Error: "
  29.            Case InfoType.Critical : MessageType = "Critical: "
  30.            Case InfoType.None : MessageType = ""
  31.        End Select
  32.  
  33.        Try
  34.            My.Computer.FileSystem.WriteAllText(LogFile, vbNewLine & LogDate & MessageType & Message & vbNewLine, True)
  35.            Return True
  36.        Catch ex As Exception
  37.            'Return False
  38.            Throw New Exception(ex.Message)
  39.        End Try
  40.  
  41.    End Function
  42.  
  43. #End Region





· Cierra un proceso (No lo mata)

Código
  1. #Region " Close Process Function "
  2.  
  3.    ' [ Close Process Function ]
  4.    '
  5.    ' Examples :
  6.    '
  7.    ' Close_Process(Application.ExecutablePath)
  8.    ' Close_Process("notepad.exe")
  9.    ' Close_Process("notepad", False)
  10.  
  11.    Private Function Close_Process(ByRef Process_Name As String, _
  12.                                   Optional ByVal OnlyFirstFound As Boolean = True) As Boolean
  13.  
  14.        If Process_Name.ToLower.EndsWith(".exe") Then Process_Name = Process_Name.Substring(0, Process_Name.Length - 4)
  15.        Dim proc() As Process = Process.GetProcessesByName(Process_Name)
  16.  
  17.        If Not OnlyFirstFound Then
  18.            For proc_num As Integer = 0 To proc.Length - 1
  19.                Try : proc(proc_num).CloseMainWindow() _
  20.                    : Catch : Return False : End Try ' One of the processes can't be closed
  21.            Next
  22.            Return True
  23.        Else
  24.            Try : proc(0).CloseMainWindow() : Return True ' Close message sent to the process
  25.            Catch : Return False : End Try ' Can't close the process
  26.        End If
  27.  
  28.        Return Nothing ' ProcessName not found
  29.  
  30.    End Function
  31.  
  32. #End Region





· Buscar coincidencias de texto usando expresiones regulares

Código
  1. #Region " Find RegEx "
  2.  
  3.    ' [ Find RegEx Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' If Find_RegEx("abcdef", "^[A-Z]+$") Then MsgBox("Yes") Else MsgBox("No") ' Result: No
  9.    ' If Find_RegEx("abcdef", "^[A-Z]+$", True) Then MsgBox("Yes") Else MsgBox("No") ' Result: Yes
  10.  
  11.    Private Function Find_RegEx(ByVal str As String, ByVal Pattern As String, _
  12.                                 Optional ByVal Ignorecase As Boolean = False) As Boolean
  13.  
  14.        Dim RegExCase As System.Text.RegularExpressions.RegexOptions
  15.  
  16.        If Ignorecase Then _
  17.             RegExCase = System.Text.RegularExpressions.RegexOptions.IgnoreCase _
  18.        Else RegExCase = System.Text.RegularExpressions.RegexOptions.None
  19.  
  20.        Dim RegEx As New System.Text.RegularExpressions.Regex(Pattern, RegExCase)
  21.  
  22.        Return RegEx.IsMatch(str)
  23.  
  24.    End Function
  25.  
  26. #End Region





· Leer un texto línea por línea (For each line...) con posibilidad de saltar líneas en blanco.

Código
  1. #Region " Read TextFile Libe By Line "
  2.  
  3.    ' [ Read TextFile Libe By Line ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' Read_TextFile_Libe_By_Line("C:\Test.txt")
  9.    ' Read_TextFile_Libe_By_Line("C:\Test.txt", True)
  10.  
  11.    Private Sub Read_TextFile_Libe_By_Line(ByVal TextFile As String, _
  12.                                           Optional ByVal Read_Blank_Lines As Boolean = False)
  13.        Dim Line As String = Nothing
  14.        Dim Text As IO.StreamReader = IO.File.OpenText(TextFile)
  15.        Dim RegEx As New System.Text.RegularExpressions.Regex("^\s+$")
  16.  
  17.        Do Until Text.EndOfStream
  18.  
  19.            Line = Text.ReadLine()
  20.  
  21.            If (Not Read_Blank_Lines _
  22.                AndAlso _
  23.               (Not Line = "" _
  24.                And Not RegEx.IsMatch(Line))) _
  25.                OrElse Read_Blank_Lines Then
  26.                ' Do things here...
  27.                MsgBox(Line)
  28.            End If
  29.  
  30.        Loop
  31.  
  32.        Text.Close() : Text.Dispose()
  33.  
  34.    End Sub
  35.  
  36. #End Region
9219  Programación / Programación General / Re: Modificar idiomas de .exe en: 16 Abril 2013, 13:32 pm
Lo que necesitas es el editor "PE Explorer", modificas los strings de las tablas y aplicas los cambios.

Saludos!
9220  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 16 Abril 2013, 12:06 pm
La función de convertir un string a Case, mejorada y mucho más ampliada:

Código
  1. #Region " String to Case "
  2.  
  3.    ' [ String to Case Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(String_To_Case("THiS is a TeST", StringCase.Titlecase))
  9.    ' MsgBox(String_To_Case("THiS is a TeST", StringCase.DelimitedCase_Lower, ";"))
  10.    ' Var = String_To_WordCase(Var, StringCase.LowerCase)
  11.  
  12.    Public Enum StringCase
  13.  
  14.        LowerCase
  15.        UpperCase
  16.        Titlecase
  17.        WordCase
  18.  
  19.        CamelCase_First_Lower
  20.        CamelCase_First_Upper
  21.  
  22.        MixedCase_First_Lower
  23.        MixedCase_First_Upper
  24.        MixedCase_Word_Lower
  25.        MixedCase_Word_Upper
  26.  
  27.        DelimitedCase_Lower
  28.        DelimitedCase_Mixed_Word_Lower
  29.        DelimitedCase_Mixed_Word_Upper
  30.        DelimitedCase_Title
  31.        DelimitedCase_Upper
  32.        DelimitedCase_Word
  33.  
  34.    End Enum
  35.  
  36.    Private Function String_To_Case(ByVal str As String, _
  37.                                    ByVal StringCase As StringCase, _
  38.                                    Optional ByVal Delimiter As String = "-") As String
  39.        Select Case StringCase
  40.  
  41.            Case StringCase.LowerCase
  42.                Return str.ToLower
  43.  
  44.            Case StringCase.UpperCase
  45.                Return str.ToUpper
  46.  
  47.            Case StringCase.Titlecase
  48.                Return Char.ToUpper(str(0)) + StrConv(str.Substring(1), VbStrConv.Lowercase)
  49.  
  50.            Case StringCase.WordCase
  51.                Return System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str)
  52.  
  53.            Case StringCase.CamelCase_First_Lower
  54.                Return Char.ToLower(str(0)) & _
  55.                    System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str).Replace(" ", "").Substring(1)
  56.  
  57.            Case StringCase.CamelCase_First_Upper
  58.                Return Char.ToUpper(str(0)) & _
  59.                    System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str).Replace(" ", "").Substring(1)
  60.  
  61.            Case StringCase.MixedCase_First_Lower
  62.                Dim MixedString As String = Nothing
  63.                For X As Integer = 0 To str.Length - 1
  64.                    Dim c As Char = str(X)
  65.                    If (X / 2).ToString.Contains(",") Then _
  66.                         MixedString += c.ToString.ToUpper _
  67.                    Else MixedString += c.ToString.ToLower
  68.                Next
  69.                Return MixedString
  70.  
  71.            Case StringCase.MixedCase_First_Upper
  72.                Dim MixedString As String = Nothing
  73.                For X As Integer = 0 To str.Length - 1
  74.                    Dim c As Char = str(X)
  75.                    If (X / 2).ToString.Contains(",") Then _
  76.                         MixedString += c.ToString.ToLower _
  77.                    Else MixedString += c.ToString.ToUpper
  78.                Next
  79.                Return MixedString
  80.  
  81.            Case StringCase.MixedCase_Word_Lower
  82.                Dim MixedString As String = Nothing
  83.                Dim Count As Integer = 1
  84.                For X As Integer = 0 To str.Length - 1
  85.                    Dim c As Char = str(X)
  86.                    If Not c = " " Then Count += 1 Else Count = 1
  87.                    If (Count / 2).ToString.Contains(",") Then _
  88.                         MixedString += c.ToString.ToUpper _
  89.                    Else MixedString += c.ToString.ToLower
  90.                Next
  91.                Return MixedString
  92.  
  93.            Case StringCase.MixedCase_Word_Upper
  94.                Dim MixedString As String = Nothing
  95.                Dim Count As Integer = 1
  96.                For X As Integer = 0 To str.Length - 1
  97.                    Dim c As Char = str(X)
  98.                    If Not c = " " Then Count += 1 Else Count = 1
  99.                    If (Count / 2).ToString.Contains(",") Then _
  100.                         MixedString += c.ToString.ToLower _
  101.                    Else MixedString += c.ToString.ToUpper
  102.                Next
  103.                Return MixedString
  104.  
  105.            Case StringCase.DelimitedCase_Lower
  106.                Dim rgx As New System.Text.RegularExpressions.Regex("\s+")
  107.                Return rgx.Replace(str.ToLower, Delimiter)
  108.  
  109.            Case StringCase.DelimitedCase_Upper
  110.                Dim rgx As New System.Text.RegularExpressions.Regex("\s+")
  111.                Return rgx.Replace(str.ToUpper, Delimiter)
  112.  
  113.            Case StringCase.DelimitedCase_Title
  114.                Dim rgx As New System.Text.RegularExpressions.Regex("\s+")
  115.                Return rgx.Replace(Char.ToUpper(str(0)) + StrConv(str.Substring(1), VbStrConv.Lowercase), Delimiter)
  116.  
  117.            Case StringCase.DelimitedCase_Word
  118.                Dim rgx As New System.Text.RegularExpressions.Regex("\s+")
  119.                Return rgx.Replace(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str), Delimiter)
  120.  
  121.            Case StringCase.DelimitedCase_Mixed_Word_Lower
  122.                Dim MixedString As String = Nothing
  123.                Dim Count As Integer = 1
  124.                For X As Integer = 0 To str.Length - 1
  125.                    Dim c As Char = str(X)
  126.                    If Not c = " " Then Count += 1 Else Count = 1
  127.                    If (Count / 2).ToString.Contains(",") Then _
  128.                         MixedString += c.ToString.ToUpper _
  129.                    Else MixedString += c.ToString.ToLower
  130.                Next
  131.                Dim rgx As New System.Text.RegularExpressions.Regex("\s+")
  132.                Return rgx.Replace(MixedString, Delimiter)
  133.  
  134.            Case StringCase.DelimitedCase_Mixed_Word_Upper
  135.                Dim MixedString As String = Nothing
  136.                Dim Count As Integer = 1
  137.                For X As Integer = 0 To str.Length - 1
  138.                    Dim c As Char = str(X)
  139.                    If Not c = " " Then Count += 1 Else Count = 1
  140.                    If (Count / 2).ToString.Contains(",") Then _
  141.                         MixedString += c.ToString.ToLower _
  142.                    Else MixedString += c.ToString.ToUpper
  143.                Next
  144.                Dim rgx As New System.Text.RegularExpressions.Regex("\s+")
  145.                Return rgx.Replace(MixedString, Delimiter)
  146.  
  147.            Case Else
  148.                Return Nothing
  149.  
  150.        End Select
  151.  
  152.    End Function
  153.  
  154. #End Region
Páginas: 1 ... 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 [922] 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 ... 1235
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines