Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: Lyckety15 en 25 Noviembre 2005, 21:33 pm



Título: Formateo de 1 pc
Publicado por: Lyckety15 en 25 Noviembre 2005, 21:33 pm
¿me podrian decir algun codigo de fuente k haga 1 formateo de pc? espero k se pueda weno cuidense chao


Título: Re: Formateo de 1 pc
Publicado por: #Borracho.- en 25 Noviembre 2005, 23:05 pm
El ejemplo q te voy a dar ahora tiene una opción para hacer la copia del disco y formatear este...
Salu2

Bueno, abres un proyecto nuevo, y colocas un DriveListBox, luego colocas 3 botones: 1 que se llame cmdFormat, el 2 que se llame cmdDiskCopy, y el otro que se llame cmdExit.

Eso es unicamente si no quieres cambiar el formato del código que te pongo a continuación:

Código:
Private Declare Function SHFormatDrive Lib "shell32" (ByVal hwnd As Long, ByVal Drive As Long, ByVal fmtID As Long, ByVal options As Long) As Long
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long


Private Sub cmdDiskCopy_Click()


    Dim DriveLetter$, DriveNumber&, DriveType&
    Dim RetVal&, RetFromMsg&
    DriveLetter = UCase(Drive1.Drive)
    DriveNumber = (Asc(DriveLetter) - 65)
    DriveType = GetDriveType(DriveLetter)
    If DriveType = 2 Then
        RetVal = Shell("rundll32.exe diskcopy.dll,DiskCopyRunDll " _
            & DriveNumber & "," & DriveNumber, 1)
    Else
        RetFromMsg = MsgBox("Only floppies can" & vbCrLf & _
            "be diskcopied!", 64, "DiskCopy Example")
    End If
   
End Sub

Private Sub cmdExit_Click()
    Unload Form1
    Set Form1 = Nothing
End Sub

Private Sub cmdFormat_Click()

Dim DriveLetter$, DriveNumber&, DriveType&
    Dim RetVal&, RetFromMsg%
    DriveLetter = UCase(Drive1.Drive)
    DriveNumber = (Asc(DriveLetter) - 65)
    DriveType = GetDriveType(DriveLetter)
    If DriveType = 2 Then
        RetVal = SHFormatDrive(Me.hwnd, DriveNumber, 0&, 0&)
    Else
        RetFromMsg = MsgBox("This drive is NOT a removeable" & vbCrLf & _
            "drive! Format this drive?", 276, "SHFormatDrive Example")
        Select Case RetFromMsg
            Case 6
            Case 7
        End Select
    End If
   
End Sub


Private Sub Drive1_Change()

Dim DriveLetter$, DriveNumber&, DriveType&
    DriveLetter = UCase(Drive1.Drive)
    DriveNumber = (Asc(DriveLetter) - 65)
    DriveType = GetDriveType(DriveLetter)
    If DriveType <> 2 Then
        cmdDiskCopy.Enabled = False
    Else
        cmdDiskCopy.Enabled = True
    End If
   
End Sub


Bueno creo que es ese... Ya (la verdad no me acuerdo) aunque mientras lo fui escribiendo me pareció que era para FormatFloppy.

Espero q te sirva de todas formas... :P
Salu2