Release 20030408.
[wine/gsoc-2012-control.git] / dlls / oleaut32 / typelib16.c
blob9b16d659c2973f1d5feba9d5777f216b1a4eeef5
1 /*
2 * TYPELIB 16bit part.
4 * Copyright 1997 Marcus Meissner
5 * Copyright 1999 Rein Klazes
6 * Copyright 2000 Francois Jacques
7 * Copyright 2001 Huw D M Davies for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "config.h"
25 #include "wine/port.h"
27 #include <stdlib.h>
28 #include <string.h>
29 #include <stdio.h>
30 #include <ctype.h>
32 #include "winerror.h"
33 #include "winnls.h" /* for PRIMARYLANGID */
34 #include "winreg.h" /* for HKEY_LOCAL_MACHINE */
35 #include "winuser.h"
37 #include "objbase.h"
38 #include "ole2disp.h"
39 #include "typelib.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(ole);
44 /*************************************************************************
45 * TYPELIB {TYPELIB}
47 * This dll is the 16 bit version of the Typelib API, part the original
48 * implementation of Ole automation. It and its companion ole2disp.dll were
49 * superceeded by oleaut32.dll which provides 32 bit implementations of these
50 * functions and greatly extends the Ole Api.
52 * Winelib developers cannot use these functions directly, they are implemented
53 * solely for backwards compatibility with existing legacy applications.
55 * SEE ALSO
56 * oleaut32(), ole2disp().
59 /****************************************************************************
60 * QueryPathOfRegTypeLib [TYPELIB.14]
62 * Get the registry key of a registered type library.
64 * RETURNS
65 * Success: S_OK. path is updated with the key name
66 * Failure: E_FAIL, if guid was not found in the registry
68 * NOTES
69 * The key takes the form "Classes\Typelib\<guid>\<major>.<minor>\<lcid>\win16\"
71 HRESULT WINAPI
72 QueryPathOfRegTypeLib16(
73 REFGUID guid, /* [in] Guid to get the key name for */
74 WORD wMaj, /* [in] Major version */
75 WORD wMin, /* [in] Minor version */
76 LCID lcid, /* [in] Locale Id */
77 LPBSTR16 path) /* [out] Destination for the registry key name */
79 char xguid[80];
80 char typelibkey[100],pathname[260];
81 DWORD plen;
83 TRACE("\n");
85 if (HIWORD(guid)) {
86 sprintf( typelibkey, "SOFTWARE\\Classes\\Typelib\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\%d.%d\\%lx\\win16",
87 guid->Data1, guid->Data2, guid->Data3,
88 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
89 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7],
90 wMaj,wMin,lcid);
91 } else {
92 sprintf(xguid,"<guid 0x%08lx>",(DWORD)guid);
93 FIXME("(%s,%d,%d,0x%04lx,%p),can't handle non-string guids.\n",xguid,wMaj,wMin,(DWORD)lcid,path);
94 return E_FAIL;
96 plen = sizeof(pathname);
97 if (RegQueryValueA(HKEY_LOCAL_MACHINE,typelibkey,pathname,&plen)) {
98 /* try again without lang specific id */
99 if (SUBLANGID(lcid))
100 return QueryPathOfRegTypeLib16(guid,wMaj,wMin,PRIMARYLANGID(lcid),path);
101 FIXME("key %s not found\n",typelibkey);
102 return E_FAIL;
104 *path = SysAllocString16(pathname);
105 return S_OK;
108 /******************************************************************************
109 * LoadTypeLib [TYPELIB.3]
111 * Load and register a type library.
113 * RETURNS
114 * Success: S_OK. pptLib contains the type libraries ITypeLib interface.
115 * Failure: An HRESULT error code.
117 * NOTES
118 * Both parameters are FAR pointers.
120 HRESULT WINAPI LoadTypeLib16(
121 LPOLESTR szFile, /* [in] Name of file to load from */
122 ITypeLib** pptLib) /* [out] Destination for loaded ITypeLib interface */
124 FIXME("(%s,%p): stub\n",debugstr_w((LPWSTR)szFile),pptLib);
126 if (pptLib!=0)
127 *pptLib=0;
129 return E_FAIL;
132 /****************************************************************************
133 * OaBuildVersion (TYPELIB.15)
135 * Get the Ole Automation build version.
137 * PARAMS
138 * None
140 * RETURNS
141 * The build version.
143 * NOTES
144 * Known typelib.dll versions:
145 *| OLE Ver. Comments Date Build Ver.
146 *| -------- ------------------------- ---- ---------
147 *| OLE 2.01 Call not available 1993 N/A
148 *| OLE 2.02 1993-94 02 3002
149 *| OLE 2.03 23 730
150 *| OLE 2.03 03 3025
151 *| OLE 2.03 W98 SE orig. file !! 1993-95 10 3024
152 *| OLE 2.1 NT 1993-95 ?? ???
153 *| OLE 2.3.1 W95 23 700
154 *| OLE2 4.0 NT4SP6 1993-98 40 4277
156 DWORD WINAPI OaBuildVersion16(void)
158 /* FIXME: I'd like to return the highest currently known version value
159 * in case the user didn't force a --winver, but I don't know how
160 * to retrieve the "versionForced" info from misc/version.c :(
161 * (this would be useful in other places, too) */
162 FIXME("If you get version error messages, please report them\n");
163 switch(GetVersion() & 0x8000ffff) /* mask off build number */
165 case 0x80000a03: /* WIN31 */
166 return MAKELONG(3027, 3); /* WfW 3.11 */
167 case 0x80000004: /* WIN95 */
168 return MAKELONG(700, 23); /* Win95A */
169 case 0x80000a04: /* WIN98 */
170 return MAKELONG(3024, 10); /* W98 SE */
171 case 0x00000004: /* NT4 */
172 return MAKELONG(4277, 40); /* NT4 SP6 */
173 default:
174 FIXME("Version value not known yet. Please investigate it!\n");
175 return 0;