473,785 Members | 2,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Visual C++ 6.0 Undeclared Identifier Error

3 New Member
First of all I would like to indicate that I am a newbie a programming. I am having a problem compiling a sample source code that I downloaded from microsoft. When I try to build the program I get an error that 'STORAGE_PROPER TY_QUERY' undeclared identifier. This structure is defined in the ntddstor.h file and is included. I dont understand why it does not see this structure.

OS: Windows XP, Visual C++ 6.0, latest SDK and changed the include and library directory order to have the SDK files first in the search order. Any ideas would be appreciated.

ErrorCode: c:\program files\microsoft visual studio\myprojec ts\programs that work\firstioctl \main.cpp|54|er ror C2065: 'STORAGE_PROPER TY_QUERY' : undeclared identifier|

Expand|Select|Wrap|Line Numbers
  1. /* The code of interest is in the subroutine GetDriveGeometry. The
  2. code in main shows how to interpret the results of the call. */
  3.  
  4. #include <stdio.h>
  5. #include <windows.h>
  6. #include <winioctl.h>
  7. #include <ntddstor.h>
  8.  
  9. BOOL GetDriveGeometry(DISK_GEOMETRY *pdg)
  10. {
  11.   HANDLE hDevice;               // handle to the drive to be examined
  12.   BOOL bResult;                 // results flag
  13.   DWORD junk;                   // discard results
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.   hDevice = CreateFile(TEXT("\\\\.\\PhysicalDrive1"),  // drive
  21.                     0,                // no access to the drive
  22.                     FILE_SHARE_READ | // share mode
  23.                     FILE_SHARE_WRITE,
  24.                     NULL,             // default security attributes
  25.                     OPEN_EXISTING,    // disposition
  26.                     0,                // file attributes
  27.                     NULL);            // do not copy file attributes
  28.  
  29.   if (hDevice == INVALID_HANDLE_VALUE) // cannot open the drive
  30.   {
  31.     return (FALSE);
  32.   }
  33.  
  34.   bResult = DeviceIoControl(hDevice,  // device to be queried
  35.       IOCTL_DISK_GET_DRIVE_GEOMETRY,  // operation to perform
  36.                              NULL, 0, // no input buffer
  37.                             pdg, sizeof(*pdg),     // output buffer
  38.                             &junk,                 // # bytes returned
  39.                             (LPOVERLAPPED) NULL);  // synchronous I/O
  40.  
  41.   CloseHandle(hDevice);
  42.  
  43.   return (bResult);
  44. }
  45.  
  46. int main(int argc, char *argv[])
  47. {
  48.   DISK_GEOMETRY pdg;            // disk drive geometry structure
  49.   BOOL bResult;                 // generic results flag
  50.   ULONGLONG DiskSize;           // size of the drive, in bytes
  51.  
  52.  
  53. STORAGE_PROPERTY_QUERY              query;
  54. PSTORAGE_ADAPTER_DESCRIPTOR         adpDesc;
  55. PSTORAGE_DEVICE_DESCRIPTOR          devDesc;
  56. SCSI_PASS_THROUGH_WITH_BUFFERS      sptwb;
  57.  
  58.  
  59.  
  60.   bResult = GetDriveGeometry (&pdg);
  61.  
  62.   if (bResult)
  63.   {
  64.     printf("Cylinders = %I64d\n", pdg.Cylinders);
  65.     printf("Tracks/cylinder = %ld\n", (ULONG) pdg.TracksPerCylinder);
  66.     printf("Sectors/track = %ld\n", (ULONG) pdg.SectorsPerTrack);
  67.     printf("Bytes/sector = %ld\n", (ULONG) pdg.BytesPerSector);
  68.  
  69.     DiskSize = pdg.Cylinders.QuadPart * (ULONG)pdg.TracksPerCylinder *
  70.       (ULONG)pdg.SectorsPerTrack * (ULONG)pdg.BytesPerSector;
  71.     printf("Disk size = %I64d (Bytes) = %I64d (Gb)\n", DiskSize,
  72.            DiskSize / (1024 * 1024 * 1024));
  73.   }
  74.   else
  75.   {
  76.     printf ("GetDriveGeometry failed. Error %ld.\n", GetLastError ());
  77.   }
  78.  
  79.   return ((int)bResult);
  80. }
  81.  
Apr 18 '08 #1
5 12537
gpraghuram
1,275 Recognized Expert Top Contributor
The other declarations after STORAGE_PROPERT Y_QUERY that is PSTORAGE_ADAPTE R_DESCRIPTOR is defined in the same header file?
If it is so check whether you have to include any specific definitions for that.
Better put the the header file also here so that i can take a look at it

