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

 

 


Tema destacado: Introducción a la Factorización De Semiprimos (RSA)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)
0 Usuarios y 2 Visitantes están viendo este tema.
Páginas: 1 2 3 4 5 6 7 8 [9] 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ... 59 Ir Abajo Respuesta Imprimir
Autor Tema: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)  (Leído 484,238 veces)
TrashAmbishion


Desconectado Desconectado

Mensajes: 756


Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #80 en: 16 Abril 2013, 18:51 pm »

Ja no tienes nada que hacer verdad !! GRacias por los aportes  ;-) ;-) ;-) ;-) ;-)

 ::) ;D

Dale suave !!


En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.806



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #81 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


En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.806



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #82 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



« Última modificación: 18 Abril 2013, 05:34 am por EleKtro H@cker » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.806



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #83 en: 19 Abril 2013, 00:06 am »

· Detectar la ejecución de la aplicación en una máquina virtual.


Código
  1. #Region " Detect Virtual Machine "
  2.  
  3.    ' [ Detect Virtual Machine Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Instructions :
  8.    ' 1. Add a reference for "System.Management"
  9.    '
  10.    ' Examples :
  11.    ' MsgBox(Detect_Virtual_Machine)
  12.    ' If Detect_Virtual_Machine() Then MsgBox("This program cannot run on a virtual machine")
  13.  
  14.    Imports System.Management
  15.  
  16.    Private Function Detect_Virtual_Machine() As Boolean
  17.  
  18.        Dim ModelName As String = Nothing
  19.        Dim SearchQuery = New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE BytesPerSector > 0")
  20.  
  21.        For Each ManagementSystem In SearchQuery.Get
  22.  
  23.            ModelName = ManagementSystem("Model").ToString.Split(" ").First.ToLower
  24.  
  25.            If ModelName = "virtual" Or _
  26.               ModelName = "vmware" Or _
  27.               ModelName = "vbox" Or _
  28.               ModelName = "qemu" _
  29.            Then
  30.                Return True ' Virtual machine HDD Model Name found
  31.            End If
  32.  
  33.        Next
  34.  
  35.        Return False ' Virtual machine HDD Model Name not found
  36.  
  37.    End Function
  38.  
  39. #End Region
En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.806



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #84 en: 19 Abril 2013, 00:27 am »

A ver si alguien se anima y hace un snippet Anti-Sandbox, que según he leido es bien fácil: http://www.aspfree.com/c/a/braindump/virtualization-and-sandbox-detection/ pero por desgracia hay demasiados software virtualizadores para ponerse a probar uno por uno para hacer una función genérica...

