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

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


  Mostrar Mensajes
Páginas: 1 ... 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [19] 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 ... 74
181  Programación / Programación Visual Basic / Re: [Proyecto]Explorador Remoto. en: 11 Octubre 2010, 03:07 am
Solucionado, Gracias Raul338 y BlackZeroX , habia que hacerlo con ReadDirectoryChangesW

Código
  1. Option Explicit
  2.  
  3. Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
  4. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  5. Private Declare Function ReadDirectoryChangesW Lib "kernel32.dll" (ByVal hDirectory As Long, ByVal lpBuffer As Long, ByVal nBufferLength As Long, ByVal bWatchSubtree As Boolean, ByVal dwNotifyFilter As Long, lpBytesReturned As Long, ByVal lpOverlapped As Long, ByVal lpCompletionRoutine As Long) As Long
  6. Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
  7. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Long, ByVal Source As Long, ByVal Length As Long)
  8.  
  9. Private Const FILE_SHARE_DELETE             As Long = &H4
  10. Private Const FILE_SHARE_READ               As Long = &H1
  11. Private Const FILE_SHARE_WRITE              As Long = &H2
  12. Private Const FILE_LIST_DIRECTORY           As Long = &H1
  13. Private Const OPEN_EXISTING                 As Long = &H3
  14. Private Const FILE_FLAG_BACKUP_SEMANTICS    As Long = &H2000000
  15. Private Const FILE_FLAG_OVERLAPPED          As Long = &H40000000
  16. Private Const INVALID_HANDLE_VALUE          As Long = (-1)
  17. Private Const FILE_NOTIFY_CHANGE_ALL        As Long = &H17F
  18.  
  19.  
  20. Private Type OVERLAPPED
  21.    Internal                        As Long
  22.    InternalHigh                    As Long
  23.    offset                          As Long
  24.    OffsetHigh                      As Long
  25.    hEvent                          As Long
  26. End Type
  27.  
  28. Private Type FILE_NOTIFY_INFORMATION
  29.    dwNextEntryOffset               As Long
  30.    dwAction                        As Long
  31.    dwFileNameLength                As Long
  32.    wcFileName(1023)                As Byte
  33. End Type
  34.  
  35.  
  36. Private Type DriveChange
  37.    hDrive                          As Long
  38.    sDrive                          As String
  39.    Buff(0 To 1024 * 9 - 1)         As Byte
  40. End Type
  41.  
  42.  
  43. Private aChange()           As DriveChange
  44.  
  45. Private MyFileName          As String
  46.  
  47. Private Sub Form_Load()
  48.    MyFileName = "RemoteImagen.bmp"
  49.    Picture1.OLEDragMode = 1
  50. End Sub
  51.  
  52. Private Sub Picture1_OLECompleteDrag(Effect As Long)
  53.    Debug.Print GetDestination(MyFileName)
  54.    Kill App.Path & "\" & MyFileName
  55. End Sub
  56.  
  57.  
  58. Private Sub Picture1_OLEStartDrag(Data As DataObject, AllowedEffects As Long)
  59.    Open App.Path & "\" & MyFileName For Binary As #1: Close #1
  60.  
  61.    Call StartWatching
  62.    Data.SetData , vbCFFiles
  63.    Data.Files.Add App.Path & "\" & MyFileName
  64.    AllowedEffects = vbDropEffectCopy
  65. End Sub
  66.  
  67. Public Sub StartWatching()
  68.    Dim lRet As Long
  69.    Dim sBuff As String * 255
  70.    Dim arrDrive() As String
  71.    Dim lPos As Long
  72.    Dim i As Long
  73.    Dim tOLAP As OVERLAPPED
  74.  
  75.    lRet = GetLogicalDriveStrings(255, sBuff)
  76.  
  77.    arrDrive = Split(Left$(sBuff, lRet - 1), Chr$(0))
  78.  
  79.    For i = 0 To UBound(arrDrive)
  80.        lRet = CreateFile(arrDrive(i), FILE_LIST_DIRECTORY, FILE_SHARE_READ Or FILE_SHARE_DELETE Or FILE_SHARE_WRITE, 0&, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS Or FILE_FLAG_OVERLAPPED, 0&)
  81.  
  82.        If lRet <> INVALID_HANDLE_VALUE Then
  83.            ReDim Preserve aChange(lPos)
  84.            aChange(lPos).hDrive = lRet
  85.            aChange(lPos).sDrive = arrDrive(i)
  86.            lPos = lPos + 1
  87.        End If
  88.    Next
  89.  
  90.    For i = 0 To UBound(aChange)
  91.        Call ReadDirectoryChangesW(aChange(i).hDrive, VarPtr(aChange(i).Buff(0)), 9216, True, FILE_NOTIFY_CHANGE_ALL, 0&, VarPtr(tOLAP), 0&)
  92.    Next
  93.  
  94. End Sub
  95.  
  96. Private Function GetDestination(ByVal sName As String) As String
  97.    Dim i As Long
  98.    Dim sData As String
  99.    Dim lPos As Long
  100.    Dim lRet As Long
  101.    Dim tFNI As FILE_NOTIFY_INFORMATION
  102.    Dim tOLAP As OVERLAPPED
  103.  
  104.    Dim SafeCounter As Long
  105.  
  106.    Do While SafeCounter < 1000
  107.  
  108.        For i = 0 To UBound(aChange)
  109.            lPos = 0
  110.  
  111.            Do
  112.                Call CopyMemory(VarPtr(tFNI), VarPtr(aChange(i).Buff(lPos)), Len(tFNI))
  113.  
  114.                sData = Left$(tFNI.wcFileName, tFNI.dwFileNameLength / 2)
  115.  
  116.                If InStr(sData, sName) Then
  117.                    GetDestination = aChange(i).sDrive & sData
  118.                    GoTo StopWatching
  119.                End If
  120.  
  121.                If tFNI.dwNextEntryOffset = 0 Then Exit Do
  122.  
  123.                lPos = lPos + tFNI.dwNextEntryOffset
  124.            Loop
  125.  
  126.            Call ReadDirectoryChangesW(aChange(i).hDrive, VarPtr(aChange(i).Buff(0)), 9216, True, FILE_NOTIFY_CHANGE_ALL, 0&, VarPtr(tOLAP), 0&)
  127.  
  128.            DoEvents
  129.        Next
  130.        SafeCounter = SafeCounter + 1
  131.  
  132.    Loop
  133.  
  134.    Debug.Print "Error or Cancel"
  135.  
  136. StopWatching:
  137.  
  138.    For i = 0 To UBound(aChange)
  139.        Call CloseHandle(aChange(i).hDrive)
  140.    Next
  141.  
  142.    Erase aChange
  143.  
  144. End Function
  145.  
  146.  
