fuwi Posted November 17, 2005 Posted November 17, 2005 (edited) Edit: Problem solved! see my last post!==========================================================; drive formatter;; works with AutoIt3 vers. 3.1.1.1.65 and older; dont work with with AutoIt3 vers. 3.1.1.1.66 and newer !!$DriveNumber = 0 ; 0 = A: 1 = B: 2 = first HD 3 = ...$Capacity = 0 ; 0 = default drive capacity$FormatType = 1 ; 0 = full format, 1 = quick formatDllCall("SHELL32.DLL", "long", "SHFormatDrive", _ "hwnd", 0xFFFF, _ "long", $DriveNumber, _ "long", $Capacity, _ "long", $FormatType) ; has something changed in 3.1.1.1.66 und up? Edited November 18, 2005 by fuwi
Zedna Posted November 17, 2005 Posted November 17, 2005 (edited) ; drive formatter ; ; works with AutoIt3 vers. 3.1.1.1.65 and older ; dont work with with AutoIt3 vers. 3.1.1.1.66 and newer !! What means "don't work"? Is there any error message or @error after DllCall is not 0? You also could add _GetLastErrorMessage() after DllCall() DllCall(...) If @error Then _GetLastErrorMessage("After DLLCall") End If ;=============================================== ; _GetLastErrorMessage($DisplayMsgBox="") ; Format the last windows error as a string and return it ; if $DisplayMsgBox <> "" Then it will display a message box w/ the error ; Return Window's error as a string ;=============================================== Func _GetLastErrorMessage($DisplayMsgBox="") Local $ret,$s Local $p = DllStructCreate("char[4096]") Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000 If @error Then Return "" $ret = DllCall("Kernel32.dll","int","GetLastError") $ret = DllCall("kernel32.dll","int","FormatMessage",_ "int",$FORMAT_MESSAGE_FROM_SYSTEM,_ "ptr",0,_ "int",$ret[0],_ "int",0,_ "ptr",DllStructGetPtr($p),_ "int",4096,_ "ptr",0) $s = DllStructGetData($p,1) DllStructDelete($p) If $DisplayMsgBox <> "" Then MsgBox(0,"_GetLastErrorMessage",$DisplayMsgBox & @CRLF & $s) return $s EndFunc Edited November 17, 2005 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
jpm Posted November 17, 2005 Posted November 17, 2005 ; drive formatter;; works with AutoIt3 vers. 3.1.1.1.65 and older; dont work with with AutoIt3 vers. 3.1.1.1.66 and newer !!$DriveNumber = 0 ; 0 = A: 1 = B: 2 = first HD 3 = ...$Capacity = 0 ; 0 = default drive capacity$FormatType = 1 ; 0 = full format, 1 = quick formatDllCall("SHELL32.DLL", "long", "SHFormatDrive", _ "hwnd", 0xFFFF, _ "long", $DriveNumber, _ "long", $Capacity, _ "long", $FormatType) ; has something changed in 3.1.1.1.66 und up?If it is an syntax error , yes continuation line need to have a blank before the underscore
Valik Posted November 17, 2005 Posted November 17, 2005 The way HWND's are handled has changed at that time but I don't know why that is affecting your code. Your code should of never worked since you are clearly ignoring the documentation for the SHFormatDrive: hwnd [in]The handle of the parent window of the dialog. The Format dialog must have a parent window; therefore, this parameter cannot be NULL.Don't try to beat the system by passing in a non-null but invalid HWND. Obtain a valid handle to something (The Desktop?) and pass it. If doing that still does not work, then I'll look further into why the behavior has changed.
fuwi Posted November 17, 2005 Author Posted November 17, 2005 @Zedna "dont work" -> the script terminates immediatly, nothing happens, @error is 0 "works" -> the MS Format-GUI is starting (same as you rightclick on 3 1/2 Floppy (A:) and select "Format...") @jpm yes, there blanks before the underscore
tonedeaf Posted November 18, 2005 Posted November 18, 2005 I didn't check your script but I've this script working since release 3.1.0.**DON'T CLICK THE FORMAT BUTTON**_ShowFormatDialog("C") Func _ShowFormatDialog($sDriveLetter) Local $SHFD_CAPACITY_DEFAULT = 0 Local $SHMT_FORMAT_QUICK = 1 ;Quick format Local $SHMT_FORMAT_FULL = 0 ;Full format Local $iLetter $iLetter = Asc($sDriveLetter) - 65 DllCall("shell32.dll", "long", "SHFormatDrive", "hwnd", 0, "int", $iLetter, _ "int", $SHFD_CAPACITY_DEFAULT, "int", $SHMT_FORMAT_QUICK) EndFunc
fuwi Posted November 18, 2005 Author Posted November 18, 2005 Problem solved!@tonedeafI changed "hwnd" from 0xffff to 0 as in your script.Now it works with all AutoIt3 versions!But i think, 0 is also not a valid handle,see AutoIt3 Help - Function Reference - Function HWnd - Return Value:Failure - If the HWND does not denote a valid window,a 0 (NULL) HWND will be returned and @error set to 1. I have solved now my problem (many thanks to Valik for the focus to the handle-problem):later this DllCall-code will be part of a AutoIt-GUI, so i have made this prototypefor testing. The value of "hwnd" in the DllCall is now the handle of my AutoIt-GUI.This works now with all AutoIt3 versions:#include <GUIConstants.au3> $DriveNumber = 0; 0 = A: 1 = B: 2 = C: 3 = ... $Capacity = 0 ; 0 = default drive capacity $FormatType = 1 ; 0 = full format, 1 = quick format $MyGuiHandle = GUICreate("Format-GUI", 210, 80) $Label = GUICtrlCreateLabel("Test, Test, Test", 10, 10) $FormatID = GUICtrlCreateButton("Format", 10, 50, 50, 20) $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20) GUISetState() ; display the GUI Do $msg = GUIGetMsg() Select Case $msg= $FormatID DllCall("SHELL32.DLL", "long", "SHFormatDrive", _ "hwnd", $MyGuiHandle, _ "long", $DriveNumber, _ "long", $Capacity, _ "long", $FormatType) Case $msg= $ExitID Exit Case $msg= $GUI_EVENT_CLOSE Exit EndSelect Until $msg = $GUI_EVENT_CLOSE or $msg = $ExitIDMany thanks to the AutoIt3 community!
stealthf117jm Posted June 8, 2007 Posted June 8, 2007 (edited) --> SHFormatDrive <--Thank you this is exactly what I was looking for.FYI if anyone wants more information on it: http://msdn2.microsoft.com/en-us/library/ms647748.aspxI didn't see anything there or when i searched the forums about other methods of formatting disks besides opening a console window and manually doing it. This is what I've been doing until I found this.I know I can have AutoIt select "File System" type and click "Start" & "Ok" to format, but are there any other methods of formatting a drive primarily to get no prompts and having the parameters for the file system type? From the page above it doesn't look like this method supports these types of features. Edited June 8, 2007 by stealthf117jm
stealthf117jm Posted June 8, 2007 Posted June 8, 2007 Are there any other methods of formatting a drive primarily to get no prompts and having the parameters for the file system type? From the page above it doesn't look like this method supports these types of features. Originally when I searched for DOS commands to format I did not find a silent method of formatting. I just looked again found this: http://www.computing.net/dos/wwwboard/forum/7671.html Undocumented Format Switches To format without prompts use:- Format a: /autotest be careful I've been told this can format your Hard Disk without prompts. To format without prompts but ask for a volume label use:- Format a: /backup Hope this is of some use to somebody On the current versions of Windows console I could not get /autotest to function, but /backup worked great, and if you supply a volume name in the command you get no prompts at all and can be ran as: #include <Process.au3> _RunDOS("format {volume name} V: /FS:{file system} /V:{volume label} /X [b]/backup[/b]") Odd that such switches would exists but not be listed when you format /? so people can actually use them
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now