How to get windows system directory in C

1 Answer

0 votes
#include <windows.h>
#include <stdio.h>

int main() {
    WCHAR path[MAX_PATH];
    
    GetSystemDirectory(path, MAX_PATH);
    
    printf("System directory: %ws\n", path);

    char ch = getchar();

    return 0;
}




/*
run:

System directory: C:\WINDOWS\system32

*/

 



answered Apr 4, 2022 by avibootz

Related questions

...