182  Programación / Programación Visual Basic / Re: [Proyecto]Explorador Remoto. en: 10 Octubre 2010, 10:33 am
si de echo yo pensaba lo mismo, pero no lo intente, Cobein hizo una clase FileSystemWatcher para vb6

Saludos.
183  Programación / Programación Visual Basic / Re: [Solucionado] Como Desbloquear un Array... en: 10 Octubre 2010, 10:24 am
BlackZeroX fijate que se puede eliminar sin utilizar el array temporal

Código:
Function RemoveInArrayLong(ByVal Index As Long, ByRef ThisArray() As Long) As Boolean
    Dim LenArray As Long
    LenArray = UBound(ThisArray)
    If Index < 0 Or Index > LenArray Then Exit Function
    If Not (Index = LenArray) Then
        Call CopyMemory(VarPtr(ThisArray(Index)), VarPtr(ThisArray(Index + 1)), (LenArray - Index) * 4)
    End If
    If LenArray - 1 >= 0 Then
        ReDim Preserve ThisArray(LenArray - 1)
        RemoveInArrayLong = True
    Else
        Erase ThisArray()
    End If
End Function
184  Programación / Programación Visual Basic / Re: [Proyecto]Explorador Remoto. en: 10 Octubre 2010, 03:13 am
Gracias raul338 por reportar el bugs, ya lo estoy corrigiendo, en cuanto a lo del drag a drop que me pasaste el otro día, bueno mala educación la mía no responder ejej, pero igualmente no me sirve por el tema de que el archivo no existe en la pc, osea para poder hacerlo de esa forma primero deberia descargar el archivo y como este no trabaja de una forma sincronizada, no puedo, yo lo que necesitaria saber es el destino donde se soltó el item para luego hacer una descarga normal.
no importa que el uclistview no tenga los eventos del drag and drop yo se los agrego.
una solución no muy elegante que me salio
http://www.vbforums.com/showthread.php?t=629147
pero no esta bien ya que no funciona con el escritorio, con subitems del listview de la carpeta y menos con el treview del explorer, osea una cagada.
pero no importa ya fue.

saludos. y gracias a todos por sus comentarios.
185  Programación / Programación Visual Basic / Re: [Proyecto]Explorador Remoto. en: 9 Octubre 2010, 03:43 am
aja si es cierto 76 kb, es mucho mas interesante, porque en la primera etapa pesa 120 kb voy mal ;D.

Saludos.
186  Programación / Programación Visual Basic / [Proyecto]Explorador Remoto. en: 9 Octubre 2010, 03:16 am
Hola es un poco mas de lo mismo, por el momento es un explorador remoto de archivos y carpetas realizado en vb, tiene unas cuantas herramientas.
si les interesa saber un poco mas de que se trata y descargarlo abajo esta el link.