Thanks
raghuram
Apr 18 '08 #2
vmagana
3 New Member
Yes, those declarations are in the same "ntddstor.h " file. Except for the SCSI_PASS_THROU GH. I am having problems adding the code. I get an error that says I have to fill out the message and subject field. I attached the header file. Let me know if you have problems viewing the file. Thanks for your help.
Apr 18 '08 #3
gpraghuram
1,275 Recognized Expert Top Contributor
Yes, those declarations are in the same "ntddstor.h " file. Except for the SCSI_PASS_THROU GH. I am having problems adding the code. I get an error that says I have to fill out the message and subject field. I attached the header file. Let me know if you have problems viewing the file. Thanks for your help.

Can you please post the code instead of attaching the file.

Raghuram
Apr 21 '08 #4
Banfa
9,065 Recognized Expert Moderator Expert
I have removed the attachment, I'm sorry but you may not post the code of ntddstor.h here as it is Copyright to the Microsoft Corporation, we do not allow the posting of copyright code.

If the file contains the definition (which you can check for yourself) then it is something to do with they way in which it has been included. Please post your code containing your include statements.

Banfa
Administrator
Apr 21 '08 #5
vmagana
3 New Member
Sorry for the copyright code file. The include statements are listed in the code at the beginning of this thread. They are;

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <winioctl.h>
  4. #include <ntddstor.h>
  5.  
Yes, the ntddstor. h has the definition for the STORAGE_PROPERT Y_QUERY structure. I don't know of another way to include this file. Any recommendations would be appreciated.
Apr 21 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
4840
by: Saurabh Aggrawal | last post by:
Hi, if (iter->m_name.compare(pstrName) == 0) { // Provide our object. *ppunkItem = iter->m_pUnknown; // Addref our object... iter->m_pUnknown->AddRef(); break; }
6
6639
by: craigbeanhead | last post by:
Hi, I'm teaching myself C from K&R2. I've come across something that I really don't understand. When I try to compile the following code (in VC++7), I get an "undeclared identifier" error. When I move the second integer declaration to the beginning of the function, it compiles and runs correctly. I'm sure I read that you could declare a variable anywhere in a code block, as long as you don't attempt to use it *before* the declaration....
5
4139
by: Marc Gustafson | last post by:
This function is executed when a application file is double-clicked to open in a VC++ application. Specifically, this function is enabled by RegisterShellFileTypes () in the application's InitInstance. However, under MFC 7.1 for VC++ .NET 2003, CFrameWnd::OnDDEExecute has a bug that repeatedly generates this error message in the debugger Error: failed to execute DDE command ''.
0
1496
by: Stephanie Doherty | last post by:
Hello World, I am trying to use a _spawnl function like this (and I have included the process.h file): _spawnl(_P_WAIT,iporgfile,iporgfile,NULL); It compiles with the following errors: error C2065: '_P_WAIT' : undeclared identifier
1
5616
by: Scott Chang | last post by:
Hi All I tried to use the attached OpenGL code to draw a Star-shaped figure on my Microsoft Visual C++ .NET 2002-Windows XP Pro PC. When I did 'Build' in Debug Mode, I got an error C2065: 'RenderScence': undeclared identifier. Please help and tell me (1) what it is wrong with my coding in this program and how to correct the problem, and (2) whether the functions/commands of the OpenGL v1.1 (existing in Microsoft Visual C++ .NET 2002) and GLUT...
7
5018
by: inkexit | last post by:
I'm getting these two error mesages when I try to compile the below source code: error C2065: 'input_file' : undeclared identifier error C2228: left of '.eof' must have class/struct/union type The code below was snipped from a larger program for anyone-who-might-want-to-help-me's convienience. That's why there are varibales declared in the main that are not used in the program, and why the main has such drastic indentation. However,...
10
11809
by: teddarr | last post by:
I am trying to construct a class with several functions and identifiers. The identifier in question is static double AIR which will hold the value of the annual interest rate in the class. I have been getting an error message that I can't seem to get rid of: error C2065: 'AIR' undeclared identifier I have never worked with static identifiers before and I think I'm leaving something out somewhere but I don't know what. Here's the...
3
3292
by: Anna Smidt | last post by:
Thanks for the help so far. I have some problems left. One of them is an undeclared identifier, but it's unclear to me why the compiler fights with me. It says "iter: undeclared identifier" I thought that the identifier was clear: "int", or is int just the declaration, and the identifier is something else? Thanks a lot.
1
5016
by: Harshini Raj | last post by:
Hi, I am unable to fix this error. Canyou tell me what compiler options i have to use to fix this issue? Issue Error 40:Undeclared identifier 'Name' -- Within an expression, an identifier was encountered that had not previously been declared and was not followed by a left parenthesis. Name is the name of the identifier.
0
9485
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8986
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.