Click here to Skip to main content
16,005,682 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhow can i convert ms-word to bmp by program??? Pin
hua_hero0718-Jun-07 15:37
hua_hero0718-Jun-07 15:37 
AnswerRe: how can i convert ms-word to bmp by program??? Pin
Christian Graus18-Jun-07 15:53
protectorChristian Graus18-Jun-07 15:53 
QuestionsendASPI32Command returns SS_ASPI_IS_BUSY Pin
aks.18-Jun-07 14:01
aks.18-Jun-07 14:01 
QuestionDetecting Windows Session Change Pin
Akin Ocal18-Jun-07 13:43
Akin Ocal18-Jun-07 13:43 
QuestionRe: Detecting Windows Session Change Pin
David Crow18-Jun-07 16:23
David Crow18-Jun-07 16:23 
QuestionHow can i verify that if a disc is USB disc or not Pin
Akin Ocal18-Jun-07 13:38
Akin Ocal18-Jun-07 13:38 
AnswerRe: How can i verify that if a disc is USB disc or not Pin
Iain Clarke, Warrior Programmer19-Jun-07 0:49
Iain Clarke, Warrior Programmer19-Jun-07 0:49 
AnswerRe: How can i verify that if a disc is USB disc or not Pin
Matthew Faithfull19-Jun-07 5:07
Matthew Faithfull19-Jun-07 5:07 
It's not simple but it can be done. I can't give you the code because it's owned by my employers but these basic steps should help you along.

Start by getting the drive type from your drive letter as previously suggested. For USB drives this will always be DRIVE_REMOVABLE or DRIVE_FIXED, anything else and it can be discarded at this stage.

Then you need to open a handle to the Volume with CreateFile and a file name like \\.\E:
(remember to double the slashes when you put this in a C++ string)

You can use the returned device handle to get a VOLUME_DISK_EXTENTS structure for the volume using DeviceIOControl with a IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS control code.

In the Disk Extents structure there is a DiskNumber you can now associate this with the drive letter you started with and remember it.

Now the hard part, is it USB?

The next step is to enumerate all the USB devices attached to the system using SetupDiGetClassDevs with &GUID_DEVCLASS_USB and SetupDiGetClassDevs with &DiskClassGuid to get all the disk devices. For each device use the returned handle to get Device information with SetupDiEnumDeviceInterfaces and SetupDiGetDeviceInterfaceDetail. You end up with a SP_DEVICE_INTERFACE_DETAIL_DATA structure which contains a device path. Open this path with CreateFile which gives you a device handle.
Use the device handle with DeviceIoControl and IOCTL_STORAGE_QUERY_PROPERTY and cast the result to a PSTORAGE_ADAPTER_DESCRIPTOR. This contains a BusType which will be 0x7 for USB
You can use the same device handle you called CreateFile with to do a DeviceIoControl with IOCTL_STORAGE_GET_MEDIA_TYPES_EX. Cast the returned buffer to a PGET_MEDIA_TYPES to get a structure with DeviceType. If DeviceType == FILE_DEVICE_DISK then you have a USB disk but you still don't know which drive letter it corresponds to. To determine this you need to pass the same device handle to DeviceIoControl with IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS and compare the DiskNumber in the result with the pair of DiskNumber and Drive letters that you worked out in the first step.

If this sounds like a joke it is not. I don't know any easier way to do this (took 2 weeks to develop) although I'd like to. You will need some headers from the Windows 2000 or later DDK as well for some of the GUIDS and constants. This will not work before Windows 2000. Good luck Wink | ;)

Nothing is exactly what it seems but everything with seems can be unpicked.

GeneralRe: How can i verify that if a disc is USB disc or not Pin
Akin Ocal19-Jun-07 5:47
Akin Ocal19-Jun-07 5:47 
GeneralRe: How can i verify that if a disc is USB disc or not Pin
Iain Clarke, Warrior Programmer19-Jun-07 6:05
Iain Clarke, Warrior Programmer19-Jun-07 6:05 
GeneralRe: How can i verify that if a disc is USB disc or not Pin
Matthew Faithfull19-Jun-07 6:17
Matthew Faithfull19-Jun-07 6:17 
GeneralRe: How can i verify that if a disc is USB disc or not Pin
Iain Clarke, Warrior Programmer19-Jun-07 22:50
Iain Clarke, Warrior Programmer19-Jun-07 22:50 
GeneralRe: How can i verify that if a disc is USB disc or not Pin
Matthew Faithfull20-Jun-07 0:59
Matthew Faithfull20-Jun-07 0:59 
QuestionMultiple Windows inside single Splitter Window Pin
StevenS_Dev18-Jun-07 13:30
StevenS_Dev18-Jun-07 13:30 
AnswerRe: Multiple Windows inside single Splitter Window Pin
StevenS_Dev18-Jun-07 15:29
StevenS_Dev18-Jun-07 15:29 
GeneralRe: Multiple Windows inside single Splitter Window Pin
Iain Clarke, Warrior Programmer19-Jun-07 0:52
Iain Clarke, Warrior Programmer19-Jun-07 0:52 
GeneralRe: Multiple Windows inside single Splitter Window Pin
StevenS_Dev19-Jun-07 5:51
StevenS_Dev19-Jun-07 5:51 
AnswerRe: Multiple Windows inside single Splitter Window Pin
MarkDoubson18-Jun-07 16:16
MarkDoubson18-Jun-07 16:16 
QuestionCString and binary file Pin
pnpfriend18-Jun-07 12:25
pnpfriend18-Jun-07 12:25 
AnswerRe: CString and binary file Pin
Mark Salsbery18-Jun-07 13:29
Mark Salsbery18-Jun-07 13:29 
GeneralRe: CString and binary file Pin
pnpfriend19-Jun-07 4:22
pnpfriend19-Jun-07 4:22 
GeneralRe: CString and binary file Pin
pnpfriend19-Jun-07 5:02
pnpfriend19-Jun-07 5:02 
GeneralRe: CString and binary file Pin
Mark Salsbery19-Jun-07 6:07
Mark Salsbery19-Jun-07 6:07 
AnswerRe: CString and binary file Pin
Bram van Kampen18-Jun-07 14:19
Bram van Kampen18-Jun-07 14:19 
QuestionRe: CString and binary file Pin
David Crow18-Jun-07 16:27
David Crow18-Jun-07 16:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.