Vitaly Lipatov : oledlg: Use wide strings, fix buffers size.

Alexandre Julliard julliard at winehq.org
Wed Dec 5 06:56:45 CST 2007


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

Author: Vitaly Lipatov <lav at etersoft.ru>
Date:   Sat Dec  1 19:08:26 2007 +0300

oledlg: Use wide strings, fix buffers size.

---

 dlls/oledlg/Makefile.in |    2 +-
 dlls/oledlg/insobjdlg.c |   43 +++++++++++++++++++++----------------------
 2 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/dlls/oledlg/Makefile.in b/dlls/oledlg/Makefile.in
index ed51a94..e2ea707 100644
--- a/dlls/oledlg/Makefile.in
+++ b/dlls/oledlg/Makefile.in
@@ -4,7 +4,7 @@ SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = oledlg.dll
 IMPORTLIB = liboledlg.$(IMPLIBEXT)
-IMPORTS   = ole32 comdlg32 user32 advapi32 kernel32 ntdll
+IMPORTS   = ole32 comdlg32 user32 advapi32 kernel32
 
 C_SRCS = \
 	insobjdlg.c \
diff --git a/dlls/oledlg/insobjdlg.c b/dlls/oledlg/insobjdlg.c
index 8ddf227..159b002 100644
--- a/dlls/oledlg/insobjdlg.c
+++ b/dlls/oledlg/insobjdlg.c
@@ -332,38 +332,39 @@ static void UIINSERTOBJECTDLG_SelectCreateFromFile(InsertObjectDlgInfo* pdlgInfo
  */
 static BOOL UIINSERTOBJECTDLG_PopulateObjectTypes(InsertObjectDlgInfo* pdlgInfo)
 {
+  static const WCHAR szClsid[] = {'C','L','S','I','D',0};
+  static const WCHAR szInsertable[] = {'I','n','s','e','r','t','a','b','l','e',0};
+  static const WCHAR szNotInsertable[] = {'N','o','t','I','n','s','e','r','t','a','b','l','e',0};
   DWORD i;
   LONG len;
   HKEY hkclsids;
   HKEY hkey;
   CLSID clsid;
   HRESULT ret;
-  CHAR szclsid[128];
-  CHAR keydesc[MAX_PATH];
-  CHAR keyname[MAX_PATH];
-  WCHAR wszclsid[128];
+  WCHAR keydesc[MAX_PATH];
+  WCHAR keyname[MAX_PATH];
+  WCHAR szclsid[128];
   DWORD index = 0;
 
   UIINSERTOBJECTDLG_FreeObjectTypes(pdlgInfo);
 
-  RegOpenKeyExA(HKEY_CLASSES_ROOT, "CLSID", 0, KEY_READ, &hkclsids);
+  RegOpenKeyExW(HKEY_CLASSES_ROOT, szClsid, 0, KEY_READ, &hkclsids);
 
-  while (ERROR_SUCCESS == (ret = RegEnumKeyA(hkclsids, index, szclsid, MAX_PATH)))
+  while (ERROR_SUCCESS == (ret = RegEnumKeyW(hkclsids, index, szclsid, sizeof(szclsid)/sizeof(szclsid[0]))))
   {
     index++;
 
-    RegOpenKeyExA(hkclsids, szclsid, 0, KEY_READ, &hkey);
+    RegOpenKeyExW(hkclsids, szclsid, 0, KEY_READ, &hkey);
 
-    len = MAX_PATH;
-    if (ERROR_SUCCESS != RegQueryValueA(hkey, "Insertable", keyname, &len))
+    len = sizeof(keyname);
+    if (ERROR_SUCCESS != RegQueryValueW(hkey, szInsertable, keyname, &len))
         continue;
 
-    len = MAX_PATH;
-    if (ERROR_SUCCESS == RegQueryValueA(hkey, "NotInsertable", keyname, &len))
+    len = sizeof(keyname);
+    if (ERROR_SUCCESS == RegQueryValueW(hkey, szNotInsertable, keyname, &len))
         continue;
 
-    RtlMultiByteToUnicodeN(wszclsid, MAX_PATH, NULL, szclsid, MAX_PATH); 
-    CLSIDFromString(wszclsid, &clsid);
+    CLSIDFromString(szclsid, &clsid);
 
     for (i = 0; i < pdlgInfo->lpOleUIInsertObject->cClsidExclude; i++)
       if (IsEqualGUID(&pdlgInfo->lpOleUIInsertObject->lpClsidExclude[i], &clsid))
@@ -372,14 +373,14 @@ static BOOL UIINSERTOBJECTDLG_PopulateObjectTypes(InsertObjectDlgInfo* pdlgInfo)
     if (i < pdlgInfo->lpOleUIInsertObject->cClsidExclude)
       continue;
 
-    len = MAX_PATH;
-    if (ERROR_SUCCESS == RegQueryValueA(hkey, NULL, keydesc, &len))
+    len = sizeof(keydesc);
+    if (ERROR_SUCCESS == RegQueryValueW(hkey, NULL, keydesc, &len))
     {
        CLSID* lpclsid = HeapAlloc(GetProcessHeap(), 0, sizeof(CLSID));
        memcpy(lpclsid, &clsid, sizeof(CLSID));
 
-       len = SendMessageA(pdlgInfo->hwndObjTypeLB, LB_ADDSTRING, 0, (LPARAM)keydesc);
-       SendMessageA(pdlgInfo->hwndObjTypeLB, LB_SETITEMDATA, (WPARAM)len, (LPARAM)lpclsid);
+       len = SendMessageW(pdlgInfo->hwndObjTypeLB, LB_ADDSTRING, 0, (LPARAM)keydesc);
+       SendMessageW(pdlgInfo->hwndObjTypeLB, LB_SETITEMDATA, (WPARAM)len, (LPARAM)lpclsid);
     }
   }
 
@@ -471,17 +472,15 @@ static BOOL UIINSERTOBJECTDLG_OnOpen(InsertObjectDlgInfo* pdlgInfo)
   }
   else if (BST_CHECKED == SendMessageA(pdlgInfo->hwndCreateFromFileCB, BM_GETCHECK, 0, 0))
   {
-    char fname[MAX_PATH];
-
     if (pdlgInfo->lpOleUIInsertObject->lpszFile)
     {
       HRESULT hres;
       WCHAR wcsFile[MAX_PATH];
 
-      SendMessageA(pdlgInfo->hwndFileTB, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)fname);
-      lstrcpynA(pdlgInfo->lpOleUIInsertObject->lpszFile, fname, pdlgInfo->lpOleUIInsertObject->cchFile);
+      if (SendMessageW(pdlgInfo->hwndFileTB, WM_GETTEXT, MAX_PATH, (LPARAM)wcsFile))
+          WideCharToMultiByte(CP_ACP, 0, wcsFile, -1,
+              pdlgInfo->lpOleUIInsertObject->lpszFile, pdlgInfo->lpOleUIInsertObject->cchFile, NULL, NULL);
 
-      RtlMultiByteToUnicodeN(wcsFile, MAX_PATH, NULL, fname, MAX_PATH); 
       if (ERROR_SUCCESS == (hres = GetClassFile(wcsFile, &pdlgInfo->lpOleUIInsertObject->clsid)))
       {
          if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CREATEFILEOBJECT)




More information about the wine-cvs mailing list