Help handling a device

Hi, my aim is to get a handle on my USB device, and dismount the USB drive (I would also like it to remount straight after but i will crawl before i can walk). I have worked out that FSCTL_DISMOUNT_VOLUME could be what i need and ive had a go at putting something together but it doesnt work. Can anyone help me with my small program?


HANDLE hDevice;
DWORD dwIoControlCode;
LPVOID lpInBuffer;
DWORD nInBufferSize;
DWORD nOutBufferSize;
LPDWORD lpBytesReturned;
LPOVERLAPPED lpOverlapped;
FSCTL_DISMOUNT_VOLUME disMount;

hDevice = CreateFile (TEXT("\\\\.\\e:"), // drive (THIS IS THE LETTER OF MY USB DRIVE)
0, // no access to the drive
FILE_SHARE_READ, // share mode

NULL, // default security attributes
OPEN_EXISTING, // disposition
0, // file attributes
NULL); // do not copy file attributes

DeviceIoControl(hDevice, // device to be queried
disMount, // operation to perform
NULL, 0, // no input buffer
// pdg, sizeof(*pdg), // output buffer DONT KNOW WHAT THIS IS FOR
// &junk, // # bytes returned DONT KNOW WHAT THIS IS FOR
(LPOVERLAPPED) NULL); // synchronous I/O

CloseHandle(hDevice);
[1628 byte] By [tootypegs] at [2007-11-20 11:39:33]