Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

windows

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?

like image 914
wamp Avatar asked Dec 28 '22 08:12

wamp


1 Answers

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.

like image 91
James McNellis Avatar answered Jan 14 '23 23:01

James McNellis