|
-
Aug 3rd, 2000, 11:40 AM
#1
Thread Starter
Member
Well, given that:
shell "C:\blahblahblah.blah", vbnormalfocus works, would it work say like this:
drive = inputbox("What drive would you like to format?")
shell "c:\windows\format.exe" & drive &, vbnormalfocus
Now would that format the drive given in the input box? or not....thanks for that reply
-----------------------------------------------------------
Wisdom is supreme, therefore get wisdom,
though it costs all you have, get understanding.
Proverbs 4:7
-----------------------------------------------------------
-
Aug 3rd, 2000, 12:32 PM
#2
_______
<?>
What's the matter..no nerve to try?
Never Work...if you want to format here is the code!
Code:
'make a form with 2 command buttons and a drivelistbox
'format a drive on your computer
'if you blow yourself out of the water it's your problem
'not mine....this is code that works so use it with
'a little knowledge....
'
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 Command1_Click()
Dim DriveLetter$, DriveNumber&, DriveType&
Dim RetVal&, RetFromMsg%
DriveLetter = UCase(Drive1.Drive)
DriveNumber = (Asc(DriveLetter) - 65) ' Change letter to Number: A=0
DriveType = GetDriveType(DriveLetter)
If DriveType = 2 Then 'Floppies, etc
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 'Yes
' UnComment to do it...
'RetVal = SHFormatDrive(Me.hwnd, DriveNumber, 0&, 0&)
Case 7 'No
' Do nothing
End Select
End If
End Sub
Private Sub Command2_Click()
' DiskCopyRunDll takes two parameters- From and To
Dim DriveLetter$, DriveNumber&, DriveType&
Dim RetVal&, RetFromMsg&
DriveLetter = UCase(Drive1.Drive)
DriveNumber = (Asc(DriveLetter) - 65)
DriveType = GetDriveType(DriveLetter)
If DriveType = 2 Then 'Floppies, etc
RetVal = Shell("rundll32.exe diskcopy.dll,DiskCopyRunDll " _
& DriveNumber & "," & DriveNumber, 1) 'Notice space after
Else ' Just in Case 'DiskCopyRunDll
RetFromMsg = MsgBox("Only floppies can" & vbCrLf & _
"be diskcopied!", 64, "DiskCopy Example")
End If
End Sub
'Add 1 ListDrive name Drive1
Private Sub Drive1_Change()
Dim DriveLetter$, DriveNumber&, DriveType&
DriveLetter = UCase(Drive1.Drive)
DriveNumber = (Asc(DriveLetter) - 65)
DriveType = GetDriveType(DriveLetter)
If DriveType = 2 Then 'Floppies, etc
Command2.Enabled = False
Else
Command2.Enabled = True
End If
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 3rd, 2000, 12:37 PM
#3
Frenzied Member
you've got an extra & in there so it probably won't compile, Ive never used the format command from the command line but something like this should work
Code:
Do 'Keep looping round until valid letter is given
drive = inputbox("What drive would you like to format?")
'I suspect you need to run it with a colon after the drive letter
If Not (Right(drive,2) = ":") Then
drive = drive & ":"
End If
'Now check it's 2 characters long (a letter and a colon)
If Len(drive) = 2 and IsAlphaNumeric(Left(drive,1)) Then
shell "c:\windows\format.exe " & drive , vbnormalfocus 'NB note the Space after the EXE name
Exit Do 'Leave the loop
Else
Msgbox "Invalid Drive Name
End If
Loop
-
Aug 3rd, 2000, 12:54 PM
#4
_______
<?>
Beg to differ Sam..
there is no such file as Format.exe...format is a function form dos..the shell command above says
your shell statement produces this
C:\Windows\Format.exe" a:
Dos would say this
Format a:
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 3rd, 2000, 01:10 PM
#5
Frenzied Member
as I say, I've never run it from the command line, and i didn't want to try because I don't want to format any of the disks I have lying around
-
Aug 3rd, 2000, 01:25 PM
#6
_______
<?>
wasn't a dig...just a FYI...
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 3rd, 2000, 01:46 PM
#7
transcendental analytic
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|