Article View: borland.public.cppbuilder.nativeapi
Article #4646Re: Problem with DeviceIoControl() IOCTL_STORAGE_QUERY_PROPERTY
From: Richard Bradbrook
Date: Thu, 15 Dec 2005 21:23
Date: Thu, 15 Dec 2005 21:23
28 lines
2225 bytes
2225 bytes
I use the following code (and it works ok!) STORAGE_PROPERTY_QUERY StoragePropertyQuery; STORAGE_ADAPTER_DESCRIPTOR StorageAdapterDescriptor; BOOL Success; DWORD NumberOfBytesReturned; ZeroMemory(&StoragePropertyQuery, sizeof(STORAGE_PROPERTY_QUERY)); ZeroMemory(&StorageAdapterDescriptor, sizeof(STORAGE_ADAPTER_DESCRIPTOR)); StoragePropertyQuery.PropertyId = StorageAdapterProperty; StoragePropertyQuery.QueryType = PropertyStandardQuery; Success = DeviceIoControl(TempHandle, IOCTL_STORAGE_QUERY_PROPERTY, &StoragePropertyQuery, sizeof(STORAGE_PROPERTY_QUERY), &StorageAdapterDescriptor, sizeof(STORAGE_ADAPTER_DESCRIPTOR), &NumberOfBytesReturned, NULL); Generally speaking, if 'Success' turns out to be False, you should drop back down to the legacy IOCTL_SCSI_GET_CAPABILITIES command. It won't get you your bustype, but it'll give you the figure to use for your maximum transfer window. I also advise you to VirtualAlloc a buffer somewhere for all your I/O transfers. When buffers are not correctly alligned, DeviceIoControl often fails with the error you're getting - that's where the 'AlignmentMask' value comes in.
Technical Details
Message-ID:
<43a1de8b$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!meganewsservers.com!feeder2.on.meganewsservers.com!news-out.superfeed.net!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<8b04q11n406hs1bonf8n9586mn3of3lqm3@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f7af8c8a3ab6155a X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Richard Bradbrook" <dont@spamme.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <8b04q11n406hs1bonf8n9586mn3of3lqm3@4ax.com> Subject: Re: Problem with DeviceIoControl() IOCTL_STORAGE_QUERY_PROPERTY Date: Thu, 15 Dec 2005 21:23:42 -0000 Lines: 30 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.3790.1830 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 82.71.43.223 Message-ID: <43a1de8b$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1134681739 82.71.43.223 (15 Dec 2005 13:22:19 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!meganewsservers.com!feeder2.on.meganewsservers.com!news-out.superfeed.net!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail