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 ... 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 [940] 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 ... 1254
9391  Programación / .NET (C#, VB.NET, ASP) / Re: (ayuda) auto navegador en: 18 Abril 2013, 21:18 pm
Vale ya he visto tu proyecto,

el error es que estás deteniendo la ejecución del Thread al usar Thread.sleep.

El timer tickea cada 100 ms, y tu estás deteniendo el Thread por 5 segundos en cada Tick, BIG PROBLEM xD.

Te recomiendo que uses la propiedad interval del timer para ajustar el tiempo que deseas:
Código:
Timer1.Interval = 5 * 1000


Código
  1. Public Class Form1
  2.  
  3.    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  4.        ListBox1.Items.Add(TextBox1.Text) ' Añadimos el dato
  5.        TextBox1.SelectAll() ' Seleccionamos el texto
  6.        TextBox1.Select() ' y activamos el TextBox
  7.    End Sub
  8.  
  9.    Private Sub Timer1_Tick(Sender As Object, e As EventArgs) Handles Timer1.Tick
  10.        Static i As Integer = 0
  11.  
  12.        If i = ListBox1.Items.Count Then
  13.            Sender.Stop()
  14.            i = 0
  15.            MsgBox("Terminó la lista")
  16.        Else
  17.            ListBox1.SelectedIndex = i
  18.            WebBrowser1.Navigate(ListBox1.SelectedItem)
  19.            Me.Text = "Navegando en '" & ListBox1.SelectedItem & "'"
  20.            i += 1
  21.        End If
  22.  
  23.    End Sub
  24.  
  25.    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  26.        Timer1.Interval = 5 * 1000
  27.        Timer1.Start()
  28.    End Sub
  29.  
  30. End Class

EDITO: Otra forma de hacerlo, sin depender de un Timer, sería así:

Código
  1. Public Class Form1
  2.  
  3.    Dim Seconds As Long = 0
  4.  
  5.    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  6.        ListBox1.Items.Add(TextBox1.Text) ' Añadimos el dato
  7.        TextBox1.SelectAll() ' Seleccionamos el texto
  8.        TextBox1.Select() ' y activamos el TextBox
  9.    End Sub
  10.  
  11.    Private Sub NavigateListBox()
  12.        For Each URL As String In ListBox1.Items
  13.            Me.Text = "Navegando en '" & URL & "'"
  14.            WebBrowser1.Navigate(URL)
  15.            Sleep(Seconds) ' Segundos
  16.        Next
  17.    End Sub
  18.  
  19.    Private Sub Sleep(ByVal Duration As Int64)
  20.        Dim Starttime = DateTime.Now
  21.        Do While (DateTime.Now - Starttime).TotalSeconds < Duration : Application.DoEvents() : Loop
  22.    End Sub
  23.  
  24.    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  25.        NavigateListBox()
  26.    End Sub
  27.  
  28.    Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
  29.        Seconds = CLng(sender.text)
  30.    End Sub
  31.  
  32. End Class

Saludos!
9392  Programación / .NET (C#, VB.NET, ASP) / Re: (ayuda) auto navegador en: 18 Abril 2013, 21:05 pm
hmmm pues que raro, a mi si que me funciona corréctamente:

Código
  1.  
  2. public class class1
  3.  
  4.   Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  5.        Me.ClientSize = New Point(640, 480)
  6.  
  7.        Dim ListBox1 As New ListBox, WebBrowser1 As New WebBrowser
  8.        ListBox1.Dock = DockStyle.Top : WebBrowser1.Dock = DockStyle.Bottom
  9.        Me.Controls.Add(ListBox1) : Me.Controls.Add(WebBrowser1)
  10.  
  11.        ListBox1.Items.Clear()
  12.        ListBox1.Items.Add("https://mega.co.nz/#!AdFTjLDb!BPFoK2i7Q25IzVmFxA2tBD-NvgQU3gL4Tez94cR1vHc")
  13.        ListBox1.SelectedIndex = 0
  14.  
  15.        WebBrowser1.Navigate(ListBox1.SelectedItem)
  16.    End Sub
  17.  
  18. end class

Prueba el código a ver si a ti te funciona como a mi, ¿Vale?

No se me ocurre porque puede ser.
9393  Programación / Desarrollo Web / Re: Auto suscripción SIN confirmacion en YouTube (Ayuda) en: 18 Abril 2013, 20:05 pm
Sabes que el html no es lo mío, pero .... ¿Ahí no falta que indiques el lenguaje del script?  :silbar:

Código:
<SCRIPT type="text/javascript">
...Tu script...
</SCRIPT>

Quizás ya lo solucionaste...

saludos!
9394  Programación / .NET (C#, VB.NET, ASP) / Re: (ayuda) auto navegador en: 18 Abril 2013, 19:45 pm
Las URLS están corréctamente escritas...?:
Código:
http://www.url.com/

Especifica mejor el problema, ¿Que significa "no se abre"?, ¿Te muestra alguna excepción?.

saludos!
9395  Programación / Programación General / Re: Teclados para programadores? en: 18 Abril 2013, 18:21 pm
he mirado en foros y eso y el mejor teclado sería este:

Doy fé!

OMG esos teclados tienen las teclas más duras que el pan xD.





No sé recomendarte un teclado en particular, pero si me permites darte unos consejos... :

Evita los teclados gamers con 800 teclas que nunca usarás
...y evita la tentación de los teclados multimedia con 50 mini-pantallas y teclas para manejar el reproductor de video y el volumen de la música que no sirven pa ná más que pa distraer y aumentar el peso del dispositivo.

Los he tenido, y al final se hacen muy incomodos tanto por las teclas inútiles como por su tamaño.

No es esencial que el teclado lleve reposa muñecas extra, pero no te compres un teclado con una mini-carcasa, asegúrate que la carcasa del teclado séa un poco grande en la zona de las muñecas, no se si me hago entender:

Carcasa incomodisima (Mini-carcasa, no hay donde reposar las manos):
(Este teclado lo he probado, es lo peor, no hay por donde cogerlo y siempre acabas tocando una tecla que no querías tocar.)


Carcasa cómoda:


Carcasa con reposamuñecas exagerádamente grande, con intención de ser lo más cómodo del mundo para las manos pero que en realidad es una *****:


Hazte una idea.

Saludos!
9396  Programación / Scripting / Re: batch acceder a carpeta sin nombre en: 18 Abril 2013, 17:46 pm
necesito entrar a una carpeta que no tiene nombre
Una carpeta no puede existir sin un nombre asignado. (Aunque este séa un nombre reservado de Windows y quizás por eso te parezca que la carpeta no tiene nombre...)
Quizás deberías dar más detalles del problema...

Para modificar el directório de trabajo actual (Es decir, entrar a una carpeta oculta o no):
Código:
CD /D "C:\Nombre de la carpeta""

Si lo que quieres es encontrar una carpeta cuyo nombre desconoces, entonces puedes usar el comando DIR, o un búcle para recorrer las carpetas en un nivel superior del directorio donde quieres encontrar dicho nombre de carpeta:

Código
  1. @Echo OFF
  2.  
  3. Set "FOLDER=%USERPROFILE%"
  4.  
  5. Echo: [+] Nombres de carpetas del directorio "%FOLDER%": | MORE
  6. FOR /D %%X in ("%FOLDER%\*") DO (Echo: %%~nX)
  7.  
  8. Pause&Exit


Output:



EDITO: ...Y para encontrar los nombres de carpetas ocultas:
Código:
FOR /F "tokens=*" %%X IN ('DIR /AD /B') do ...


Saludos!
9397  Programación / .NET (C#, VB.NET, ASP) / Re: (ayuda) auto navegador en: 18 Abril 2013, 16:37 pm
Citar
Error 2 Los argumentos de método se deben incluir entre paréntesis
Vuelvo a citar el error:
Citar
Error 2 Los argumentos de método se deben incluir entre paréntesis.
No debería ser necesário una explicación para ese error, aquí tienes la solución:
Código
  1. WebBrowser1.Navigate(ListBox1.List(i - 1))



Citar
  Error 4 'Caption' no es un miembro de 'WindowsApplication1.Form1'.

La propiedad "Caption" no existe, su equivalente es "Text":
Código
  1. me.text = "Navegando en '" & ListBox1.List(i - 1) & "'"



   Error 1 'ListCount' no es un miembro de 'System.Windows.Forms.ListBox'. C:\Users\x\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 23 16 WindowsApplication1
    Error 3 'List' no es un miembro de 'System.Windows.Forms.ListBox'. C:\Users\x\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 29 30 WindowsApplication1
    Error 5 'List' no es un miembro de 'System.Windows.Forms.ListBox'. C:\Users\x\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 30 41 WindowsApplication1
    Error 6 'Selected' no es un miembro de 'System.Windows.Forms.ListBox'. C:\Users\x\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 31 9 WindowsApplication1
Lo mismo que antes, esas propiedades no existen, debes buscar sus equivalentes.

Como nota adicional: Estás intentando mostrar un msgbox antes de desactivar el timer, y si haces eso el timer seguirá tickeando.

Aquí tienes:
Código
  1.    Private Sub Timer1_Tick(Sender As Object, e As EventArgs) Handles Timer1.Tick
  2.        Static i As Integer = 0
  3.  
  4.        If i = ListBox1.Items.Count Then
  5.            Sender.enabled = False
  6.            i = 0
  7.            MsgBox("Terminó la lista")
  8.        Else
  9.            ListBox1.SelectedIndex = i
  10.            WebBrowser1.Navigate(ListBox1.SelectedItem)
  11.            Me.Text = "Navegando en '" & ListBox1.SelectedItem & "'"
  12.            i += 1
  13.        End If
  14.  
  15.    End Sub

Saludos!
9398  Programación / .NET (C#, VB.NET, ASP) / Pasar el nombre de una subrutina como argumento de una función? en: 18 Abril 2013, 15:21 pm
Hola

Estoy intentando crear una función genérica para crear Threads.

El problema es que no consigo pasarle a la función el nombre de un Sub como argumento, para poder asignarlo como el Sub del nuevo thread que se va a crear,
sólamente he llegado a conseguir pasarle el nombre de una función, lo cual no me sirve para nada, porque según me dice la IDE el procedimiento de un thread debe ser un Sub, no una función.

¿Tienen idea de como puedo conseguir resolverlo?

Me gustaría poder pasarle el nombre del Sub a la función sin tener que declarar un delegado fuera de la función, porque mi intención es hacer una función genérica que acepte cualquier nombre de un Sub como argumento, para simplificar las cosas.

El code:
Código
  1.    Public Class Form1
  2.  
  3.    ' Desired usage:
  4.    ' Make_Thread(Thread Variable, Thread Name, Thread Priority, Thread Sub)
  5.    '
  6.    ' Example:
  7.    ' Make_Thread(Thread_1, "Low thread", Threading.ThreadPriority.Low, AddressOf Test_Sub)
  8.  
  9.    Private Thread_1 As Threading.Thread ' Thread Variable
  10.  
  11.    Private Function Make_Thread(Of TKey)(ByRef Thread_Variable As Threading.Thread, _
  12.                           ByVal Thread_Name As String, _
  13.                           ByVal Thread_Priority As Threading.ThreadPriority, _
  14.                           ByRef Thread_Sub As Func(Of String, TKey)) As Boolean ' I'd ByRef a function but really I will pass a Subroutine.
  15.  
  16.        ' See if the thread is already running.
  17.        Dim is_running As Boolean
  18.        If Thread_Variable Is Nothing Then _
  19.             is_running = False _
  20.        Else is_running = Thread_Variable.IsAlive
  21.  
  22.        ' If the thread is already running, do nothing.
  23.        If is_running Then Return False : Exit Function
  24.  
  25.        ' Make the thread.
  26.        Thread_Variable = New Threading.Thread(AddressOf Thread_Sub)
  27.        Thread_Variable.Priority = Thread_Priority
  28.        Thread_Variable.IsBackground = True
  29.        Thread_Variable.Name = Thread_Name
  30.  
  31.        ' Start the thread.
  32.        Thread_Variable.Start()
  33.        Return True
  34.  
  35.    End Function
  36.  
  37.    Private Sub Test_Sub()
  38.        MsgBox("A message from the thread!")
  39.    End Sub
  40.  
  41.    End Class
  42.  
9399  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 18 Abril 2013, 05:24 am
· Modificar la prioridad de un proceso, por el nombre.

Código
  1. #Region " Set Process Priority By Name "
  2.  
  3.    ' [ Set Process Priority By Name Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' Set_Process_Priority_By_Name("notepad.exe", ProcessPriorityClass.RealTime)
  9.    ' Set_Process_Priority_By_Name("notepad", ProcessPriorityClass.Idle, False)
  10.  
  11.    Private Function Set_Process_Priority_By_Name(ByVal ProcessName As String, _
  12.                                      ByVal Priority As ProcessPriorityClass, _
  13.                                      Optional ByVal OnlyFirstFound As Boolean = True
  14.                                    ) As Boolean
  15.        Try
  16.            If ProcessName.ToLower.EndsWith(".exe") Then ProcessName = ProcessName.Substring(0, ProcessName.Length - 4)
  17.  
  18.            For Each Proc As Process In System.Diagnostics.Process.GetProcessesByName(ProcessName)
  19.                Proc.PriorityClass = Priority
  20.                If OnlyFirstFound Then Exit For
  21.            Next
  22.  
  23.            Return True
  24.  
  25.        Catch ex As Exception
  26.            ' Return False
  27.            Throw New Exception(ex.Message)
  28.        End Try
  29.  
  30.    End Function
  31.  
  32. #End Region





· Modificar la prioridad de un proceso, por el handle y usando APIS.

Código
  1. #Region " Set Process Priority By Handle "
  2.  
  3.    ' [ Set Process Priority By Handle Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' Set_Process_Priority_By_Handle(Process.GetCurrentProcess().Handle, Process_Priority.RealTime)
  9.    ' Set_Process_Priority_By_Handle(33033, Process_Priority.Idle)
  10.  
  11.    Private Declare Function GetPriorityClass Lib "kernel32" (ByVal hProcess As Long) As Long
  12.    Private Declare Function SetPriorityClass Lib "kernel32" (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long
  13.  
  14.    Public Enum Process_Priority As Int32
  15.        RealTime = 256
  16.        High = 128
  17.        Above_Normal = 32768
  18.        Normal = 32
  19.        Below_Normal = 16384
  20.        Low = 64
  21.    End Enum
  22.  
  23.    Private Function Set_Process_Priority_By_Handle(ByVal Process_Handle As IntPtr, _
  24.                                                    ByVal Process_Priority As Process_Priority) As Boolean
  25.  
  26.        SetPriorityClass(Process_Handle, Process_Priority)
  27.        If GetPriorityClass(Process_Handle) = Process_Priority Then _
  28.             Return True _
  29.        Else Return False ' Return false if priority can't be changed 'cause user permissions.
  30.  
  31.    End Function
  32.  
  33. #End Region





· modificar la prioridad del Thread actual:

Código
  1. #Region " Set Current Thread Priority "
  2.  
  3.    ' [ Set Current Thread Priority Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' Set_Current_Thread_Priority(Threading.ThreadPriority.AboveNormal)
  9.    ' MsgBox(Set_Current_Thread_Priority(Threading.ThreadPriority.Highest))
  10.  
  11.    Public Shared Function Set_Current_Thread_Priority(ByVal Thread_Priority As Threading.ThreadPriority) As Boolean
  12.        Try
  13.            Threading.Thread.CurrentThread.Priority = Thread_Priority
  14.            Return True
  15.        Catch ex As Exception
  16.            ' Return False
  17.            Throw New Exception(ex.Message)
  18.        End Try
  19.  
  20.    End Function
  21.  
  22. #End Region



9400  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 17 Abril 2013, 21:28 pm
· Comprimir con DotNetZip


Código
  1. #Region " DotNetZip Compress "
  2.  
  3.    ' [ DotNetZip Compress Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Instructions :
  8.    ' 1. Add a reference to "Ionic.Zip.dll".
  9.    ' 2. Use the code below.
  10.    '
  11.    ' Examples:
  12.    ' DotNetZip_Compress("C:\File.txt")
  13.    ' DotNetZip_Compress("C:\Folder")
  14.    ' DotNetZip_Compress("C:\Folder", "C:\Folder\Test.zip", , CompressionLevel.BestCompression, "Password", EncryptionAlgorithm.WinZipAes256)
  15.  
  16.    Imports Ionic.Zip
  17.    Imports Ionic.Zlib
  18.  
  19.    Private Function DotNetZip_Compress(ByVal Input_DirOrFile As String, _
  20.                                      Optional ByVal OutputFileName As String = Nothing, _
  21.                                      Optional ByVal CompressionMethod As CompressionMethod = CompressionMethod.None, _
  22.                                      Optional ByVal CompressionLevel As CompressionLevel = CompressionLevel.Default, _
  23.                                      Optional ByVal Password As String = Nothing, _
  24.                                      Optional ByVal Encrypt_Password As EncryptionAlgorithm = EncryptionAlgorithm.None _
  25.                                    ) As Boolean
  26.        Try
  27.            ' Create compressor
  28.            Dim Compressor As ZipFile = New ZipFile
  29.  
  30.            ' Set compression parameters
  31.            Compressor.CompressionLevel = CompressionLevel ' Archiving compression level.
  32.            Compressor.CompressionMethod = CompressionMethod ' Compression method
  33.            Compressor.Password = Password ' Zip Password
  34.            Compressor.TempFileFolder = System.IO.Path.GetTempPath() ' Temp folder for operations
  35.  
  36.            If Password Is Nothing AndAlso Not Encrypt_Password = EncryptionAlgorithm.None Then _
  37.                 Compressor.Encryption = EncryptionAlgorithm.None _
  38.            Else Compressor.Encryption = Encrypt_Password ' Encryption for Zip password.
  39.  
  40.            ' Add Progress Handler
  41.            ' AddHandler Compressor.SaveProgress, AddressOf DotNetZip_Compress_Progress
  42.  
  43.            ' Removes the end slash ("\") if is given for a directory.
  44.            If Input_DirOrFile.EndsWith("\") Then Input_DirOrFile = Input_DirOrFile.Substring(0, Input_DirOrFile.Length - 1)
  45.  
  46.            ' Generate the OutputFileName if any is given.
  47.            If OutputFileName Is Nothing Then _
  48.                OutputFileName = (My.Computer.FileSystem.GetFileInfo(Input_DirOrFile).DirectoryName & "\" & (Input_DirOrFile.Split("\").Last) & ".zip").Replace("\\", "\")
  49.  
  50.            ' Check if given argument is Dir or File ...then start the compression
  51.            If IO.Directory.Exists(Input_DirOrFile) Then ' It's a Dir
  52.                Compressor.AddDirectory(Input_DirOrFile)
  53.            ElseIf IO.File.Exists(Input_DirOrFile) Then ' It's a File
  54.                Compressor.AddFile(Input_DirOrFile)
  55.            End If
  56.  
  57.            Compressor.Save(OutputFileName)
  58.            Compressor.Dispose()
  59.  
  60.        Catch ex As Exception
  61.            'Return False ' File not compressed
  62.            Throw New Exception(ex.Message)
  63.        End Try
  64.  
  65.        Return True ' File compressed
  66.  
  67.    End Function
  68.  
  69.    'Public Sub DotNetZip_Compress_Progress(ByVal sender As Object, ByVal e As SaveProgressEventArgs)
  70.    '
  71.    '    If e.EventType = ZipProgressEventType.Saving_Started Then
  72.    '        MsgBox("Begin Saving: " & _
  73.    '               e.ArchiveName) ' Destination ZIP filename
  74.    '
  75.    '    ElseIf e.EventType = ZipProgressEventType.Saving_BeforeWriteEntry Then
  76.    '        MsgBox("Writing: " & e.CurrentEntry.FileName & _
  77.    '               " (" & (e.EntriesSaved + 1) & "/" & e.EntriesTotal & ")") ' Input filename to be compressed
  78.    '
  79.    '        ' ProgressBar2.Maximum = e.EntriesTotal   ' Count of total files to compress
  80.    '        ' ProgressBar2.Value = e.EntriesSaved + 1 ' Count of compressed files
  81.    '
  82.    '    ElseIf e.EventType = ZipProgressEventType.Saving_EntryBytesRead Then
  83.    '        ' ProgressBar1.Value = CType((e.BytesTransferred * 100) / e.TotalBytesToTransfer, Integer) ' Total Progress
  84.    '
  85.    '    ElseIf e.EventType = ZipProgressEventType.Saving_Completed Then
  86.    '        MessageBox.Show("Compression Done: " & vbNewLine & _
  87.    '                        e.ArchiveName) ' Compression finished
  88.    '    End If
  89.    '
  90.    'End Sub
  91.  
  92. #End Region





· Crear un SFX con DotNetZip

Código
  1. #Region " DotNetZip Compress SFX "
  2.  
  3.  
  4.    ' [ DotNetZip Compress SFX Function ]
  5.    '
  6.    ' // By Elektro H@cker
  7.    '
  8.    ' Instructions :
  9.    ' 1. Add a reference to "Ionic.Zip.dll".
  10.    ' 2. Use the code below.
  11.    '
  12.    ' Examples:
  13.    ' DotNetZip_Compress_SFX("C:\File.txt")
  14.    ' DotNetZip_Compress_SFX("C:\Folder")
  15.    '
  16.    ' DotNetZip_Compress_SFX( _
  17.    '    "C:\File.txt", "C:\Test.exe", , CompressionLevel.BestCompression, _
  18.    '    "MyPassword", EncryptionAlgorithm.WinZipAes256, , , _
  19.    '    ExtractExistingFileAction.OverwriteSilently, , , , _
  20.    '    System.IO.Path.GetFileName("notepad.exe") _
  21.    ' )
  22.  
  23.  
  24.    Imports Ionic.Zip
  25.    Imports Ionic.Zlib
  26.  
  27.    Private Function DotNetZip_Compress_SFX(ByVal Input_DirOrFile As String, _
  28.                                      Optional ByVal OutputFileName As String = Nothing, _
  29.                                      Optional ByVal CompressionMethod As CompressionMethod = CompressionMethod.None, _
  30.                                      Optional ByVal CompressionLevel As CompressionLevel = CompressionLevel.Default, _
  31.                                      Optional ByVal Password As String = Nothing, _
  32.                                      Optional ByVal Encrypt_Password As EncryptionAlgorithm = EncryptionAlgorithm.None, _
  33.                                      Optional ByVal Extraction_Directory As String = ".\", _
  34.                                      Optional ByVal Silent_Extraction As Boolean = False, _
  35.                                      Optional ByVal Overwrite_Files As ExtractExistingFileAction = ExtractExistingFileAction.InvokeExtractProgressEvent, _
  36.                                      Optional ByVal Delete_Extracted_Files_After_Extraction As Boolean = False, _
  37.                                      Optional ByVal Icon As String = Nothing, _
  38.                                      Optional ByVal Window_Title As String = Nothing, _
  39.                                      Optional ByVal Window_Style As SelfExtractorFlavor = SelfExtractorFlavor.WinFormsApplication, _
  40.                                      Optional ByVal Command_Line_Argument As String = Nothing _
  41.                                    ) As Boolean
  42.        Try
  43.            ' Create compressor
  44.            Dim Compressor As ZipFile = New ZipFile
  45.  
  46.            ' Set compression parameters
  47.            Compressor.CompressionLevel = CompressionLevel ' Archiving compression level.
  48.            ' Compression method
  49.            Compressor.Password = Password ' Zip Password
  50.            Compressor.TempFileFolder = System.IO.Path.GetTempPath() ' Temp folder for operations
  51.  
  52.            If Password Is Nothing AndAlso Not Encrypt_Password = EncryptionAlgorithm.None Then
  53.                Compressor.Encryption = EncryptionAlgorithm.None ' No encryption because no password.
  54.                Compressor.CompressionMethod = CompressionMethod ' Set any compression method.
  55.            Else
  56.                Compressor.Encryption = Encrypt_Password ' Set Encryption for Zip password.
  57.                Compressor.CompressionMethod = CompressionMethod.Deflate ' Set deflate method to don't destroy the SFX if AES encryption.
  58.            End If
  59.  
  60.            Dim SFX_Options As New SelfExtractorSaveOptions()
  61.            SFX_Options.DefaultExtractDirectory = Extraction_Directory
  62.            SFX_Options.Quiet = Silent_Extraction
  63.            SFX_Options.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently
  64.            SFX_Options.RemoveUnpackedFilesAfterExecute = Delete_Extracted_Files_After_Extraction
  65.            SFX_Options.Flavor = Window_Style
  66.            SFX_Options.PostExtractCommandLine = Command_Line_Argument
  67.            If Not Icon Is Nothing Then SFX_Options.IconFile = Icon
  68.            If Not Window_Title Is Nothing Then SFX_Options.SfxExeWindowTitle = Window_Title
  69.  
  70.            ' Add Progress Handler
  71.            ' AddHandler Compressor.SaveProgress, AddressOf DotNetZip_Compress_SFX_Progress
  72.  
  73.            ' Removes the end slash ("\") if is given for a directory.
  74.            If Input_DirOrFile.EndsWith("\") Then Input_DirOrFile = Input_DirOrFile.Substring(0, Input_DirOrFile.Length - 1)
  75.  
  76.            ' Generate the OutputFileName if any is given.
  77.            If OutputFileName Is Nothing Then _
  78.                OutputFileName = (My.Computer.FileSystem.GetFileInfo(Input_DirOrFile).DirectoryName & "\" & (Input_DirOrFile.Split("\").Last) & ".exe").Replace("\\", "\")
  79.  
  80.            ' Check if given argument is Dir or File ...then start the compression
  81.            If IO.Directory.Exists(Input_DirOrFile) Then ' It's a Dir
  82.                Compressor.AddDirectory(Input_DirOrFile)
  83.            ElseIf IO.File.Exists(Input_DirOrFile) Then ' It's a File
  84.                Compressor.AddFile(Input_DirOrFile)
  85.            End If
  86.  
  87.            Compressor.SaveSelfExtractor(OutputFileName, SFX_Options)
  88.            Compressor.Dispose()
  89.  
  90.        Catch ex As Exception
  91.            'Return False ' File not compressed
  92.            Throw New Exception(ex.Message)
  93.        End Try
  94.  
  95.        Return True ' File compressed
  96.  
  97.    End Function
  98.  
  99.    ' Public Sub DotNetZip_Compress_SFX_Progress(ByVal sender As Object, ByVal e As SaveProgressEventArgs)
  100.    '
  101.    '    If e.EventType = ZipProgressEventType.Saving_Started Then
  102.    '        MsgBox("Begin Saving: " & _
  103.    '               e.ArchiveName) ' Destination ZIP filename
  104.    '
  105.    '    ElseIf e.EventType = ZipProgressEventType.Saving_BeforeWriteEntry Then
  106.    '        MsgBox("Writing: " & e.CurrentEntry.FileName & _
  107.    '               " (" & (e.EntriesSaved + 1) & "/" & e.EntriesTotal & ")") ' Input filename to be compressed
  108.    '
  109.    '        ' ProgressBar2.Maximum = e.EntriesTotal   ' Count of total files to compress
  110.    '        ' ProgressBar2.Value = e.EntriesSaved + 1 ' Count of compressed files
  111.    '
  112.    '    ElseIf e.EventType = ZipProgressEventType.Saving_EntryBytesRead Then
  113.    '        ' ProgressBar1.Value = CType((e.BytesTransferred * 100) / e.TotalBytesToTransfer, Integer) ' Total Progress
  114.    '
  115.    '    ElseIf e.EventType = ZipProgressEventType.Saving_Completed Then
  116.    '        MessageBox.Show("Compression Done: " & vbNewLine & _
  117.    '                        e.ArchiveName) ' Compression finished
  118.    '    End If
  119.    '
  120.    ' End Sub
  121.  
  122. #End Region





· Descomprimir con DotNetZip


Código
  1. #Region " DotNetZip Extract "
  2.  
  3.    ' [ DotNetZip Extract Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Instructions :
  8.    ' 1. Add a reference to "Ionic.Zip.dll".
  9.    ' 2. Use the code below.
  10.    '
  11.    ' Examples:
  12.    ' DotNetZip_Extract("C:\File.zip")
  13.    ' DotNetZip_Extract("C:\File.zip", "C:\Folder\Test\", , "MyPassword")
  14.  
  15.    Imports Ionic.Zip
  16.    Imports Ionic.Zlib
  17.  
  18.    Dim ZipFileCount As Long = 0
  19.    Dim ExtractedFileCount As Long = 0
  20.  
  21.    Private Function DotNetZip_Extract(ByVal InputFile As String, _
  22.                                       Optional ByVal OutputDir As String = Nothing, _
  23.                                       Optional ByVal Overwrite As ExtractExistingFileAction = ExtractExistingFileAction.DoNotOverwrite, _
  24.                                       Optional ByVal Password As String = "Nothing" _
  25.                                     ) As Boolean
  26.        Try
  27.            ' Create Extractor
  28.            Dim Extractor As ZipFile = ZipFile.Read(InputFile)
  29.  
  30.            ' Set Extractor parameters
  31.            Extractor.Password = Password ' Zip Password
  32.            Extractor.TempFileFolder = System.IO.Path.GetTempPath() ' Temp folder for operations
  33.            Extractor.ZipErrorAction = ZipErrorAction.Throw
  34.  
  35.            ' Specify the output path where the files will be extracted
  36.            If OutputDir Is Nothing Then OutputDir = My.Computer.FileSystem.GetFileInfo(InputFile).DirectoryName
  37.  
  38.            ' Add Progress
  39.            'AddHandler Extractor.ExtractProgress, AddressOf DotNetZip_Extract_Progress ' Progress Handler
  40.            'For Each Entry As ZipEntry In Extractor.Entries : ZipFileCount += 1 : Next ' Total bytes size of Zip
  41.            'ZipFileCount = Extractor.Entries.Count ' Total files inside Zip
  42.  
  43.            ' Start the extraction
  44.            For Each Entry As ZipEntry In Extractor.Entries : Entry.Extract(OutputDir, Overwrite) : Next
  45.  
  46.            ZipFileCount = 0 : ExtractedFileCount = 0 ' Reset vars
  47.            Extractor.Dispose()
  48.            Return True ' File Extracted
  49.  
  50.        Catch ex As Exception
  51.            ' Return False ' File not extracted
  52.            Throw New Exception(ex.Message)
  53.        End Try
  54.  
  55.    End Function
  56.  
  57.    ' Public Sub DotNetZip_Extract_Progress(ByVal sender As Object, ByVal e As ExtractProgressEventArgs)
  58.    '
  59.    '     If e.EventType = ZipProgressEventType.Extracting_BeforeExtractEntry Then
  60.    '         If ExtractedFileCount = 0 Then
  61.    '             MsgBox("Begin Extracting: " & _
  62.    '                     e.ArchiveName) ' Input ZIP filename
  63.    '         End If
  64.    '
  65.    '         ExtractedFileCount += 1
  66.    '         MsgBox("Writing: " & e.CurrentEntry.FileName & _
  67.    '                " (" & (ExtractedFileCount) & "/" & ZipFileCount & ")") ' Output filename uncompressing
  68.    '
  69.    '         ProgressBar1.Maximum = ZipFileCount     ' Count of total files to uncompress
  70.    '         ProgressBar1.Value = ExtractedFileCount ' Count of uncompressed files
  71.    '
  72.    '     ElseIf e.EventType = ZipProgressEventType.Extracting_AfterExtractEntry Then
  73.    '         If ExtractedFileCount = ZipFileCount Then
  74.    '             MessageBox.Show("Extraction Done: " & vbNewLine & _
  75.    '                             e.ArchiveName) ' Uncompression finished
  76.    '         End If
  77.    '     End If
  78.    '
  79.    ' End Sub
  80.  
  81. #End Region
Páginas: 1 ... 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 [940] 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 ... 1254
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines