0

I am a C++ rookie, so this might be obvious.

I am trying to write a program that prints disk information. While browsing the fileapi.h header file on microsoft.com, I found an interesting function GetDiskSpaceInformationA(), which I would like to use.

I created a new C++ console project in Visual Studios 2013, and included <windows.h> and <fileapi.h>, see whole program below. Now, I noticed that a lot of functions in fileapi.h seem to not be included. At least, compared to the functions that are on the website. One of these missing functions is, of course, GetDiskSpaceInformationA().

What is the reason for this? Is it because my target architecture is Windows? Is there anyway for me to get access to the functions I want in fileapi.h?

#include "stdafx.h"

#include <windows.h>
#include <fileapi.h>

int _tmain(int argc, _TCHAR* argv[])
{
    GetDiskSpaceInformationA();  //Error identifier "GetDiskSpaceInformationA" is undefined
    return 0;
}
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
MarkusAnd
  • 750
  • 7
  • 21
  • You probably want [GetDiskSpaceInformationW](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getdiskspaceinformationw). See [this question](https://stackoverflow.com/questions/7424383/what-is-the-difference-between-the-a-and-w-functions-in-the-win32-api) as to why. – Rex Mar 10 '23 at 12:34
  • @Rex I see, thanks! However, that method can't be found either. – MarkusAnd Mar 10 '23 at 13:09
  • 1
    Perhaps it's been added during the decade that's passed since your Visual Studio was modern. – molbdnilo Mar 10 '23 at 14:04
  • 1
    if the function exists in fileapi.h then it is probably preprocessorly conditioned. Many WinApi functions depend on which windows version you target. – engf-010 Mar 10 '23 at 14:28
  • 2
    BTW ,Since you're a Rookie ,you'd be better off by installing a more modern version of Visual Studio. – engf-010 Mar 10 '23 at 14:37

0 Answers0