- New implementation of SendMessage, ReceiveMessage, ReplyMessage functions
[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 "oleauto.h"
16 #include "wine/obj_base.h"
17 #include "objbase.h"
18 #include "debug.h"
19 #include "winversion.h"
20
21 /****************************************************************************
22  *              QueryPathOfRegTypeLib16 [TYPELIB.14]
23  *
24  * the path is "Classes\Typelib\<guid>\<major>.<minor>\<lcid>\win16\"
25  * RETURNS
26  *      path of typelib
27  */
28 HRESULT WINAPI
29 QueryPathOfRegTypeLib16(        
30         REFGUID guid,   /* [in] referenced guid */
31         WORD wMaj,      /* [in] major version */
32         WORD wMin,      /* [in] minor version */
33         LCID lcid,      /* [in] locale id */
34         LPBSTR16 path   /* [out] path of typelib */
35 ) {
36         char    xguid[80];
37         char    typelibkey[100],pathname[260];
38         DWORD   plen;
39
40         if (HIWORD(guid)) {
41                 WINE_StringFromCLSID(guid,xguid);
42                 sprintf(typelibkey,"SOFTWARE\\Classes\\Typelib\\%s\\%d.%d\\%ld\\win16",
43                         xguid,wMaj,wMin,lcid&0xff
44                 );
45         } else {
46                 sprintf(xguid,"<guid 0x%08lx>",(DWORD)guid);
47                 FIXME(ole,"(%s,%d,%d,0x%04lx,%p),can't handle non-string guids.\n",xguid,wMaj,wMin,(DWORD)lcid,path);
48                 return E_FAIL;
49         }
50         plen = sizeof(pathname);
51         if (RegQueryValue16(HKEY_LOCAL_MACHINE,typelibkey,pathname,&plen)) {
52                 FIXME(ole,"key %s not found\n",typelibkey);
53                 return E_FAIL;
54         }
55         *path = SysAllocString16(pathname);
56         return S_OK;
57 }
58  
59 /****************************************************************************
60  *              QueryPathOfRegTypeLib32 [OLEAUT32.164]
61  * RETURNS
62  *      path of typelib
63  */
64 HRESULT WINAPI
65 QueryPathOfRegTypeLib32(        
66         REFGUID guid,   /* [in] referenced guid */
67         WORD wMaj,      /* [in] major version */
68         WORD wMin,      /* [in] minor version */
69         LCID lcid,      /* [in] locale id */
70         LPBSTR32 path   /* [out] path of typelib */
71 ) {
72         char    xguid[80];
73         char    typelibkey[100],pathname[260];
74         DWORD   plen;
75
76
77         if (HIWORD(guid)) {
78                 WINE_StringFromCLSID(guid,xguid);
79                 sprintf(typelibkey,"SOFTWARE\\Classes\\Typelib\\%s\\%d.%d\\%ld\\win32",
80                         xguid,wMaj,wMin,lcid&0xff
81                 );
82         } else {
83                 sprintf(xguid,"<guid 0x%08lx>",(DWORD)guid);
84                 FIXME(ole,"(%s,%d,%d,0x%04lx,%p),stub!\n",xguid,wMaj,wMin,(DWORD)lcid,path);
85                 return E_FAIL;
86         }
87         plen = sizeof(pathname);
88         if (RegQueryValue16(HKEY_LOCAL_MACHINE,typelibkey,pathname,&plen)) {
89                 FIXME(ole,"key %s not found\n",typelibkey);
90                 return E_FAIL;
91         }
92         *path = HEAP_strdupAtoW(GetProcessHeap(),0,pathname);
93         return S_OK;
94 }
95
96 /******************************************************************************
97  * LoadTypeLib [TYPELIB.3]  Loads and registers a type library
98  * NOTES
99  *    Docs: OLECHAR32 FAR* szFile
100  *    Docs: iTypeLib FAR* FAR* pptLib
101  *
102  * RETURNS
103  *    Success: S_OK
104  *    Failure: Status
105  */
106 HRESULT WINAPI LoadTypeLib16(
107     OLECHAR32 *szFile, /* [in] Name of file to load from */
108     void * *pptLib) /* [out] Pointer to pointer to loaded type library */
109 {
110     FIXME(ole, "('%s',%p): stub\n",debugstr_w((LPWSTR)szFile),pptLib);
111
112     if (pptLib!=0)
113       *pptLib=0;
114
115     return E_FAIL;
116 }
117
118 /******************************************************************************
119  *              LoadTypeLib32   [OLEAUT32.161]
120  * Loads and registers a type library
121  * NOTES
122  *    Docs: OLECHAR32 FAR* szFile
123  *    Docs: iTypeLib FAR* FAR* pptLib
124  *
125  * RETURNS
126  *    Success: S_OK
127  *    Failure: Status
128  */
129 HRESULT WINAPI LoadTypeLib32(
130     OLECHAR32 *szFile,   /* [in] Name of file to load from */
131     void * *pptLib) /* [out] Pointer to pointer to loaded type library */
132 {
133     FIXME(ole, "('%s',%p): stub\n",debugstr_w(szFile),pptLib);
134
135     if (pptLib!=0)
136       *pptLib=0;
137
138     return E_FAIL;
139 }
140
141 /******************************************************************************
142  *              RegisterTypeLib32       [OLEAUT32.163]
143  * Adds information about a type library to the System Registry           
144  * NOTES
145  *    Docs: ITypeLib FAR * ptlib
146  *    Docs: OLECHAR32 FAR* szFullPath
147  *    Docs: OLECHAR32 FAR* szHelpDir
148  *
149  * RETURNS
150  *    Success: S_OK
151  *    Failure: Status
152  */
153 HRESULT WINAPI RegisterTypeLib32(
154      ITypeLib * ptlib,      /*[in] Pointer to the library*/
155      OLECHAR32 * szFullPath, /*[in] full Path of the library*/
156      OLECHAR32 * szHelpDir)  /*[in] dir to the helpfile for the library, may be NULL*/
157 {   FIXME(ole, "(%p,%s,%s): stub\n",ptlib, debugstr_w(szFullPath),debugstr_w(szHelpDir));
158     return S_OK;        /* FIXME: pretend everything is OK */
159 }
160
161 /****************************************************************************
162  *      OABuildVersion                          (TYPELIB.15)
163  * RETURNS
164  *      path of typelib
165  */
166 DWORD WINAPI OABuildVersion(void)
167 {
168 WINDOWS_VERSION ver = VERSION_GetVersion();
169
170     switch (ver) {
171       case WIN95:
172         return MAKELONG(0xbd0, 0xa); /* Win95A */
173       case WIN31:
174         return MAKELONG(0xbd3, 0x3); /* WfW 3.11 */
175       default:
176         FIXME(ole, "Version value not known yet. Please investigate it !");
177         return MAKELONG(0xbd0, 0xa); /* return Win95A for now */
178     }
179 }