Antu Philip
Antu Philip

Reputation: 33

Not able to get the correct path using getsystemdirectory() in 64 bit machine

I have an application running under 64bit OS (Windows 7). I was expecting GetSystemDirectory to return "C:\Windows\SysWOW64". Instead, it returns "C:\Windows\system32".

How do I get it to return "C:\Windows\SysWOW64"?

Upvotes: 2

Views: 4145

Answers (2)

Remy Lebeau
Remy Lebeau

Reputation: 595557

I was expecting GetSystemDirectory to return "C:\Windows\SysWOW64". Instead, it returns "C:\Windows\system32".

As it should be, because system32 is the official system folder, even for a 32bit app running on 64bit Windows. In that latter case, any files a 32bit app tries to access in system32 are silently redirected to SysWOW64 by the WOW64 emulator. You don't need to do anything special in your code to get that behavior. So keep using system32 whether your app is 32bit or 64bit.

If you want to get the path of the SysWOW64 folder specifically, use GetSystemWow64Directory() instead.

Upvotes: 5

Pazhaniyappan
Pazhaniyappan

Reputation: 122

#include <Windows.h>

int main(int argv, char* args[])
{
    TCHAR sysDir[MAX_PATH];
    GetSystemWow64Directory(sysDir, MAX_PATH);

    std::cout << sysDir << std::endl;

    return 0;
 }

OUTPUT:

C:\Windows\SysWOW64

Upvotes: -1

Related Questions