mfplat/sample: Optimize copying to 2d buffer.
[wine.git] / dlls / typelib.dll16 / typelib.c
blob41a4790a2533a99aa7735835a102997c16cec83c
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include <stdlib.h>
25 #include <string.h>
26 #include <stdarg.h>
27 #include <stdio.h>
28 #include <ctype.h>
30 #include "winerror.h"
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wine/winbase16.h"
34 #include "winreg.h"
35 #include "winuser.h"
36 #include "objbase.h"
37 #include "oleauto.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(ole);
42 /*************************************************************************
43 * TYPELIB {TYPELIB}
45 * This dll is the 16 bit version of the Typelib API, part the original
46 * implementation of Ole automation. It and its companion ole2disp.dll were
47 * superseded by oleaut32.dll which provides 32 bit implementations of these
48 * functions and greatly extends the OLE API.
50 * Winelib developers cannot use these functions directly, they are implemented
51 * solely for backwards compatibility with existing legacy applications.
53 * SEE ALSO
54 * oleaut32(), ole2disp().
57 /****************************************************************************
58 * QueryPathOfRegTypeLib [TYPELIB.14]
60 * Get the registry key of a registered type library.
62 * RETURNS
63 * Success: S_OK. path is updated with the key name
64 * Failure: E_FAIL, if guid was not found in the registry
66 * NOTES
67 * The key takes the form "Classes\Typelib\<guid>\<major>.<minor>\<lcid>\win16\"
69 HRESULT WINAPI
70 QueryPathOfRegTypeLib16(
71 REFGUID guid, /* [in] Guid to get the key name for */
72 WORD wMaj, /* [in] Major version */
73 WORD wMin, /* [in] Minor version */
74 LCID lcid, /* [in] Locale Id */
75 SEGPTR *path) /* [out] Destination for the registry key name */
77 char xguid[80];
78 char typelibkey[100],pathname[260];
79 LONG plen;
80 char *ret;
82 TRACE("\n");
84 if (HIWORD(guid)) {
85 sprintf( typelibkey, "SOFTWARE\\Classes\\Typelib\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\%d.%d\\%lx\\win16",
86 guid->Data1, guid->Data2, guid->Data3,
87 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
88 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7],
89 wMaj,wMin,lcid);
90 } else {
91 sprintf(xguid,"<guid 0x%08lx>",(DWORD)guid);
92 FIXME("(%s,%d,%d,0x%04lx,%p),can't handle non-string guids.\n",xguid,wMaj,wMin,lcid,path);
93 return E_FAIL;
95 plen = sizeof(pathname);
96 if (RegQueryValueA(HKEY_LOCAL_MACHINE,typelibkey,pathname,&plen)) {
97 /* try again without lang specific id */
98 if (SUBLANGID(lcid))
99 return QueryPathOfRegTypeLib16(guid,wMaj,wMin,PRIMARYLANGID(lcid),path);
100 FIXME("key %s not found\n",typelibkey);
101 return E_FAIL;
103 ret = HeapAlloc( GetProcessHeap(), 0, strlen(pathname) + 1 );
104 if (!ret) return E_FAIL;
105 strcpy( ret, pathname );
106 *path = MapLS(ret);
107 return S_OK;
110 /******************************************************************************
111 * LoadTypeLib [TYPELIB.3]
113 * Load and register a type library.
115 * RETURNS
116 * Success: S_OK. pptLib contains the type libraries ITypeLib interface.
117 * Failure: An HRESULT error code.
119 * NOTES
120 * Both parameters are FAR pointers.
122 HRESULT WINAPI LoadTypeLib16(
123 LPSTR szFile, /* [in] Name of file to load from */
124 ITypeLib** pptLib) /* [out] Destination for loaded ITypeLib interface */
126 FIXME("(%s,%p): stub\n",debugstr_a(szFile),pptLib);
128 if (pptLib!=0)
129 *pptLib=0;
131 return E_FAIL;
134 /***********************************************************************
135 * LHashValOfNameSys (TYPELIB.4)
137 ULONG WINAPI LHashValOfNameSys16( SYSKIND skind, LCID lcid, LPCSTR lpStr)
139 return LHashValOfNameSysA( skind, lcid, lpStr );
142 /****************************************************************************
143 * OaBuildVersion (TYPELIB.15)
145 * Get the Ole Automation build version.
147 * PARAMS
148 * None
150 * RETURNS
151 * The build version.
153 * NOTES
154 * Known typelib.dll versions:
155 *| OLE Ver. Comments Date Build Ver.
156 *| -------- ------------------------- ---- ---------
157 *| OLE 2.01 Call not available 1993 N/A
158 *| OLE 2.02 1993-94 02 3002
159 *| OLE 2.03 23 730
160 *| OLE 2.03 03 3025
161 *| OLE 2.03 W98 SE orig. file !! 1993-95 10 3024
162 *| OLE 2.1 NT 1993-95 ?? ???
163 *| OLE 2.3.1 W95 23 700
164 *| OLE2 4.0 NT4SP6 1993-98 40 4277
165 *| OLE 2.1 W2K 2000 10 3029
166 *| OLE 2.1 WXP 2002 10 3029
167 *| OLE 2.1 Vista 2007 10 3029
169 DWORD WINAPI OaBuildVersion16(void)
171 /* FIXME: I'd like to return the highest currently known version value
172 * in case the user didn't force a --winver, but I don't know how
173 * to retrieve the "versionForced" info from misc/version.c :(
174 * (this would be useful in other places, too) */
175 FIXME("If you get version error messages, please report them\n");
176 switch(GetVersion() & 0x8000ffff) /* mask off build number */
178 case 0x80000a03: /* WIN31 */
179 return MAKELONG(3027, 3); /* WfW 3.11 */
180 case 0x80000004: /* WIN95 */
181 return MAKELONG(700, 23); /* Win95A */
182 case 0x80000a04: /* WIN98 */
183 return MAKELONG(3024, 10); /* W98 SE */
184 case 0x00000004: /* NT4 */
185 return MAKELONG(4277, 40); /* NT4 SP6 */
186 case 0x00000005: /* W2K */
187 return MAKELONG(3029, 10); /* W2K SP4 */
188 case 0x00000105: /* WXP */
189 return MAKELONG(3029, 10); /* WXP SP2 */
190 case 0x00000006: /* Vista */
191 return MAKELONG(3029, 10); /* Vista */
192 default:
193 FIXME("Version value not known yet. Please investigate it!\n");
194 return 0;