blob: 504a5c878072ffacfedb63b1ac6f6d8f85d96aea [file] [log] [blame]
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001/*
2 * TYPELIB
3 *
4 * Copyright 1997 Marcus Meissner
5 */
6
7#include <stdlib.h>
8#include <string.h>
9#include <assert.h>
Jim Aston2e1cafa1999-03-14 16:35:05 +000010#include "windef.h"
Marcus Meissner064f1701999-02-28 19:14:33 +000011#include "winerror.h"
12#include "winreg.h"
13#include "oleauto.h"
Marcus Meissner219cfd81999-02-24 13:05:13 +000014#include "wine/winbase16.h"
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000015#include "heap.h"
Alexandre Julliard638f1691999-01-17 16:32:32 +000016#include "wine/obj_base.h"
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000017#include "debug.h"
Andreas Mohr29bbe121998-11-22 16:36:07 +000018#include "winversion.h"
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000019
Alexandre Julliard54c27111998-03-29 19:44:57 +000020/****************************************************************************
Matthew Beckerb05264f1998-10-11 14:21:42 +000021 * QueryPathOfRegTypeLib16 [TYPELIB.14]
22 *
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000023 * the path is "Classes\Typelib\<guid>\<major>.<minor>\<lcid>\win16\"
Alexandre Julliard54c27111998-03-29 19:44:57 +000024 * RETURNS
25 * path of typelib
26 */
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000027HRESULT WINAPI
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000028QueryPathOfRegTypeLib16(
Alexandre Julliard54c27111998-03-29 19:44:57 +000029 REFGUID guid, /* [in] referenced guid */
30 WORD wMaj, /* [in] major version */
31 WORD wMin, /* [in] minor version */
32 LCID lcid, /* [in] locale id */
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000033 LPBSTR16 path /* [out] path of typelib */
Alexandre Julliard54c27111998-03-29 19:44:57 +000034) {
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000035 char xguid[80];
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000036 char typelibkey[100],pathname[260];
37 DWORD plen;
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000038
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000039 if (HIWORD(guid)) {
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000040 WINE_StringFromCLSID(guid,xguid);
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000041 sprintf(typelibkey,"SOFTWARE\\Classes\\Typelib\\%s\\%d.%d\\%ld\\win16",
42 xguid,wMaj,wMin,lcid&0xff
43 );
44 } else {
Alexandre Julliard54c27111998-03-29 19:44:57 +000045 sprintf(xguid,"<guid 0x%08lx>",(DWORD)guid);
Alexandre Julliardf90efa91998-06-14 15:24:15 +000046 FIXME(ole,"(%s,%d,%d,0x%04lx,%p),can't handle non-string guids.\n",xguid,wMaj,wMin,(DWORD)lcid,path);
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000047 return E_FAIL;
48 }
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;
53 }
54 *path = SysAllocString16(pathname);
55 return S_OK;
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000056}
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000057
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000058/****************************************************************************
Matthew Beckerb05264f1998-10-11 14:21:42 +000059 * QueryPathOfRegTypeLib32 [OLEAUT32.164]
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000060 * RETURNS
61 * path of typelib
62 */
63HRESULT WINAPI
Alexandre Julliarda3960291999-02-26 11:11:13 +000064QueryPathOfRegTypeLib(
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000065 REFGUID guid, /* [in] referenced guid */
66 WORD wMaj, /* [in] major version */
67 WORD wMin, /* [in] minor version */
68 LCID lcid, /* [in] locale id */
Alexandre Julliarda3960291999-02-26 11:11:13 +000069 LPBSTR path /* [out] path of typelib */
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000070) {
71 char xguid[80];
72 char typelibkey[100],pathname[260];
73 DWORD plen;
74
75
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
80 );
81 } else {
82 sprintf(xguid,"<guid 0x%08lx>",(DWORD)guid);
Alexandre Julliardf90efa91998-06-14 15:24:15 +000083 FIXME(ole,"(%s,%d,%d,0x%04lx,%p),stub!\n",xguid,wMaj,wMin,(DWORD)lcid,path);
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000084 return E_FAIL;
85 }
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;
90 }
91 *path = HEAP_strdupAtoW(GetProcessHeap(),0,pathname);
92 return S_OK;
93}
94
95/******************************************************************************
96 * LoadTypeLib [TYPELIB.3] Loads and registers a type library
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000097 * NOTES
Jean-Claude Coteb00cbea1998-12-10 10:00:38 +000098 * Docs: OLECHAR32 FAR* szFile
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000099 * Docs: iTypeLib FAR* FAR* pptLib
100 *
101 * RETURNS
102 * Success: S_OK
103 * Failure: Status
104 */
Andreas Mohr7a6228d1998-12-11 09:16:48 +0000105HRESULT WINAPI LoadTypeLib16(
Alexandre Julliarda3960291999-02-26 11:11:13 +0000106 OLECHAR *szFile, /* [in] Name of file to load from */
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000107 void * *pptLib) /* [out] Pointer to pointer to loaded type library */
108{
Juergen Schmied69f2ea61998-12-26 19:44:13 +0000109 FIXME(ole, "('%s',%p): stub\n",debugstr_w((LPWSTR)szFile),pptLib);
Francis Beaudet4f85ca41999-01-23 11:53:21 +0000110
111 if (pptLib!=0)
112 *pptLib=0;
113
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000114 return E_FAIL;
115}
116
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000117/******************************************************************************
Matthew Beckerb05264f1998-10-11 14:21:42 +0000118 * LoadTypeLib32 [OLEAUT32.161]
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000119 * Loads and registers a type library
120 * NOTES
Jean-Claude Coteb00cbea1998-12-10 10:00:38 +0000121 * Docs: OLECHAR32 FAR* szFile
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000122 * Docs: iTypeLib FAR* FAR* pptLib
123 *
124 * RETURNS
125 * Success: S_OK
126 * Failure: Status
127 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000128HRESULT WINAPI LoadTypeLib(
129 OLECHAR *szFile, /* [in] Name of file to load from */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000130 void * *pptLib) /* [out] Pointer to pointer to loaded type library */
131{
Juergen Schmied69f2ea61998-12-26 19:44:13 +0000132 FIXME(ole, "('%s',%p): stub\n",debugstr_w(szFile),pptLib);
Francis Beaudet4f85ca41999-01-23 11:53:21 +0000133
134 if (pptLib!=0)
135 *pptLib=0;
136
137 return E_FAIL;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000138}
139
140/******************************************************************************
Francis Beaudeteb5a29b1999-02-20 16:48:53 +0000141 * LoadRegTypeLib [OLEAUT32.162]
142 */
143HRESULT WINAPI LoadRegTypeLib(
144 REFGUID rguid,
145 unsigned short wVerMajor,
146 unsigned short wVerMinor,
147 LCID lcid,
148 void** pptLib)
149{
150 FIXME(ole, "(): stub\n");
151
152 if (pptLib!=0)
153 *pptLib=0;
154
155 return E_FAIL;
156}
157
158/******************************************************************************
Matthew Beckerb05264f1998-10-11 14:21:42 +0000159 * RegisterTypeLib32 [OLEAUT32.163]
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000160 * Adds information about a type library to the System Registry
161 * NOTES
162 * Docs: ITypeLib FAR * ptlib
Jean-Claude Coteb00cbea1998-12-10 10:00:38 +0000163 * Docs: OLECHAR32 FAR* szFullPath
164 * Docs: OLECHAR32 FAR* szHelpDir
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000165 *
166 * RETURNS
167 * Success: S_OK
168 * Failure: Status
169 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000170HRESULT WINAPI RegisterTypeLib(
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000171 ITypeLib * ptlib, /*[in] Pointer to the library*/
Alexandre Julliarda3960291999-02-26 11:11:13 +0000172 OLECHAR * szFullPath, /*[in] full Path of the library*/
173 OLECHAR * szHelpDir) /*[in] dir to the helpfile for the library, may be NULL*/
Juergen Schmied69f2ea61998-12-26 19:44:13 +0000174{ FIXME(ole, "(%p,%s,%s): stub\n",ptlib, debugstr_w(szFullPath),debugstr_w(szHelpDir));
Andreas Mohr29bbe121998-11-22 16:36:07 +0000175 return S_OK; /* FIXME: pretend everything is OK */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000176}
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000177
178/****************************************************************************
179 * OABuildVersion (TYPELIB.15)
180 * RETURNS
181 * path of typelib
182 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000183DWORD WINAPI OABuildVersion16(void)
Alexandre Julliard54c27111998-03-29 19:44:57 +0000184{
Andreas Mohr29bbe121998-11-22 16:36:07 +0000185WINDOWS_VERSION ver = VERSION_GetVersion();
186
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 */
195 }
Alexandre Julliard54c27111998-03-29 19:44:57 +0000196}