Created
December 12, 2023 18:34
-
-
Save Sohamkadam333/cf171c695802edee96110aedecd3c617 to your computer and use it in GitHub Desktop.
Retrieves the path of the Windows directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GetWindowsDirectory function is a part of the Windows API and is used to retrieve the path of the Windows directory. The Windows directory is where the core operating system files are stored. | |
#include <iostream> | |
#include <windows.h> | |
using namespace std; | |
int main() | |
{ | |
TCHAR windowsDirectory[MAX_PATH]; | |
int result = GetWindowsDirectory(windowsDirectory,MAX_PATH); | |
if(result > 0 && result < MAX_PATH) | |
{ | |
wcout<<"Windows Directory = "<<windowsDirectory<<endl; | |
} | |
else | |
{ | |
wcout<<"Error getting windows directory, Error No : "<<GetLastError()<<endl; | |
} | |
system("PAUSE"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment