Aric Stewart : imm: Implement ImmGetIMEFileNameW and ImmGetIMEFileNameA.

Alexandre Julliard julliard at winehq.org
Wed Mar 26 09:16:12 CDT 2008


Module: wine
Branch: master
Commit: 5035a85533ff374ff801596f3e159087164612ae
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5035a85533ff374ff801596f3e159087164612ae

Author: Aric Stewart <aric at codeweavers.com>
Date:   Tue Mar 25 07:07:11 2008 -0500

imm: Implement ImmGetIMEFileNameW and ImmGetIMEFileNameA.

---

 dlls/imm32/Makefile.in |    2 +-
 dlls/imm32/imm.c       |   81 ++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 72 insertions(+), 11 deletions(-)

diff --git a/dlls/imm32/Makefile.in b/dlls/imm32/Makefile.in
index 4118422..909f29b 100644
--- a/dlls/imm32/Makefile.in
+++ b/dlls/imm32/Makefile.in
@@ -4,7 +4,7 @@ SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = imm32.dll
 IMPORTLIB = imm32
-IMPORTS   = user32 gdi32 kernel32
+IMPORTS   = user32 gdi32 advapi32 kernel32
 
 C_SRCS = \
 	imm.c
diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c
index de217d1..89f7c47 100644
--- a/dlls/imm32/imm.c
+++ b/dlls/imm32/imm.c
@@ -30,6 +30,7 @@
 #include "imm.h"
 #include "ddk/imm.h"
 #include "winnls.h"
+#include "winreg.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(imm);
 
@@ -1178,23 +1179,83 @@ DWORD WINAPI ImmGetGuideLineW(HIMC hIMC, DWORD dwIndex, LPWSTR lpBuf, DWORD dwBu
 /***********************************************************************
  *		ImmGetIMEFileNameA (IMM32.@)
  */
-UINT WINAPI ImmGetIMEFileNameA(
-  HKL hKL, LPSTR lpszFileName, UINT uBufLen)
+UINT WINAPI ImmGetIMEFileNameA( HKL hKL, LPSTR lpszFileName, UINT uBufLen)
 {
-  FIXME("(%p, %p, %d): stub\n", hKL, lpszFileName, uBufLen);
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return 0;
+    LPWSTR bufW = NULL;
+    UINT wBufLen = uBufLen;
+    UINT rc;
+
+    if (uBufLen && lpszFileName)
+        bufW = HeapAlloc(GetProcessHeap(),0,uBufLen * sizeof(WCHAR));
+    else /* We need this to get the number of byte required */
+    {
+        bufW = HeapAlloc(GetProcessHeap(),0,MAX_PATH * sizeof(WCHAR));
+        wBufLen = MAX_PATH;
+    }
+
+    rc = ImmGetIMEFileNameW(hKL,bufW,wBufLen);
+
+    if (rc > 0)
+    {
+        if (uBufLen && lpszFileName)
+            rc = WideCharToMultiByte(CP_ACP, 0, bufW, -1, lpszFileName,
+                                 uBufLen, NULL, NULL);
+        else /* get the length */
+            rc = WideCharToMultiByte(CP_ACP, 0, bufW, -1, NULL, 0, NULL,
+                                     NULL);
+    }
+
+    HeapFree(GetProcessHeap(),0,bufW);
+    return rc;
 }
 
 /***********************************************************************
  *		ImmGetIMEFileNameW (IMM32.@)
  */
-UINT WINAPI ImmGetIMEFileNameW(
-  HKL hKL, LPWSTR lpszFileName, UINT uBufLen)
+UINT WINAPI ImmGetIMEFileNameW(HKL hKL, LPWSTR lpszFileName, UINT uBufLen)
 {
-  FIXME("(%p, %p, %d): stub\n", hKL, lpszFileName, uBufLen);
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return 0;
+    static const WCHAR szImeFileW[] = {'I','m','e',' ','F','i','l','e',0};
+    static const WCHAR fmt[] = {'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s','\\','%','0','8','x',0};
+
+    HKEY hkey;
+    DWORD length;
+    DWORD rc;
+    WCHAR regKey[sizeof(fmt)/sizeof(WCHAR)+8];
+
+    wsprintfW( regKey, fmt, (unsigned)hKL );
+    rc = RegOpenKeyW( HKEY_LOCAL_MACHINE, regKey, &hkey);
+    if (rc != ERROR_SUCCESS)
+    {
+        SetLastError(rc);
+        return 0;
+    }
+
+    length = 0;
+    rc = RegGetValueW(hkey, NULL, szImeFileW, RRF_RT_REG_SZ, NULL, NULL, &length);
+
+    if (rc != ERROR_SUCCESS)
+    {
+        RegCloseKey(hkey);
+        SetLastError(rc);
+        return 0;
+    }
+    if (length > uBufLen * sizeof(WCHAR) || !lpszFileName)
+    {
+        RegCloseKey(hkey);
+        if (lpszFileName)
+        {
+            SetLastError(ERROR_INSUFFICIENT_BUFFER);
+            return 0;
+        }
+        else
+            return length / sizeof(WCHAR);
+    }
+
+    RegGetValueW(hkey, NULL, szImeFileW, RRF_RT_REG_SZ, NULL, lpszFileName, &length);
+
+    RegCloseKey(hkey);
+
+    return length / sizeof(WCHAR);
 }
 
 /***********************************************************************




More information about the wine-cvs mailing list