How to eject the removable device under the native mode

Hi! Now I have encountered a big problem.
Our application is a native NT app(such as AUTOCHK). And it is not a Win32
application. I want to eject automatically the removable device(such as MO
drive) when the app run under the native mode.

The code is as follows:
InitializeObjectAttributes(
&ObjectAttributes,
&filename, //“\Device\Harddisk1\DP(1)0-0+2”(MO device name)
OBJ_CASE_INSENSITIVE,
NULL,
NULL
);
ntstatus=NtCreateFile(
&hf,
GENERIC_WRITE|SYNCHRONIZE|GENERIC_READ,
&ObjectAttributes,
&IoStatusBlock,
0,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_DELETE,
FILE_OPEN,
FILE_SYNCHRONOUS_IO_NONALERT|FILE_WRITE_THROUGH,
NULL,
0
);

ZwFsControlFile(
hVolume,
NULL,NULL, NULL,
&IoStatusBlock,
IOCTL_STORAGE_EJECT_MEDIA,
NULL, 0,NULL, 0);

But it seem that the removable device can not respond the code
IOCTL_STORAGE_EJECT_MEDIA. Who can help me solve the problem? Or tell me
the helpful way?

Thanks in advance.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

On Wed, 20 Feb 2002 1:6:6, “shirley” wrote:

>Hi! Now I have encountered a big problem.
>Our application is a native NT app(such as AUTOCHK). And it is not a Win32
>application. I want to eject automatically the removable device(such as MO
>drive) when the app run under the native mode.

First, you need to call NtDeviceIoControlFile() rather than
NtFsControlFile() to issue IOCTL_* control codes (parameter list is the
same as for NtFsControlFile). Next, read
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q165721 , it
should be obvious how to transform this into native code.

Ralf.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> But it seem that the removable device can not respond the code

IOCTL_STORAGE_EJECT_MEDIA. Who can help me solve the problem? Or tell me

Try ZwDeviceIoControlFile instead.

Max


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com