PD: ¿A nadie le interesa aportar snippets aquí? :(

Saludos!
En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.806



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #85 en: 19 Abril 2013, 04:22 am »

· Animar la ventana con efectos

Código
  1. #Region " Animate Window "
  2.  
  3.    ' [ Animate Window ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' AnimateWindow(Me.Handle, 1500, Animation.Show_Fade)
  9.    ' AnimateWindow(Me.Handle, 1500, Animation.Hide_Center)
  10.  
  11.    Public Declare Function AnimateWindow Lib "user32" (ByVal hwnd As IntPtr, ByVal dwtime As Int64, ByVal dwflags As Animation) As Boolean
  12.  
  13.    Public Enum Animation As Int32
  14.  
  15.        Show_Left_To_Right = 1
  16.        Show_Right_To_left = 2
  17.        Show_Top_To_Bottom = 4
  18.        Show_Bottom_to_top = 8
  19.        Show_Corner_Left_UP = 5
  20.        Show_Corner_Left_Down = 9
  21.        Show_Corner_Right_UP = 6
  22.        Show_Corner_Right_Down = 10
  23.        Show_Center = 16
  24.        Show_Fade = 524288
  25.  
  26.        Hide_Left_To_Right = 1 Or 65536
  27.        Hide_Right_To_left = 2 Or 65536
  28.        Hide_Top_To_Bottom = 4 Or 65536
  29.        Hide_Bottom_to_top = 8 Or 65536
  30.        Hide_Corner_Left_UP = 5 Or 65536
  31.        Hide_Corner_Left_Down = 9 Or 65536
  32.        Hide_Corner_Right_UP = 6 Or 65536
  33.        Hide_Corner_Right_Down = 10 Or 65536
  34.        Hide_Center = 16 Or 65536
  35.        Hide_Fade = 524288 Or 65536
  36.  
  37.    End Enum
  38.  
  39. #End Region
« Última modificación: 19 Abril 2013, 04:29 am por EleKtro H@cker » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.806



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #86 en: 19 Abril 2013, 17:42 pm »

· Ejemplo de un String multi-línea para aplicaciones de consola:

Código
  1.        Dim Logo As String = <a><![CDATA[
  2.  ___              _ _           _   _               _____ _ _   _      
  3. / _ \            | (_)         | | (_)             |_   _(_) | | |    
  4. / /_\ \_ __  _ __ | |_  ___ __ _| |_ _  ___  _ __     | |  _| |_| | ___
  5. |  _  | '_ \| '_ \| | |/ __/ _` | __| |/ _ \| '_ \    | | | | __| |/ _ \
  6. | | | | |_) | |_) | | | (_| (_| | |_| | (_) | | | |   | | | | |_| |  __/
  7. \_| |_/ .__/| .__/|_|_|\___\__,_|\__|_|\___/|_| |_|   \_/ |_|\__|_|\___|
  8.      | |   | |                                                        
  9.      |_|   |_|                                                        
  10.  
  11. ]]></a>.Value
  12.  
  13. Console.WriteLine(Logo)

En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.806



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #87 en: 19 Abril 2013, 18:47 pm »

· Setear los argumentos commandline por defecto del modo debug de la aplicación.

Código
  1. #Region " Set CommandLine Arguments "
  2.  
  3.    ' [ Set CommandLine Arguments Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples:
  8.    ' For Each Arg In Arguments : MsgBox(Arg) : Next
  9.  
  10.    Dim Arguments As List(Of String) = Set_CommandLine_Arguments()
  11.  
  12.    Public Function Set_CommandLine_Arguments() As List(Of String)
  13. #If DEBUG Then
  14.        ' Debug Commandline arguments for this application:
  15.        Dim DebugArguments = "Notepad.exe -Sleep 5 -Interval 50 -Key CTRL+C"
  16.        Return DebugArguments.Split(" ").ToList
  17. #Else
  18.        ' Nomal Commandline arguments
  19.        Return My.Application.CommandLineArgs.ToList
  20. #End If
  21.    End Function
  22.  
  23. #End Region


« Última modificación: 19 Abril 2013, 18:56 pm por EleKtro H@cker » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.806



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #88 en: 19 Abril 2013, 19:34 pm »

· Un Sub especial para el control de terceros "CButton", para modificar los colores (Y actualizar el estado de los colores).

http://www.codeproject.com/Articles/26622/Custom-Button-Control-with-Gradient-Colors-and-Ext

Código
  1. #Region " Change Cbutton Color "
  2.  
  3.    ' [ Change Cbutton Color ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples:
  8.    ' Change_Cbutton_Color(CButton1, Color.Black, Color.DarkRed, Color.Red)
  9.  
  10.  
  11.    Private Sub Change_Cbutton_Color(ByVal Button_Name As CButtonLib.CButton, _
  12.                                      ByVal Color1 As Color, _
  13.                                      ByVal Color2 As Color, _
  14.                                      ByVal Color3 As Color)
  15.  
  16.        Button_Name.ColorFillBlend.iColor(0) = Color1
  17.        Button_Name.ColorFillBlend.iColor(1) = Color2
  18.        Button_Name.ColorFillBlend.iColor(2) = Color3
  19.        Button_Name.UpdateDimBlends()
  20.  
  21.    End Sub
  22.  
  23. #End Region
« Última modificación: 19 Abril 2013, 19:36 pm por EleKtro H@cker » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.806



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #89 en: 19 Abril 2013, 22:35 pm »

· comprueba si Aero está activado:

Código
  1. #Region " Is Aero Enabled? "
  2.  
  3.    ' [ Is Aero Enabled? Function ]
  4.    '
  5.    ' Examples:
  6.    ' MsgBox(Is_Aero_Enabled)
  7.  
  8.    <System.Runtime.InteropServices.DllImport("dwmapi.dll")> _
  9.    Private Shared Function DwmIsCompositionEnabled(ByRef enabled As Boolean) As Integer
  10.    End Function
  11.  
  12.    Public Function Is_Aero_Enabled() As Boolean
  13.        If Environment.OSVersion.Version.Major < 6 Then
  14.            Return False ' Windows version is under Windows Vista so not Aero.
  15.        Else
  16.            DwmIsCompositionEnabled(Is_Aero_Enabled)
  17.        End If
  18.    End Function
  19.  
  20. #End Region
En línea

Páginas: 1 2 3 4 5 6 7 8 [9] 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ... 59 Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines