From: Christian ASTOR on
bluestar wrote:

> But I don't how to format after i partitioned new disk.
> I don't know the Logical Drives of new disk, so I can't use
> other apis to format.

The matching Logical-Physical can be done with
GetLogicalDriveStrings() and
IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
on each drive letter (=>DiskNumber)
(or
IOCTL_STORAGE_GET_DEVICE_NUMBER)
From: bluestar on
On 7$B7n(B3$BF|(B, $B>e8a(B4$B;~(B04$BJ,(B, Christian ASTOR <casto...(a)club-internet.fr> wrote:
> bluestar wrote:
> > But I don't how to format after i partitioned new disk.
> > I don't know the Logical Drives of new disk, so I can't use
> > other apis to format.
>
> The matching Logical-Physical can be done with
> GetLogicalDriveStrings() and
> IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
> on each drive letter (=>DiskNumber)
> (or
> IOCTL_STORAGE_GET_DEVICE_NUMBER)


Dear Sir:

I use the API:GetLogicalDrives() to compare before and after
partition.
I already got new Logical Drive, and I try to use SHFormatDrive
to format.
( dwReturn = SHFormatDrive(this->m_hWnd, 'F' ,
SHFMT_ID_DEFAULT, 0); => Quick format that i do )
But I found the 2 points:
(1) it pops the format-dialog, and you need to keyin/select
some informations to format.
But I hope no dialog pop and user doesn't need to keyin/
select anything.
(2) I try to use ShellExecute to run DOS command to format
( ShellExecute(NULL,"open","format.exe","f: /V:Data /
fs:NTFS /q", NULL, SW_SHOWNORMAL ); )
But it would show the information that need user confirm or
keyin volume label.

Could you have any idea to format without user confirm or
keyin something?
Could bat file to do this function?

Thanks for your kindly help.
From: bluestar on
On 7$B7n(B3$BF|(B, $B>e8a(B4$B;~(B04$BJ,(B, Christian ASTOR <casto...(a)club-internet.fr> wrote:
> bluestar wrote:
> > But I don't how to format after i partitioned new disk.
> > I don't know the Logical Drives of new disk, so I can't use
> > other apis to format.
>
> The matching Logical-Physical can be done with
> GetLogicalDriveStrings() and
> IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
> on each drive letter (=>DiskNumber)
> (or
> IOCTL_STORAGE_GET_DEVICE_NUMBER)

Dear Sir:

I can use GetLogicalDrive() to get new Logical Drive.
I also try to use below command to format HDD after
partitioning Disk.
But I am very confused that how to know format already
completed.
Because I need to wait format completely and then read/write
to HDD.
My Project flow is Partition Disk -> Format Logical Drive ->
Write/Read HDD

Could you teach me how to do?

//------------------------------------------------------------------------------------------------------------------//
TCHAR parameters[MAX_PATH];
wsprintf(parameters, "%c: /V:Data /FS:NTFS /Q /Y", cDrive);
nReturn = (INT)ShellExecute(NULL, "open","format",parameters,
NULL, SW_SHOWNORMAL);

if( nReturn>32 )
{
bResult = TRUE;
}
else
bResult = FALSE;
From: Christian ASTOR on
bluestar wrote:

> By the way, If I want to check how many Logical Drives in One
> Disk,
> do you have any APIs or sample code to help me?

As I said, e.g. with IOCTL_STORAGE_GET_DEVICE_NUMBER on each logical volume.

On my PC, I get :

C: => DiskNumber = 0, Partition 1
D: => DiskNumber = 0, Partition 2
E: => DiskNumber = 1

then =>
PhysicalDrive0 : C and D
PhysicalDrive1 : E
From: bluestar on
I got it.
Thanks for your information.

On 7$B7n(B5$BF|(B, $B>e8a(B4$B;~(B48$BJ,(B, Christian ASTOR <casto...(a)club-internet.fr> wrote:
> bluestar wrote:
> > By the way, If I want to check how many Logical Drives in One
> > Disk,
> > do you have any APIs or sample code to help me?
>
> As I said, e.g. with IOCTL_STORAGE_GET_DEVICE_NUMBER on each logical volume.
>
> On my PC, I get :
>
> C: => DiskNumber = 0, Partition 1
> D: => DiskNumber = 0, Partition 2
> E: => DiskNumber = 1
>
> then =>
> PhysicalDrive0 : C and D
> PhysicalDrive1 : E