From: cartoper on
I am working on a program that reads data from a removable device (USB
Stick) that the user will insert into the computer and then when the
data is removed, will need to remove the media. In the system tray,
there is the icon/tool to "Safely Remove Hardware". How do I do that
programmatically? I am working in C#, so if I can avoid dropping to
the API level, that would be great, but with 10+ years of C/C++
experence, WinAPI level examples work, too!

From: Don Burn on
You need the Setup api's from the DDK/WDK. Get the WDK and look at the
DevCon sample for information on how to do it.

--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply




<cartoper(a)gmail.com> wrote in message
news:1169921417.697818.10430(a)m58g2000cwm.googlegroups.com...
>I am working on a program that reads data from a removable device (USB
> Stick) that the user will insert into the computer and then when the
> data is removed, will need to remove the media. In the system tray,
> there is the icon/tool to "Safely Remove Hardware". How do I do that
> programmatically? I am working in C#, so if I can avoid dropping to
> the API level, that would be great, but with 10+ years of C/C++
> experence, WinAPI level examples work, too!
>


From: cartoper on
On Jan 27, 1:18 pm, "Don Burn" <b...(a)stopspam.windrvr.com> wrote:
> You need the Setup api's from the DDK/WDK. Get the WDK and look at the
> DevCon sample for information on how to do it.

Don,

It looks like the WDK is not a free download, am I correct? If not,
any thoughts on where to go find it? This is the link I found:

http://www.microsoft.com/whdc/devtools/wdk/betawdk.mspx

From: Don Burn on
Actually it is free, you just have to follow the directions. I know the
page says Beta, but it now gives you the release version. Alternatively,
if you can find the last DDK Build 3790.1830 that should work fine also.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply


<cartoper(a)gmail.com> wrote in message
news:1169923086.484520.69540(a)m58g2000cwm.googlegroups.com...
> On Jan 27, 1:18 pm, "Don Burn" <b...(a)stopspam.windrvr.com> wrote:
>> You need the Setup api's from the DDK/WDK. Get the WDK and look at the
>> DevCon sample for information on how to do it.
>
> Don,
>
> It looks like the WDK is not a free download, am I correct? If not,
> any thoughts on where to go find it? This is the link I found:
>
> http://www.microsoft.com/whdc/devtools/wdk/betawdk.mspx
>


From: Uwe Sieber on
cartoper(a)gmail.com wrote:
> I am working on a program that reads data from a removable device (USB
> Stick) that the user will insert into the computer and then when the
> data is removed, will need to remove the media. In the system tray,
> there is the icon/tool to "Safely Remove Hardware". How do I do that
> programmatically? I am working in C#, so if I can avoid dropping to
> the API level, that would be great, but with 10+ years of C/C++
> experence, WinAPI level examples work, too!

I've shown this in user mode in a sample project:
http://www.codeproject.com/system/RemoveDriveByLetter.asp

The page needs an update because of some new findings.

CM_Query_And_Remove_SubTree requires admin previleges, while
CM_Request_Device_Eject does not. Today I've seen that Vista
redetected an USB hard disk immediately after using
CM_Query_And_Remove_SubTree successfully. It did not happen
with CM_Request_Device_Eject.

If you want XP show the "it's save now" balloon, then use
NULL/0 for the veto params. An additional effect is, that
XP doesn't play the removal sound then when the device is
unplugged. Quite strange...


Greetings from Germany

Uwe