那时他自己的写函数再说C语言区分大小写的 /* * UnicodeToAnsi converts the Unicode string pszW to an ANSI string * and returns the ANSI string through ppszA. Space for the * the converted string is allocated by UnicodeToAnsi. */ HRESULT __fastcall UnicodeToAnsi(LPCOLESTR pszW, LPSTR* ppszA) { ULONG cbAnsi, cCharacters; DWORD dwError; // If input is null then just return the same. if (pszW == NULL) { *ppszA = NULL; return NOERROR; } cCharacters = wcslen(pszW)+1; // Determine number of bytes to be allocated for ANSI string. An // ANSI string can have at most 2 bytes per character (for Double // Byte Character Strings.) cbAnsi = cCharacters*2; // Use of the OLE allocator is not required because the resultant // ANSI string will never be passed to another COM component. You // can use your own allocator. *ppszA = (LPSTR) CoTaskMemAlloc(cbAnsi); if (NULL == *ppszA) return E_OUTOFMEMORY; // Convert to ANSI. if (0 == WideCharToMultiByte(CP_ACP, 0, pszW, cCharacters, *ppszA, cbAnsi, NULL, NULL)) { dwError = GetLastError(); CoTaskMemFree(*ppszA); *ppszA = NULL; return HRESULT_FROM_WIN32(dwError); } return NOERROR;}
The point is: "C语言区分大小写的", just as bluebohe says...
/*
* UnicodeToAnsi converts the Unicode string pszW to an ANSI string
* and returns the ANSI string through ppszA. Space for the
* the converted string is allocated by UnicodeToAnsi.
*/ HRESULT __fastcall UnicodeToAnsi(LPCOLESTR pszW, LPSTR* ppszA)
{ ULONG cbAnsi, cCharacters;
DWORD dwError; // If input is null then just return the same.
if (pszW == NULL)
{
*ppszA = NULL;
return NOERROR;
} cCharacters = wcslen(pszW)+1;
// Determine number of bytes to be allocated for ANSI string. An
// ANSI string can have at most 2 bytes per character (for Double
// Byte Character Strings.)
cbAnsi = cCharacters*2; // Use of the OLE allocator is not required because the resultant
// ANSI string will never be passed to another COM component. You
// can use your own allocator.
*ppszA = (LPSTR) CoTaskMemAlloc(cbAnsi);
if (NULL == *ppszA)
return E_OUTOFMEMORY; // Convert to ANSI.
if (0 == WideCharToMultiByte(CP_ACP, 0, pszW, cCharacters, *ppszA,
cbAnsi, NULL, NULL))
{
dwError = GetLastError();
CoTaskMemFree(*ppszA);
*ppszA = NULL;
return HRESULT_FROM_WIN32(dwError);
}
return NOERROR;}
"C语言区分大小写的",
just as bluebohe says...