Release 980927
[wine] / ole / typelib.c
1 /*
2  *      TYPELIB
3  *
4  *      Copyright 1997  Marcus Meissner
5  */
6
7 #include <stdlib.h>
8 #include <string.h>
9 #include <assert.h>
10 #include "wintypes.h"
11 #include "heap.h"
12 #include "windows.h"
13 #include "winreg.h"
14 #include "winerror.h"
15 #include "ole.h"
16 #include "ole2.h"
17 #include "oleauto.h"
18 #include "compobj.h"
19 #include "debug.h"
20
21 /****************************************************************************
22  *      QueryPathOfRegTypeLib                   (TYPELIB.14)
23  * the path is "Classes\Typelib\<guid>\<major>.<minor>\<lcid>\win16\"
24  * RETURNS
25  *      path of typelib
26  */
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;
38
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
43                 );
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;
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;
56 }
57  
58 /****************************************************************************
59  *      QueryPathOfRegTypeLib                   (OLEAUT32.164)
60  * RETURNS
61  *      path of typelib
62  */
63 HRESULT WINAPI
64 QueryPathOfRegTypeLib32(        
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         LPBSTR32 path   /* [out] path of typelib */
70 ) {
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);
83                 FIXME(ole,"(%s,%d,%d,0x%04lx,%p),stub!\n",xguid,wMaj,wMin,(DWORD)lcid,path);
84                 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
97  * NOTES
98  *    Docs: OLECHAR FAR* szFile
99  *    Docs: iTypeLib FAR* FAR* pptLib
100  *
101  * RETURNS
102  *    Success: S_OK
103  *    Failure: Status
104  */
105 HRESULT WINAPI LoadTypeLib(
106     void *szFile,   /* [in] Name of file to load from */
107     void * *pptLib) /* [out] Pointer to pointer to loaded type library */
108 {
109     FIXME(ole, "(%s,%p): stub\n",debugstr_a(szFile),pptLib);
110     return E_FAIL;
111 }
112
113 /******************************************************************************
114  * LoadTypeLib                          (OLEAUT32.161)
115  * Loads and registers a type library
116  * NOTES
117  *    Docs: OLECHAR FAR* szFile
118  *    Docs: iTypeLib FAR* FAR* pptLib
119  *
120  * RETURNS
121  *    Success: S_OK
122  *    Failure: Status
123  */
124 HRESULT WINAPI LoadTypeLib32(
125     void *szFile,   /* [in] Name of file to load from */
126     void * *pptLib) /* [out] Pointer to pointer to loaded type library */
127 {
128     FIXME(ole, "(%s,%p): stub\n",szFile,pptLib);
129     (long *)pptLib=0x123;
130     return S_OK;           /* fixme: pretend everything is OK*/
131 }
132
133 /******************************************************************************
134  * RegisterTypeLib                              (OLEAUT32.163)
135  * Adds information about a type library to the System Registry           
136  * NOTES
137  *    Docs: ITypeLib FAR * ptlib
138  *    Docs: OLECHAR FAR* szFullPath
139  *    Docs: OLECHAR FAR* szHelpDir
140  *
141  * RETURNS
142  *    Success: S_OK
143  *    Failure: Status
144  */
145 HRESULT WINAPI RegisterTypeLib32(
146      ITypeLib * ptlib,      /*[in] Pointer to the library*/
147      OLECHAR * szFullPath, /*[in] full Path of the library*/
148      OLECHAR * szHelpDir)  /*[in] dir to the helpfile for the library, may be NULL*/  
149 {   FIXME(ole, "(%p,%s,%s): stub\n",ptlib, szFullPath,szHelpDir);
150     return S_OK;        /* fixme: pretend everything is OK*/
151 }
152
153 /****************************************************************************
154  *      OABuildVersion                          (TYPELIB.15)
155  * RETURNS
156  *      path of typelib
157  */
158 DWORD WINAPI OABuildVersion()
159 {
160         return MAKELONG(0xbd3, 0x3);
161 }