Descargar.
187  Programación / Programación Visual Basic / Drag and Drop, vbCFFiles, conocer la carpeta de destino en: 1 Octubre 2010, 04:34 am
Hola, como podria hacer un drag and drop sobre una carpeta y poder conocer el destino de esta carpeta, para poder abrir un archivo en forma binarya.

si yo utilizo este metodo
Código:
Private Sub ListView1_OLEStartDrag(Data As ComctlLib.DataObject, AllowedEffects As Long)
    Dim i As Long
   
    For i = 1 To ListView1.ListItems.Count
   
        If ListView1.ListItems.Item(i).Selected = True Then
       
            Data.Files.Add ListView1.ListItems(i).Tag
            Data.SetData , vbCFFiles
           
        End If
       
    Next

End Sub

es nesesario que el archivo ya exista (ListView1.ListItems(i).Tag) pero esto me obliga a no poder continuar modificandolo.

mi nececidad es crearlo luego de haber hecho el drag and drop.

Es posible esto?
188  Programación / Programación Visual Basic / Re: [RETO] Cuadradro Numerico en de forma "¬" en: 18 Septiembre 2010, 05:07 am
ok siempre apurado no leo bien las cosas  ;D

Código:
Option Explicit

Private Declare Function GetTickCount Lib "kernel32.dll" () As Long

Private Sub Form_Load()
    Dim arr() As Long, lNum As Long
    Dim t As Long
   
   
    t = GetTickCount
   
    lNum = 1000
   
    CuadradoArray arr, lNum

    Debug.Print ArrToString(arr, lNum)
   
    MsgBox GetTickCount - t
End Sub


Private Sub CuadradoArray(arr() As Long, lNum As Long)
    Dim x As Long, y As Long, n As Long
    Dim i As Long, lCount As Long
   
    ReDim arr(lNum - 1, lNum - 1)
   
    For n = 0 To lNum - 1
   
        y = i
        i = i + 1
       
        For x = 0 To lNum - i
            lCount = lCount + 1
            arr(x, y) = lCount
        Next
   
        x = x - 1
       
        For y = i To lNum - 1
            lCount = lCount + 1
            arr(x, y) = lCount
        Next
       
    Next
End Sub


Private Function ArrToString(arr() As Long, ByVal lNum As Long) As String
    Dim x As Long, y As Long
    Dim LenFormat As Long
    Dim sVal As String
    Dim i As Long

    LenFormat = Len(CStr(lNum * lNum))

    ArrToString = String((lNum * lNum) * (LenFormat + 1), "0")

    lNum = lNum - 1

    For y = 0 To lNum
        For x = 0 To lNum
            sVal = arr(x, y)
            i = i + 1
            If x = lNum Then
                Mid$(ArrToString, (i * LenFormat) - Len(sVal) + i) = sVal & vbCr
            Else
                Mid$(ArrToString, (i * LenFormat) - Len(sVal) + i) = sVal & vbTab
            End If
        Next
    Next
End Function
189  Programación / Programación Visual Basic / Re: [SNIPPET] Mi primer snippet (copiado), obtener LocalAppData en Windows XP en: 18 Septiembre 2010, 03:03 am
y que hace la LocalAppData (?)

hace esto
Código:
Option Explicit

Private Sub Form_Load()
    MsgBox GetLocalAppData
End Sub

Public Function GetLocalAppData() As String
    GetLocalAppData = CreateObject("Shell.Application").NameSpace(28).Self.Path
End Function
 
190  Programación / Programación Visual Basic / Re: [RETO] Cuadradro Numerico en de forma "¬" en: 18 Septiembre 2010, 02:37 am
hay va el mio

Código:
Option Explicit

Private Sub Form_Load()
    Dim Arr() As Long, lNum As Long
   
    lNum = 10
   
    CuadradoArray Arr, lNum
   
    PrintArr Arr, lNum
End Sub


Private Sub CuadradoArray(Arr() As Long, lNum As Long)
    Dim x As Long, y As Long, n As Long
    Dim i As Long, lCount As Long
   
    ReDim Arr(lNum - 1, lNum - 1)
   
    For n = 0 To lNum - 1
   
        y = i
        i = i + 1
       
        For x = 0 To lNum - i
            lCount = lCount + 1
            Arr(x, y) = lCount
        Next
   
        x = x - 1
       
        For y = i To lNum - 1
            lCount = lCount + 1
            Arr(x, y) = lCount
        Next
       
    Next
End Sub

Private Sub PrintArr(Arr() As Long, lNum As Long)
    Dim x As Long, y As Long, sFormat As String
   
    sFormat = String(Len(CStr(lNum * lNum)), "0")
   
    For y = 0 To lNum - 1
        For x = 0 To lNum - 1
            Debug.Print Format(Arr(x, y), sFormat),
        Next
        Debug.Print
    Next
End Sub
Páginas: 1 ... 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [19] 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 ... 74
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines