Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - cobein

#191
No te preocupes, yo no sufro, hay cosas mas importantes que un comentario tuyo. Simplemente lo cite para que te dieras cuenta lo fuera de lugar que estabas y al parecer funciono.

Bueno, no tieme mucho sentido seguir con esto porque no es util para el foro y me imagino que lo sabras mejor que yo. Como dicen en mis pagos, "Para que gastar polvora en chimangos".

Nadie se ofendio ni mucho menos, me alegro que tengas tu respuesta que era lo importante de este thread. Suerte con tu proyecto!!!

Para el que no entienda el dicho:

hXXp://www.avesdelapatagonia.com.ar/chimangotx1.htm

Resulta paradójico entonces que en muchos lugares el chimango sea perseguido y cazado. “No hay que gastar pólvora en chimangos” es un dicho popular del folklore argentino que alude a que no deben dedicarse esfuerzos a cosas que no valen la pena. El origen de este refrán está en que esta ave rapaz no es buena para comer, de modo que nadie razonablemente encara su caza.
#192
No dije nada, tenes razon, era mi maquina y no el source xD de 10
#193
Che, te quedo muy lindo, limpio y facil de usar. Una cosa que note es que no tiene soporte para el mousewheel, estaria bueno porque es bastante comodo.
#194
Como tobu dice, "pasate a net dios mio de mi alma.y no me digas que es net." te apuesto que es mucho mas facil.
#195
Dios mio de mi alma, 300 MB de un framework para no saber como se programa ni como se saca el serial de un USB drive.
Eso es a lo que yo llamo no tener idea de nada. "Usa NET que no tenes que aprender nada"
#196
Lo saque de un modulo que uso que tiene mas cosas asi que si no estan todas las declaraciones... creo que si pero si falta algo lo pueden agregar.

'---------------------------------------------------------------------------------------
' Module      : mUSBSerial
' DateTime    : 24/06/2008 07:54
' Author      : Cobein
' Mail        : cobein27@hotmail.com
' WebPage     : http://www.advancevb.com.ar/
' Purpose     : Read USB device srial.
' Usage       : At your own risk
' Requirements: None
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce
'               or publish this code on any web site,
'               online service, or distribute as source
'               on any media without express permission.
'
' History     : 24/06/2008 First Cut....................................................
'---------------------------------------------------------------------------------------

Option Explicit

Private Const INVALID_HANDLE_VALUE  As Long = (-1)
Private Const OPEN_EXISTING         As Long = 3
Private Const GENERIC_READ          As Long = &H80000000
Private Const FILE_SHARE_READ       As Long = &H1
Private Const FILE_SHARE_WRITE      As Long = &H2
Private Const IOCTL_STORAGE_BASE    As Long = &H2D
Private Const METHOD_BUFFERED       As Long = 0
Private Const FILE_ANY_ACCESS       As Long = 0

Private Const ERROR_NOERROR         As Long = &H0
Private Const ERROR_INVALIDBUSTYPE  As Long = &H2
Private Const ERROR_GENERICERROR    As Long = &H4

Private Const DIGCF_PRESENT         As Long = &H2
Private Const DIGCF_DEVICEINTERFACE As Long = &H10

Private Enum STORAGE_PROPERTY_ID
   StorageDeviceProperty = 0
   StorageAdapterProperty
End Enum

Private Enum STORAGE_QUERY_TYPE
   PropertyStandardQuery = 0
   PropertyExistsQuery
   PropertyMaskQuery
   PropertyQueryMaxDefined
End Enum

Public Enum STORAGE_BUS_TYPE
   BusTypeUnknown = 0
   BusTypeScsi
   BusTypeAtapi
   BusTypeAta
   BusType1394
   BusTypeSsa
   BusTypeFibre
   BusTypeUsb
   BusTypeRAID
   BusTypeMaxReserved = &H7F
End Enum

Private Type STORAGE_PROPERTY_QUERY
   PropertyId                      As STORAGE_PROPERTY_ID
   QueryType                       As STORAGE_QUERY_TYPE
   AdditionalParameters(0)         As Byte
End Type

Private Type STORAGE_DEVICE_NUMBER
   dwDeviceType                    As Long
   dwDeviceNumber                  As Long
   dwPartitionNumber               As Long
End Type

Private Type OVERLAPPED
   Internal                        As Long
   InternalHigh                    As Long
   offset                          As Long
   OffsetHigh                      As Long
   hEvent                          As Long
End Type

Private Type STORAGE_DEVICE_DESCRIPTOR
   Version                         As Long
   SIZE                            As Long
   DeviceType                      As Byte
   DeviceTypeModifier              As Byte
   RemovableMedia                  As Byte
   CommandQueueing                 As Byte
   VendorIdOffset                  As Long
   ProductIdOffset                 As Long
   ProductRevisionOffset           As Long
   SerialNumberOffset              As Long
   BusType                         As STORAGE_BUS_TYPE
   RawPropertiesLength             As Long
   RawDeviceProperties(0)          As Byte
End Type

Private Type GUID
   Data1                           As Long
   Data2                           As Integer
   Data3                           As Integer
   Data4(0 To 7)                   As Byte
