LRESULT TransConvertList( HIMC hImc, LPIMESTRUCT lpIme) { LPSTR lpSrc; LPSTR lpDst; HGLOBAL hCandList; LPCANDIDATELIST lpCandList; LPSTR lpCandStr; UINT i, uBufLen; LRESULT lRet = 0; lpSrc = lpSource(lpIme); lpDst = lpDest(lpIme); uBufLen = ImmGetConversionListA(GetKeyboardLayout(0), hImc, (LPCSTR)lpSrc, NULL, 0, GCL_CONVERSION); if (uBufLen) { hCandList = GlobalAlloc(GHND, uBufLen); lpCandList = (LPCANDIDATELIST)GlobalLock(hCandList); lRet = ImmGetConversionListA(GetKeyboardLayout(0), hImc, (LPCSTR)lpSrc, lpCandList, uBufLen, GCL_CONVERSION); for (i = 0; i < lpCandList->dwCount; i++) { lpCandStr = (LPSTR)lpCandList + lpCandList->dwOffset[i]; *lpDst++ = *lpCandStr++; *lpDst++ = *lpCandStr++; } *lpDst = '\0'; lpIme->wCount = (WORD)lpCandList->dwCount * 2; GlobalUnlock(hCandList); GlobalFree(hCandList); } return (lRet); }
LRESULT TransCodeConvert( HIMC hIMC, LPIMESTRUCT lpIme ) /*++ Routine Description: Arguments: Return Value: --*/ { UNREFERENCED_PARAMETER(hIMC); switch (lpIme->wParam) { case IME_JUNJAtoBANJA: lpIme->wCount = JunjaToBanja(lpSource(lpIme), lpDest(lpIme)); break; case IME_BANJAtoJUNJA: lpIme->wCount = BanjaToJunja(lpSource(lpIme), lpDest(lpIme)); break; case IME_JOHABtoKS: lpIme->wCount = JohabToKs(lpSource(lpIme), lpDest(lpIme)); break; case IME_KStoJOHAB: lpIme->wCount = KsToJohab(lpSource(lpIme), lpDest(lpIme)); break; default: lpIme->wCount = 0; } return (lpIme->wCount); }
LPCTSTR APIException::ToString() { if (0 != m_szMessage) { return m_szMessage; } LPVOID lpSource(NULL); DWORD dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS; if (IsSystemError()) { dwFlags |= FORMAT_MESSAGE_FROM_SYSTEM; } else { dwFlags |= FORMAT_MESSAGE_FROM_HMODULE; HMODULE hModule = ::LoadLibraryEx( _T("ndasmsg.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE); lpSource = hModule; if (NULL == hModule) { return _T(""); } } BOOL fSuccess = ::FormatMessage( dwFlags, lpSource, m_dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &m_szMessage, 0, NULL); if (!fSuccess) { return _T(""); } if (NULL != lpSource) { ::FreeLibrary((HMODULE)lpSource); } return m_szMessage; }