Sign in to follow this  
Followers 0
Efo74

Function that return PhisicalDisc Numbers

3 posts in this topic

It is not best of programming but it works.

#include <File.au3>

#include <Process.au3>

$var = _Get_Phisical_Disk_Numbers()

for $i=1 to $var[0]

Msgbox(0,"\\.\PhysicalDrive" & $var[$i],$var[$i])

Next

;********************************************************************************

Func _Get_Phisical_Disk_Numbers()

;return the number of Phisical Drives installed \\.\PhysicalDrive(x)

;return array, array[0] = number of disk find

;array[0]=-1 if error

;********************************************************************************

Dim $Array_return[100]

$Array_return[0] = 0

$phisical_disk_find = 0

$s_TempFile = _TempFile()

$Run_command_line = "wmic partition get name,size,type >" & '"' & $s_TempFile & '"'

_RunDOS($Run_command_line)

if FileExists($s_TempFile)=0 Then

$Array_return[0]=-1

return $Array_return

EndIf

$file = FileOpen($s_TempFile, 0)

If $file = -1 Then

$Array_return[0]=-1

return $Array_return

EndIf

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

$start_extract = StringInStr($line, "#")

if $start_extract <> 0 Then

$start_extract+=1

$end_extract = StringInStr($line,",",0,1,$start_extract)

if $end_extract <> 0 Then

$str_disk_n = StringMid($line,$start_extract,$end_extract-$start_extract)

if ($str_disk_n <> "") Then

$phisical_disk_find+=1

$Array_return[0]=$phisical_disk_find

$Array_return[$phisical_disk_find]=$str_disk_n

EndIf

EndIf

EndIf

Wend

FileClose($file)

FileDelete($s_TempFile)

return $Array_return

EndFunc


:rolleyes:

Share this post


Link to post
Share on other sites



Yes John, DriveGetDrive return --> "C:" "D:" ...

My Function return ---> 0 1 2

For example

C: can not be 0


:rolleyes:

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0