End Type

Private Type SP_DEVICE_INTERFACE_DATA
   cbSize                          As Long
   InterfaceClassGuid              As GUID
   flags                           As Long
   Reserved                        As Long
End Type

Private Type SP_DEVINFO_DATA
   cbSize                          As Long
   ClassGuid                       As GUID
   DevInst                         As Long
   Reserved                        As Long
End Type

Private Type SP_DEVICE_INTERFACE_DETAIL_DATA
   cbSize                          As Long
   strDevicePath                   As String * 260
End Type

Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function DeviceIoControl Lib "kernel32" (ByVal hDevice As Long, ByVal dwIoControlCode As Long, lpInBuffer As Any, ByVal nInBufferSize As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesReturned As Long, lpOverlapped As Any) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function SetupDiGetClassDevs Lib "setupapi.dll" Alias "SetupDiGetClassDevsA" (ByVal ClassGuid As Long, ByVal Enumerator As Long, ByVal HwndParent As Long, ByVal flags As Long) As Long
Private Declare Function SetupDiEnumDeviceInterfaces Lib "setupapi.dll" (ByVal DeviceInfoSet As Long, ByVal DeviceInfoData As Long, ByRef InterfaceClassGuid As GUID, ByVal MemberIndex As Long, ByRef DeviceInterfaceData As SP_DEVICE_INTERFACE_DATA) As Long
Private Declare Function SetupDiGetDeviceInterfaceDetail Lib "setupapi.dll" Alias "SetupDiGetDeviceInterfaceDetailA" (ByVal DeviceInfoSet As Long, ByRef DeviceInterfaceData As SP_DEVICE_INTERFACE_DATA, DeviceInterfaceDetailData As Any, ByVal DeviceInterfaceDetailDataSize As Long, ByRef RequiredSize As Long, DeviceInfoData As Any) As Long
Private Declare Function SetupDiDestroyDeviceInfoList Lib "setupapi.dll" (ByVal DeviceInfoSet As Long) As Long
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Declare Function QueryDosDevice Lib "kernel32" Alias "QueryDosDeviceA" (ByVal lpDeviceName As String, ByVal lpTargetPath As String, ByVal ucchMax As Long) As Long

Public Function GetUSBSerial(ByVal sDrive As String, ByRef sSerial As String) As Long
   Dim sDriveFormated      As String
   Dim sData               As String
   
   On Local Error GoTo GetUSBSerial_Error

   If Not GetDriveBusType(sDrive) = BusTypeUsb Then
       GetUSBSerial = ERROR_INVALIDBUSTYPE
       Exit Function
   End If
   
   sDriveFormated = "\\.\" & Left$(sDrive, 1) & ":"
   sDrive = Left$(sDrive, 1) & ":"
   
   sData = GetDriveDevicePathByDeviceNumber( _
      GetDeviceNumber(sDriveFormated), GetDriveType(sDrive), sDrive)
     
   sData = Split(sData, "#")(2)
   sSerial = Split(sData, "&")(0)
   
   GetUSBSerial = ERROR_NOERROR
   
   Exit Function
   
GetUSBSerial_Error:
   GetUSBSerial = ERROR_GENERICERROR
End Function

Private Function GetDriveDevicePathByDeviceNumber(ByVal lDevNumb As Long, ByVal lDriveType As Long, ByVal sDevice As String) As String
   Dim tGUID                               As GUID
   Dim hDevInfo                            As Long
   Dim tSP_DEVICE_INTERFACE_DATA           As SP_DEVICE_INTERFACE_DATA
   Dim tSP_DEVICE_INTERFACE_DETAIL_DATA    As SP_DEVICE_INTERFACE_DETAIL_DATA
   Dim tSP_DEVINFO_DATA                    As SP_DEVINFO_DATA
   
   With tGUID
       .Data2 = &HB6BF:        .Data3 = &H11D0&
       .Data4(0) = &H94&:      .Data4(1) = &HF2&
       .Data4(2) = &H0&:       .Data4(3) = &HA0&
       .Data4(4) = &HC9&:      .Data4(5) = &H1E&
       .Data4(6) = &HFB&:      .Data4(7) = &H8B&
       
       Select Case lDriveType
           Case 2
               Dim sDosDev As String * 260
               Call QueryDosDevice(Left$(sDevice, 1) & ":", sDosDev, 260)
               If InStr(sDosDev, "\Floppy") Then
                   .Data1 = &H53F56311
               Else
                   .Data1 = &H53F56307
               End If
           Case 3
               .Data1 = &H53F56307
           Case 5
               .Data1 = &H53F56308
       End Select
   End With
   
   hDevInfo = SetupDiGetClassDevs(VarPtr(tGUID), 0, 0, _
      DIGCF_PRESENT Or DIGCF_DEVICEINTERFACE)
   If hDevInfo = -1 Then Exit Function

   tSP_DEVICE_INTERFACE_DATA.cbSize = Len(tSP_DEVICE_INTERFACE_DATA)
   
   Dim lRet As Long
   Dim lIndex As Long
   Dim lSize As Long
   Dim lReturn As Long
   
   Do
       lRet = SetupDiEnumDeviceInterfaces(hDevInfo, _
          0, tGUID, lIndex, tSP_DEVICE_INTERFACE_DATA)
       If lRet = 0 Then Exit Do
       lSize = 0
       Call SetupDiGetDeviceInterfaceDetail(hDevInfo, _
          tSP_DEVICE_INTERFACE_DATA, ByVal 0&, 0, lSize, ByVal 0&)
         
       If lSize <> 0 And lSize <= 1024 Then
           tSP_DEVICE_INTERFACE_DETAIL_DATA.cbSize = 5
           tSP_DEVINFO_DATA.cbSize = Len(tSP_DEVINFO_DATA)
           
           If SetupDiGetDeviceInterfaceDetail(hDevInfo, _
              tSP_DEVICE_INTERFACE_DATA, tSP_DEVICE_INTERFACE_DETAIL_DATA, _
              ByVal lSize, lReturn, tSP_DEVINFO_DATA) Then
               If lDevNumb = _
                  GetDeviceNumber(tSP_DEVICE_INTERFACE_DETAIL_DATA.strDevicePath) Then
                   Call SetupDiDestroyDeviceInfoList(hDevInfo)
                   GetDriveDevicePathByDeviceNumber = tSP_DEVICE_INTERFACE_DETAIL_DATA.strDevicePath
                   Exit Function
               End If
           End If
       End If
       lIndex = lIndex + 1
   Loop
   Call SetupDiDestroyDeviceInfoList(hDevInfo)
   
