Skip to content

Instantly share code, notes, and snippets.

@Sohamkadam333
Created December 12, 2023 18:27
Show Gist options
  • Save Sohamkadam333/fdd3ca64ab697aeb7a6377ec35aba951 to your computer and use it in GitHub Desktop.
Save Sohamkadam333/fdd3ca64ab697aeb7a6377ec35aba951 to your computer and use it in GitHub Desktop.
Retrieves the path of the system directory. The system directory contains system files such as dynamic-link libraries and drivers.
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
TCHAR systemDirectory[MAX_PATH];
DWORD result = GetSystemDirectory(systemDirectory,MAX_PATH);
if(result !=0)
{
_tprintf(_T("System Directory %s\n"),systemDirectory);
}
else
{
cout<<"Error getting systemDirectory, Error no: "<<GetLastError()<<endl;
}
system("PAUSE");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment