Ignore:
Timestamp:
Sep 17, 2000, 12:31:07 PM (25 years ago)
Author:
davidr
Message:

Updates from wine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ole32/ole2.cpp

    r872 r4274  
    1 /* $Id: ole2.cpp,v 1.2 1999-09-08 11:29:28 davidr Exp $ */
     1/* $Id: ole2.cpp,v 1.3 2000-09-17 10:31:05 davidr Exp $ */
    22/*
    33 *
     
    2121#include "commctrl.h"
    2222#include "oString.h"
     23#include "heapstring.h"
    2324#include <assert.h>
    2425
     
    155156    HKEY                clsidKey;
    156157    LONG                hres;
     158    LPSTR               buffer;
    157159
    158160    dprintf(("OLE32: OleRegGetUserType"));
     
    180182
    181183    // Allocate a buffer for the registry value.
    182     *pszUserType = (LPOLESTR)CoTaskMemAlloc(cbData);
    183 
    184     if (*pszUserType == NULL)
     184    buffer = (LPSTR)HeapAlloc(GetProcessHeap(), 0, cbData);
     185
     186    if (buffer == NULL)
    185187    {
    186188        RegCloseKey(clsidKey);
     
    188190    }
    189191
    190     hres = RegQueryValueExA(HKEY_CLASSES_ROOT, "", NULL, &dwKeyType, (LPBYTE)*pszUserType, &cbData);
     192    hres = RegQueryValueExA(HKEY_CLASSES_ROOT, "", NULL, &dwKeyType, (LPBYTE)buffer, &cbData);
    191193    RegCloseKey(clsidKey);
    192194    if (hres != ERROR_SUCCESS)
    193195    {
    194         CoTaskMemFree(*pszUserType);
    195         *pszUserType = NULL;
     196        HeapFree(GetProcessHeap(), 0, buffer);
    196197        return REGDB_E_READREGDB;
    197198    }
     199
     200    // Allocate a buffer for the return value.
     201    *pszUserType = (LPOLESTR)CoTaskMemAlloc(cbData * 2);
     202
     203    if (*pszUserType == NULL)
     204    {
     205        HeapFree(GetProcessHeap(), 0, buffer);
     206        return E_OUTOFMEMORY;
     207    }
     208
     209    // Copy & convert to unicode...
     210    lstrcpyAtoW(*pszUserType, buffer);
     211    HeapFree(GetProcessHeap(), 0, buffer);
    198212
    199213    return S_OK;
Note: See TracChangeset for help on using the changeset viewer.