End Function

Private Function GetDeviceNumber(ByVal sDrive As String) As Long
   Dim lDriveNum               As Long
   Dim hVolume                 As Long
   Dim lRet                    As Long
   Dim tSTORAGE_DEVICE_NUMBER  As STORAGE_DEVICE_NUMBER
   Dim lRetBytes               As Long
   
   lDriveNum = -1

   hVolume = CreateFile(sDrive, 0, FILE_SHARE_READ Or FILE_SHARE_WRITE, _
      ByVal 0&, OPEN_EXISTING, 0, 0)
   If Not hVolume = INVALID_HANDLE_VALUE Then
       If DeviceIoControl(hVolume, &H2D1080, ByVal 0&, ByVal 0&, _
          tSTORAGE_DEVICE_NUMBER, Len(tSTORAGE_DEVICE_NUMBER), _
          lRetBytes, ByVal 0&) Then
           GetDeviceNumber = tSTORAGE_DEVICE_NUMBER.dwDeviceNumber
       End If
       Call CloseHandle(hVolume)
   End If
End Function

Public Function GetDriveBusType(ByVal sDrive As String) As STORAGE_BUS_TYPE
   Dim lRet                        As Long
   Dim lDevice                     As Long
   Dim tSTORAGE_DEVICE_DESCRIPTOR  As STORAGE_DEVICE_DESCRIPTOR
   Dim tOVERLAPPED                 As OVERLAPPED
   Dim tSTORAGE_PROPERTY_QUERY     As STORAGE_PROPERTY_QUERY

   sDrive = Left(sDrive, 1) & ":"

   lDevice = CreateFile("\\.\" & sDrive, 0, _
      FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0)
   
   If Not lDevice = INVALID_HANDLE_VALUE Then
       With tSTORAGE_PROPERTY_QUERY
           .PropertyId = StorageDeviceProperty
           .QueryType = PropertyStandardQuery
       End With
   
       Call DeviceIoControl( _
          lDevice, _
          IOCTL_STORAGE_QUERY_PROPERTY, _
          tSTORAGE_PROPERTY_QUERY, _
          LenB(tSTORAGE_PROPERTY_QUERY), _
          tSTORAGE_DEVICE_DESCRIPTOR, _
          LenB(tSTORAGE_DEVICE_DESCRIPTOR), _
          lRet, tOVERLAPPED)
   
       GetDriveBusType = tSTORAGE_DEVICE_DESCRIPTOR.BusType
       Call CloseHandle(lDevice)
   End If
   
End Function

Private Function IOCTL_STORAGE_QUERY_PROPERTY() As Long
   IOCTL_STORAGE_QUERY_PROPERTY = _
      (IOCTL_STORAGE_BASE * 2 ^ 16) Or _
      (FILE_ANY_ACCESS * 2 ^ 14) Or _
      (&H500 * 2 ^ 2) Or _
      (METHOD_BUFFERED)
End Function
#197
Vuelvo a decir esto, creo que ya lo comente varias veces, WMI no es recomendable, no siempre esta disponible, lo que hace el code muy susceptible a fallos.
#198
Podes usar un hook global (WH_MOUSE_LL) para obtener las coordenadas permanentemente y para posicionar la etiqueta correctamente podes usar ScreenToClient.
#199
A mi me mató el conector de su analogía, reemplazo el PERO por un " mas sin en cambio", tal vez habrá querido decir "mas sin embargo" pero "mas sin en cambio" es muy bueno xDD

de idiota a complicado salto el chico...
#200
Perdon, pero la analogia esa me mato, por poco y se me cae una lagrima.