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

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


  Mostrar Mensajes
Páginas: 1 2 [3] 4 5 6 7 8 9 10 11 12 13 14 15
21  Programación / .NET (C#, VB.NET, ASP) / Re: Una pregunta sobre IO.Directory.GetFiles en: 27 Enero 2013, 12:59 pm
codigo vieejo y con ayuda de varias, pero la connserve y justo t viene para aprender

Código
  1. Imports System.Runtime.InteropServices
  2. Imports System.Text.RegularExpressions
  3. Imports System.Text
  4. Imports System.IO
  5.  
  6. Public Class ClsBucarFiles
  7.  
  8. #Region "   Icon    "
  9.  
  10.    Private Structure SHFILEINFO
  11.        Public hIcon As IntPtr ' : icon
  12.        Public iIcon As Integer ' : icondex
  13.        Public dwAttributes As Integer ' : SFGAO_ flags
  14.        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> _
  15.        Public szDisplayName As String
  16.        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> _
  17.        Public szTypeName As String
  18.    End Structure
  19.  
  20.    Private Declare Ansi Function SHGetFileInfo Lib "shell32.dll" (ByVal pszPath As String, _
  21.    ByVal dwFileAttributes As Integer, ByRef psfi As SHFILEINFO, ByVal cbFileInfo As Integer, _
  22.    ByVal uFlags As Integer) As IntPtr
  23.  
  24.    Private Const SHGFI_SMALLICON As Long = &H1
  25.    Private Const SHGFI_SYSICONINDEX As Long = &H4000
  26.    Private Const SHGFI_USEFILEATTRIBUTES As Long = &H10
  27.    Private Const SHGFI_TYPENAME As Long = &H400
  28.    Private Const SHGFI_DISPLAYNAME As Long = &H200
  29.    Private Const SHGFI_ICON = &H100
  30.    Private Const SHGFI_LARGEICON = &H0         ' Large icon
  31.    Private Shared shfitmp As SHFILEINFO   'just used for the following
  32.    Private Shared SHFILESIZE As Integer = Marshal.SizeOf(shfitmp.GetType())
  33.  
  34.    Public Function ptricon(ByVal vsPath As String) As IntPtr
  35.        Dim hImgSmall As IntPtr
  36.        Dim shinfo As New SHFILEINFO()
  37.        shinfo.szDisplayName = New String(Chr(0), 260)
  38.        shinfo.szTypeName = New String(Chr(0), 80)
  39.        hImgSmall = SHGetFileInfo(vsPath, 0&, shinfo, SHFILESIZE, _
  40.        SHGFI_ICON Or SHGFI_SYSICONINDEX Or SHGFI_SMALLICON)
  41.        Return (shinfo.hIcon)
  42.    End Function
  43.  
  44. #End Region
  45.  
  46. #Region " Declaraciones "
  47.    <DllImport("kernel32.dll")> _
  48.    Private Shared Function FindClose(ByVal hFindFile As IntPtr) As Boolean
  49.    End Function
  50.  
  51.    <DllImport("kernel32.dll", CharSet:=CharSet.None)> _
  52.    Private Shared Function FindFirstFile(ByVal lpFileName As String, ByRef lpFindFileData As WIN32_FIND_DATA) As IntPtr
  53.    End Function
  54.  
  55.    Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As IntPtr, ByRef lpFindFileData As WIN32_FIND_DATA) As Boolean
  56.  
  57.    <StructLayout(LayoutKind.Sequential)> _
  58.    Structure WIN32_FIND_DATA
  59.        Public dwFileAttributes As UInteger
  60.        Public ftCreationTime As System.Runtime.InteropServices.ComTypes.FILETIME
  61.        Public ftLastAccessTime As System.Runtime.InteropServices.ComTypes.FILETIME
  62.        Public ftLastWriteTime As System.Runtime.InteropServices.ComTypes.FILETIME
  63.        Public nFileSizeHigh As UInteger
  64.        Public nFileSizeLow As UInteger
  65.        Public dwReserved0 As UInteger
  66.        Public dwReserved1 As UInteger
  67.        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public cFileName As String
  68.        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=14)> Public cAlternateFileName As String
  69.    End Structure
  70.  
  71.  
  72.    Public Event FileFound(ByVal sPath As String, ByVal sFile As String, ByVal atributos As FileAttributes)
  73.    Public Event FolderFound(ByVal sPath As String, ByVal sFolder As String, ByVal atributos As FileAttributes)
  74.  
  75.    Private cancel As Boolean = False
  76.  
  77.    Private INVALID_HANDLE_VALUE As New IntPtr(-1)
  78.  
  79.    Private RegExp As Regex
  80.  
  81.    Private sbFiles As New StringBuilder
  82.  
  83.    Private sbFolders As New StringBuilder
  84. #End Region
  85.  
  86. #Region " PRocedimientos "
  87.  
  88.    Public Sub New()
  89.  
  90.        MyBase.New()
  91.    End Sub
  92.  
  93.    Public Sub start()
  94.        If RegExp Is Nothing Then
  95.            RegExp = New Regex(p_match, RegexOptions.IgnoreCase)
  96.        Else
  97.            RegExp = Nothing
  98.            RegExp = New Regex(p_match, RegexOptions.IgnoreCase)
  99.        End If
  100.  
  101.        cancel = False
  102.  
  103.        Dim arrdrive() As String
  104.  
  105.        arrdrive = p_path.Split(Chr(59))
  106.  
  107.        For Each s As String In arrdrive
  108.            Call SubBusqueda(s) 'recursividad xD
  109.        Next
  110.  
  111.    End Sub
  112.  
  113.    Public Sub Cancelar()
  114.        cancel = True
  115.    End Sub
  116.    Private Function StripNulls(ByVal sData As String) As String
  117.        StripNulls = Left$(sData, Len(sData))
  118.    End Function
  119.    Private Sub SubBusqueda(ByVal vsPath As String)
  120.        Dim ptrSearch As New IntPtr
  121.        Dim vsfile As String = String.Empty
  122.        Dim vsfolder As String = String.Empty
  123.        Dim vaDir As New ArrayList
  124.        Dim wfd As New WIN32_FIND_DATA
  125.        Dim dir As String = String.Empty
  126.        Dim ret As Boolean
  127.  
  128.        If cancel Then Exit Sub
  129.  
  130.        Call NormalizePath(vsPath)
  131.        ptrSearch = FindFirstFile(vsPath & "*", wfd)
  132.  
  133.        If Not ptrSearch = INVALID_HANDLE_VALUE Then
  134.  
  135.            Do
  136.                If (wfd.dwFileAttributes And FileAttributes.Directory) <> FileAttributes.Directory Then
  137.                    vsfile = StripNulls(wfd.cFileName)
  138.  
  139.                    If Not p_hide Then
  140.  
  141.                        If (wfd.dwFileAttributes And FileAttributes.Hidden) = FileAttributes.Hidden Then GoTo FNEXT
  142.  
  143.                    End If
  144.  
  145.                    If RegExp.Matches(vsfile).Count = 0 Then GoTo FNEXT
  146.  
  147.                    sbFiles.AppendLine(vsfile)
  148.  
  149.                    RaiseEvent FileFound(vsPath, vsfile, CType(wfd.dwFileAttributes, FileAttributes))
  150.                Else
  151.  
  152.                    If Not p_hide Then
  153.                        If (wfd.dwFileAttributes And FileAttributes.Hidden) = FileAttributes.Hidden Then GoTo FNEXT
  154.                    End If
  155.  
  156.                    vsfolder = StripNulls(wfd.cFileName)
  157.  
  158.                    If (vsfolder <> ".") And (vsfolder <> "..") Then
  159.                        dir = vsPath & vsfolder & "\"
  160.  
  161.                        If Not p_sys Then
  162.  
  163.                            If dir = Environ("Windir") & "\" Then GoTo FNEXT
  164.                        End If
  165.  
  166.                        vaDir.Add(dir)
  167.                        If RegExp.Matches(vsfolder).Count = 0 Then GoTo FNEXT
  168.                        sbFolders.AppendLine(vsfolder)
  169.                        RaiseEvent FolderFound(vsPath, vsfolder, CType(wfd.dwFileAttributes, FileAttributes))
  170.  
  171.                    End If
  172.                End If
  173. FNEXT:
  174.  
  175.                If cancel Then FindClose(ptrSearch) : Exit Sub
  176.                Application.DoEvents()
  177.  
  178.                ret = FindNextFile(ptrSearch, wfd)
  179.            Loop While ret
  180.            Call FindClose(ptrSearch)
  181.        End If
  182.  
  183.        If p_subfolder Then
  184.  
  185.            For i As Integer = 0 To vaDir.Count - 1
  186.  
  187.                Call SubBusqueda(CStr(vaDir(i)))
  188.            Next
  189.  
  190.        End If
  191.    End Sub
  192.  
  193.    Private Function drivers() As String
  194.        Dim drive As DriveInfo
  195.        Dim dr As New StringBuilder
  196.  
  197.        For Each drive In DriveInfo.GetDrives
  198.            With drive
  199.                If .IsReady Then
  200.                    dr.Append(drive.Name & ";")
  201.                End If
  202.            End With
  203.        Next
  204.        Return dr.ToString
  205.    End Function
  206.  
  207.    Private Function ReplaceFilter(ByVal sFilter As String) As String
  208.        sFilter = sFilter.Replace("+", "\+")
  209.        sFilter = sFilter.Replace(".", "\.")
  210.        sFilter = sFilter.Replace("|", "\|")
  211.        sFilter = sFilter.Replace(";", "|\b")
  212.        sFilter = sFilter.Replace(" ", "|\b")
  213.        sFilter = sFilter.Replace("{", "\{")
  214.        sFilter = sFilter.Replace("}", "\}")
  215.        sFilter = sFilter.Replace("*", ".+")
  216.        sFilter = sFilter.Replace("?", ".{1}")
  217.        sFilter = sFilter.Replace("(", "\(")
  218.        sFilter = sFilter.Replace(")", "\)")
  219.        sFilter = sFilter.Replace("^", "\^")
  220.        sFilter = sFilter.Replace("$", "\$")
  221.        sFilter = sFilter.Replace("[", "\[")
  222.        sFilter = sFilter.Replace("[", "\]")
  223.  
  224.        Do While CBool(InStr(sFilter, "|\b|\b"))
  225.            sFilter = Replace$(sFilter, "|\b|\b", "|\b")
  226.        Loop
  227.        Return "^(" & sFilter & ")$|(" & sFilter & ".+)"
  228.    End Function
  229.  
  230.  
  231.    Public Function NormalizePath(byval sData As String) As String
  232.  
  233.        If Strings.Len(sData) > 1 Then
  234.            sData = Strings.Replace(sData, "/", "\")
  235.            If Not Strings.Right(sData, 1) = "\" Then
  236.                Return sData & "\"
  237.            Else
  238.                Return sData
  239.            End If
  240.        End If
  241.  
  242.    End Function
  243.  
  244.  
  245. #End Region
  246.  
  247. #Region " propiedades "
  248.    Private p_match As String = String.Empty
  249.  
  250.    WriteOnly Property Match() As String
  251.        Set(ByVal value As String)
  252.            p_match = ReplaceFilter(value)
  253.        End Set
  254.    End Property
  255.  
  256.    Private p_subfolder As Boolean = False
  257.    Property SubFolder() As Boolean
  258.        Get
  259.            Return p_subfolder
  260.        End Get
  261.        Set(ByVal value As Boolean)
  262.            p_subfolder = value
  263.        End Set
  264.    End Property
  265.    Private p_hide As Boolean = False
  266.    Property HideFolder() As Boolean
  267.        Get
  268.            Return p_hide
  269.        End Get
  270.        Set(ByVal value As Boolean)
  271.            p_hide = value
  272.        End Set
  273.    End Property
  274.    Private p_sys As Boolean = False
  275.    Property SysFolder() As Boolean
  276.        Get
  277.            Return p_sys
  278.        End Get
  279.        Set(ByVal value As Boolean)
  280.            p_sys = value
  281.        End Set
  282.    End Property
  283.    Private p_path As String = drivers()
  284.    Property Path() As String
  285.        Get
  286.            Return p_path
  287.        End Get
  288.        Set(ByVal value As String)
  289.  
  290.            p_path = NormalizePath(value)
  291.        End Set
  292.    End Property
  293.    ReadOnly Property FilesString() As String
  294.        Get
  295.            Return sbFolders.ToString
  296.        End Get
  297.    End Property
  298.  
  299.    ReadOnly Property FolderString() As String
  300.        Get
  301.  
  302.            Return sbFolders.ToString
  303.        End Get
  304.    End Property
  305. #End Region
  306.  
  307. End Class
  308.  
22  Programación / .NET (C#, VB.NET, ASP) / Re: Una pregunta sobre IO.Directory.GetFiles en: 26 Enero 2013, 18:18 pm
si quieres algo rapido y optimo, usas apis, regular expresion,
23  Programación / Programación Visual Basic / Re: Aplicación en Red [Mover a VB] en: 25 Enero 2013, 09:31 am
si trabajas desde socket y a la vez envias el comando requerido que el servidor pueda interpretar y modificar el registro es posible.
lee sobre el espacio de nombres System.net
24  Programación / .NET (C#, VB.NET, ASP) / Re: Como usar FileSystemWatcher en: 23 Enero 2013, 16:57 pm
http://msdn.microsoft.com/es-es/library/system.io.filesystemwatcher(v=vs.80).aspx

pero para lo que queres noc si sera..
25  Informática / Software / Re: [Proyecto]GamesRec ---avances--- en: 8 Enero 2013, 19:27 pm
el-brujo muchas gracias man! es bueno que te guste y te paresca interesante  ;-)
26  Informática / Software / Re: [Proyecto]GamesRec ---avances--- en: 8 Enero 2013, 12:27 pm
Garlock tenemos una sola competencia en este rubro...
kub0x pronto tio la probaras..
27  Informática / Software / [Proyecto]GamesRec ---avances--- en: 8 Enero 2013, 06:30 am
GamesRec será una aplicación de escritorio para capturar imágenes y vídeos de alta calidad en momentos de juego, la aplicación permitirá compartir dichas imágenes a través de las redes sociales más conocidas Twitter y Facebook de manera automática mediante la asociación de cuentas a la aplicación haciendo uso de las API de las redes sociales mencionadas, Cuenta con un chat social exclusivo para gammers y mas mucho mas.

  • Diseño Modern UI con controles totalemente codeados desde Cero
  • Necesitaremos BetaTester, eso tendra beneficios al que encuentre los bug, con una cuenta premiun del soft.
  • tambien queremos saber de sus opiniones que mas le pondrian.




el software



Gracias saludos y opinen !

EDIT: Mod Disculpas moved a software
28  Programación / .NET (C#, VB.NET, ASP) / Re: GamesRec [Proyecto] [Imágenes] en: 3 Enero 2013, 20:54 pm
me arme algo de prueba con mi codigo para que veas.
29  Programación / .NET (C#, VB.NET, ASP) / Re: GamesRec [Proyecto] [Imágenes] en: 3 Enero 2013, 05:21 am
ya te envie un mp
30  Programación / .NET (C#, VB.NET, ASP) / Re: GamesRec [Proyecto] [Imágenes] en: 3 Enero 2013, 04:00 am
yo e trabajado con gdi+ en un proyecto para la uni sobre escritorio remoto, si me comentas puedo pasarte algo keyent
Páginas: 1 2 [3] 4 5 6 7 8 9 10 11 12 13 14 15
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines