Originally Posted by
nvoigt
You need to use double backslashes, as always:
LoadLibrary("C:\\Program Files\\Common Files\\example.dll");
Please note that your code will only run on machines that are installed in English. "Program Files" is localized in XP
Indeed, and so is "Common Files". And it also depends on if you're on a 32 or 64-bit OS.
If you want version-independant code, use the %CommonProgramFiles% environment variable together with ExpandEnvironmentStrings Function (Windows)
Example:
Code:
TCHAR *path = L"%CommonProgramFiles%\\microsoft shared\\Windows Live\\WindowsLiveLogin.dll";
TCHAR *expandedPath = NULL;
// Set length to 0 the first pass to find out required buffer length
DWORD numChars = ExpandEnvironmentStrings(path, expandedPath , 0);
expandedPath = new TCHAR[numChars];
ExpandEnvironmentStrings(path, expandedPath, numChars);
HMODULE hm = LoadLibrary(expandedPath);
delete [] expandedPath;
(proof of concept code, add your own error handling)