Handling Multiple Win32 Operating Environments
By Matthew Wilson, December 01, 2003
Ensuring backwards compatibility in Windows has resulted in many variations in Win32-based operating systems, each providing a varying set of functions. Matthew takes a look at several techniques for redefining system functions to help your app target multiple environments in Win32.
Handling Multiple Win32 Operating Environments
Listing 1 Local definition of SetCurrentDirectoryW()
BOOL WINAPI SetCurrentDirectoryW(LPCWSTR lpPathName)
{
size_t len = lstrlenW(lpPathName);
char *pathName = (char*)_alloca(1 + len);
WideCharToMultiByte(CP_ACP, 0, lpPathName, 1 + len, pathName, 1 + len, NULL, NULL);
return SetCurrentDirectoryA(pathName);
}