wamp
wamp

Reputation: 5969

How to get the full path to system32 directory with c++?

Although most of the time it's C:\WINDOWS\system32, but sometimes it can be in D partition or alike, how to get it programatically?

Upvotes: 4

Views: 11490

Answers (3)

Furkat U.
Furkat U.

Reputation: 451

UINT WINAPI GetSystemDirectory(
  _Out_  LPTSTR lpBuffer,
  _In_   UINT uSize
);

You can use this as stated here

Upvotes: 5

Chubsdad
Chubsdad

Reputation: 25537

GetWindowsDirectory also is a possibility depending on the OS/purpose. Clearly SHGetFolderPath seems to be the MS recommended way

Upvotes: 0

James McNellis
James McNellis

Reputation: 355207

You can call the Windows API function SHGetFolderPath and ask for CSIDL_SYSTEM.

In Windows Vista and later, you can call SHGetKnownFolderPath and ask for FOLDERID_System. SHGetFolderPath is just a wrapper around this function in later versions of Windows, but if you want your software to run on Windows XP, you'll need to use SHGetFolderPath.

Upvotes: 7

Related Questions