Fix OemToAnsiBuff for real Win31 behavior.
[wine.git] / ole / typelib.c
blob62bd118bd7262ebec9a94982bd836d4ab260d172
1 /*
2 * TYPELIB
4 * Copyright 1997 Marcus Meissner
5 */
7 #include <stdlib.h>
8 #include <string.h>
9 #include <assert.h>
10 #include "wintypes.h"
11 #include "winerror.h"
12 #include "winreg.h"
13 #include "oleauto.h"
14 #include "wine/winbase16.h"
15 #include "heap.h"
16 #include "wine/obj_base.h"
17 #include "debug.h"
18 #include "winversion.h"
20 /****************************************************************************
21 * QueryPathOfRegTypeLib16 [TYPELIB.14]
23 * the path is "Classes\Typelib\<guid>\<major>.<minor>\<lcid>\win16\"
24 * RETURNS
25 * path of typelib
27 HRESULT WINAPI
28 QueryPathOfRegTypeLib16(
29 REFGUID guid, /* [in] referenced guid */
30 WORD wMaj, /* [in] major version */
31 WORD wMin, /* [in] minor version */
32 LCID lcid, /* [in] locale id */
33 LPBSTR16 path /* [out] path of typelib */
34 ) {
35 char xguid[80];
36 char typelibkey[100],pathname[260];
37 DWORD plen;
39 if (HIWORD(guid)) {
40 WINE_StringFromCLSID(guid,xguid);
41 sprintf(typelibkey,"SOFTWARE\\Classes\\Typelib\\%s\\%d.%d\\%ld\\win16",
42 xguid,wMaj,wMin,lcid&0xff
44 } else {
45 sprintf(xguid,"<guid 0x%08lx>",(DWORD)guid);
46 FIXME(ole,"(%s,%d,%d,0x%04lx,%p),can't handle non-string guids.\n",xguid,wMaj,wMin,(DWORD)lcid,path);
47 return E_FAIL;
49 plen = sizeof(pathname);
50 if (RegQueryValue16(HKEY_LOCAL_MACHINE,typelibkey,pathname,&plen)) {
51 FIXME(ole,"key %s not found\n",typelibkey);
52 return E_FAIL;
54 *path = SysAllocString16(pathname);
55 return S_OK;
58 /****************************************************************************
59 * QueryPathOfRegTypeLib32 [OLEAUT32.164]
60 * RETURNS
61 * path of typelib
63 HRESULT WINAPI
64 QueryPathOfRegTypeLib(
65 REFGUID guid, /* [in] referenced guid */
66 WORD wMaj, /* [in] major version */
67 WORD wMin, /* [in] minor version */
68 LCID lcid, /* [in] locale id */
69 LPBSTR path /* [out] path of typelib */
70 ) {
71 char xguid[80];
72 char typelibkey[100],pathname[260];
73 DWORD plen;
76 if (HIWORD(guid)) {
77 WINE_StringFromCLSID(guid,xguid);
78 sprintf(typelibkey,"SOFTWARE\\Classes\\Typelib\\%s\\%d.%d\\%ld\\win32",
79 xguid,wMaj,wMin,lcid&0xff
81 } else {
82 sprintf(xguid,"<guid 0x%08lx>",(DWORD)guid);
83 FIXME(ole,"(%s,%d,%d,0x%04lx,%p),stub!\n",xguid,wMaj,wMin,(DWORD)lcid,path);
84 return E_FAIL;
86 plen = sizeof(pathname);
87 if (RegQueryValue16(HKEY_LOCAL_MACHINE,typelibkey,pathname,&plen)) {
88 FIXME(ole,"key %s not found\n",typelibkey);
89 return E_FAIL;
91 *path = HEAP_strdupAtoW(GetProcessHeap(),0,pathname);
92 return S_OK;
95 /******************************************************************************
96 * LoadTypeLib [TYPELIB.3] Loads and registers a type library
97 * NOTES
98 * Docs: OLECHAR32 FAR* szFile
99 * Docs: iTypeLib FAR* FAR* pptLib
101 * RETURNS
102 * Success: S_OK
103 * Failure: Status
105 HRESULT WINAPI LoadTypeLib16(
106 OLECHAR *szFile, /* [in] Name of file to load from */
107 void * *pptLib) /* [out] Pointer to pointer to loaded type library */
109 FIXME(ole, "('%s',%p): stub\n",debugstr_w((LPWSTR)szFile),pptLib);
111 if (pptLib!=0)
112 *pptLib=0;
114 return E_FAIL;
117 /******************************************************************************
118 * LoadTypeLib32 [OLEAUT32.161]
119 * Loads and registers a type library
120 * NOTES
121 * Docs: OLECHAR32 FAR* szFile
122 * Docs: iTypeLib FAR* FAR* pptLib
124 * RETURNS
125 * Success: S_OK
126 * Failure: Status
128 HRESULT WINAPI LoadTypeLib(
129 OLECHAR *szFile, /* [in] Name of file to load from */
130 void * *pptLib) /* [out] Pointer to pointer to loaded type library */
132 FIXME(ole, "('%s',%p): stub\n",debugstr_w(szFile),pptLib);
134 if (pptLib!=0)
135 *pptLib=0;
137 return E_FAIL;
140 /******************************************************************************
141 * LoadRegTypeLib [OLEAUT32.162]
143 HRESULT WINAPI LoadRegTypeLib(
144 REFGUID rguid,
145 unsigned short wVerMajor,
146 unsigned short wVerMinor,
147 LCID lcid,
148 void** pptLib)
150 FIXME(ole, "(): stub\n");
152 if (pptLib!=0)
153 *pptLib=0;
155 return E_FAIL;
158 /******************************************************************************
159 * RegisterTypeLib32 [OLEAUT32.163]
160 * Adds information about a type library to the System Registry
161 * NOTES
162 * Docs: ITypeLib FAR * ptlib
163 * Docs: OLECHAR32 FAR* szFullPath
164 * Docs: OLECHAR32 FAR* szHelpDir
166 * RETURNS
167 * Success: S_OK
168 * Failure: Status
170 HRESULT WINAPI RegisterTypeLib(
171 ITypeLib * ptlib, /*[in] Pointer to the library*/
172 OLECHAR * szFullPath, /*[in] full Path of the library*/
173 OLECHAR * szHelpDir) /*[in] dir to the helpfile for the library, may be NULL*/
174 { FIXME(ole, "(%p,%s,%s): stub\n",ptlib, debugstr_w(szFullPath),debugstr_w(szHelpDir));
175 return S_OK; /* FIXME: pretend everything is OK */
178 /****************************************************************************
179 * OABuildVersion (TYPELIB.15)
180 * RETURNS
181 * path of typelib
183 DWORD WINAPI OABuildVersion16(void)
185 WINDOWS_VERSION ver = VERSION_GetVersion();
187 switch (ver) {
188 case WIN95:
189 return MAKELONG(0xbd0, 0xa); /* Win95A */
190 case WIN31:
191 return MAKELONG(0xbd3, 0x3); /* WfW 3.11 */
192 default:
193 FIXME(ole, "Version value not known yet. Please investigate it !");
194 return MAKELONG(0xbd0, 0xa); /* return Win95A for now */