Neel Basu
Neel Basu

Reputation: 12904

error: 'IOCTL_STORAGE_QUERY_PROPERTY' was not declared in this scop

I've included winioctl.h and there is no #define for IOCTL_STORAGE_QUERY_PROPERTY in that file !! http://www.osronline.com/ddkx/storage/k307_8z3m.htm Says Its in ntddstor.h But I cannot find any ntddstor.h on my Windows XP. HoweverIOCTL_STORAGE_QUERY_PROPERTY mentions its supposed to work with Windows XP (I dont need > Vista Specifc Queries) and It mentions to include winioctl.h only ! (I am not using Visual C++, I an using Qt with MinGW)

Upvotes: 1

Views: 3132

Answers (2)

rodrigo
rodrigo

Reputation: 98496

I have used MinGW to compile these kind of programs. It may not be so easy to find, because frankly, the MinGW site is quite a mess, but they provide a lot of DDK header with no pain. Then I simply copy/paste the structs and defines I need and that I cannot find in the SDK headers. The macros, I define them conditionally, to avoid conflicts, just in case.

For example, your IOCTL_STORAGE_QUERY_PROPERTY is in mingw/include/ddk/ntddstor.h

#define IOCTL_STORAGE_QUERY_PROPERTY \
  CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS)

So I add in my projects:

#ifndef IOCTL_STORAGE_QUERY_PROPERTY
    #define IOCTL_STORAGE_QUERY_PROPERTY \
      CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS)
#endif

That's particularly useful if you intend to publish your code, as most people don't have the DDK headers, and they insist on using VisualStudio instead of MinGW.

Upvotes: 0

Alex F
Alex F

Reputation: 43331

I see IOCTL_STORAGE_QUERY_PROPERTY definition in WinIoCtl.h, and it compiles without any #ifdef conditions. What is your version of this file, how is it installed? I use WinIoCtl.h from VC++ 2010. Maybe you need to install Windows SDK.

Possibly your WinIoCtl.h comes from old Visual Studio or SDK. Install newest Visual Studio version, if this is impossible - install latest Microsoft Windows SDK and ensure that its include directory is listed first in your compiler.

Upvotes: 1

Related Questions