In Visual Studio 2005 C++, functions that previously took a variable declared as const no longer do so. For example, the following compiles using Visual Studio 2003:
const __wchar_t __pin *strPrinterName = ::PtrToStringChars(printerName);
BOOL result = ::OpenPrinter(strPrinterName, mJobHandle, NULL);
But, with Visual Studio 2005 results in:
error C2664: 'OpenPrinterW' : cannot convert parameter 1 from 'const wchar_t __pin *' to 'LPWSTR'
Conversion loses qualifiers
To get around this, you need to explicitly cast away the const-ness:
const __wchar_t __pin *strPrinterName = ::PtrToStringChars(printerName);
BOOL result = ::OpenPrinter((LPWSTR) strPrinterName, mJobHandle, NULL);
Removing const from the first line won't help because PtrToStringChars is declared as returning a const.