typelib.c 6.45 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 *	TYPELIB 16bit part.
 *
 * Copyright 1997 Marcus Meissner
 * Copyright 1999 Rein Klazes
 * Copyright 2000 Francois Jacques
 * Copyright 2001 Huw D M Davies for CodeWeavers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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
22 23 24 25
 */

#include <stdlib.h>
#include <string.h>
26
#include <stdarg.h>
27 28 29 30
#include <stdio.h>
#include <ctype.h>

#include "winerror.h"
31
#include "windef.h"
32
#include "winbase.h"
33
#include "wine/winbase16.h"
34
#include "winreg.h"
35 36
#include "winuser.h"
#include "objbase.h"
37
#include "oleauto.h"
38 39 40 41
#include "wine/debug.h"

WINE_DEFAULT_DEBUG_CHANNEL(ole);

Jon Griffiths's avatar
Jon Griffiths committed
42 43 44 45 46
/*************************************************************************
 * TYPELIB {TYPELIB}
 *
 * This dll is the 16 bit version of the Typelib API, part the original
 * implementation of Ole automation. It and its companion ole2disp.dll were
Francois Gouget's avatar
Francois Gouget committed
47
 * superseded by oleaut32.dll which provides 32 bit implementations of these
48
 * functions and greatly extends the OLE API.
Jon Griffiths's avatar
Jon Griffiths committed
49 50 51 52 53 54 55 56
 *
 * Winelib developers cannot use these functions directly, they are implemented
 * solely for backwards compatibility with existing legacy applications.
 *
 * SEE ALSO
 *  oleaut32(), ole2disp().
 */

57 58 59
/****************************************************************************
 *		QueryPathOfRegTypeLib	[TYPELIB.14]
 *
Jon Griffiths's avatar
Jon Griffiths committed
60 61
 * Get the registry key of a registered type library.
 *
62
 * RETURNS
Jon Griffiths's avatar
Jon Griffiths committed
63 64 65 66 67
 *  Success: S_OK. path is updated with the key name
 *  Failure: E_FAIL, if guid was not found in the registry
 *
 * NOTES
 *  The key takes the form "Classes\Typelib\<guid>\<major>.<minor>\<lcid>\win16\"
68 69 70
 */
HRESULT WINAPI
QueryPathOfRegTypeLib16(
Jon Griffiths's avatar
Jon Griffiths committed
71 72 73 74
	REFGUID guid,	/* [in] Guid to get the key name for */
	WORD wMaj,	/* [in] Major version */
	WORD wMin,	/* [in] Minor version */
	LCID lcid,	/* [in] Locale Id */
75
	SEGPTR *path)	/* [out] Destination for the registry key name */
Jon Griffiths's avatar
Jon Griffiths committed
76
{
77 78
	char	xguid[80];
	char	typelibkey[100],pathname[260];
79
	LONG	plen;
80
        char   *ret;
81

82
	TRACE("\n");
83 84

	if (HIWORD(guid)) {
85
            sprintf( typelibkey, "SOFTWARE\\Classes\\Typelib\\{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\%d.%d\\%x\\win16",
86 87 88 89 90
                     guid->Data1, guid->Data2, guid->Data3,
                     guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
                     guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7],
                     wMaj,wMin,lcid);
	} else {
91
		sprintf(xguid,"<guid 0x%08x>",(DWORD)guid);
92
		FIXME("(%s,%d,%d,0x%04x,%p),can't handle non-string guids.\n",xguid,wMaj,wMin,lcid,path);
93 94 95 96 97 98 99 100 101 102
		return E_FAIL;
	}
	plen = sizeof(pathname);
	if (RegQueryValueA(HKEY_LOCAL_MACHINE,typelibkey,pathname,&plen)) {
		/* try again without lang specific id */
		if (SUBLANGID(lcid))
			return QueryPathOfRegTypeLib16(guid,wMaj,wMin,PRIMARYLANGID(lcid),path);
		FIXME("key %s not found\n",typelibkey);
		return E_FAIL;
	}
103 104 105 106
        ret = HeapAlloc( GetProcessHeap(), 0, strlen(pathname) + 1 );
        if (!ret) return E_FAIL;
        strcpy( ret, pathname );
	*path = MapLS(ret);
107 108 109 110
	return S_OK;
}

/******************************************************************************
Jon Griffiths's avatar
Jon Griffiths committed
111 112 113
 * LoadTypeLib [TYPELIB.3]
 *
 * Load and register a type library.
114 115
 *
 * RETURNS
Jon Griffiths's avatar
Jon Griffiths committed
116 117 118 119 120
 *  Success: S_OK. pptLib contains the type libraries ITypeLib interface.
 *  Failure: An HRESULT error code.
 *
 * NOTES
 *  Both parameters are FAR pointers.
121 122
 */
HRESULT WINAPI LoadTypeLib16(
123
    LPSTR szFile, /* [in] Name of file to load from */
Jon Griffiths's avatar
Jon Griffiths committed
124
    ITypeLib** pptLib) /* [out] Destination for loaded ITypeLib interface */
125
{
126
    FIXME("(%s,%p): stub\n",debugstr_a(szFile),pptLib);
127 128 129 130 131 132 133

    if (pptLib!=0)
      *pptLib=0;

    return E_FAIL;
}

134 135 136 137 138 139 140 141
/***********************************************************************
 *              LHashValOfNameSys  (TYPELIB.4)
 */
ULONG WINAPI LHashValOfNameSys16( SYSKIND skind, LCID lcid, LPCSTR lpStr)
{
    return LHashValOfNameSysA( skind, lcid, lpStr );
}

142 143 144
/****************************************************************************
 *	OaBuildVersion				(TYPELIB.15)
 *
Jon Griffiths's avatar
Jon Griffiths committed
145
 * Get the Ole Automation build version.
146
 *
Jon Griffiths's avatar
Jon Griffiths committed
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
 * PARAMS
 *  None
 *
 * RETURNS
 *  The build version.
 *
 * NOTES
 *  Known typelib.dll versions:
 *| OLE Ver.  Comments                   Date    Build Ver.
 *| --------  -------------------------  ----    ---------
 *| OLE 2.01  Call not available         1993     N/A
 *| OLE 2.02                             1993-94  02 3002
 *| OLE 2.03                                      23 730
 *| OLE 2.03                                      03 3025
 *| OLE 2.03  W98 SE orig. file !!       1993-95  10 3024
 *| OLE 2.1   NT                         1993-95  ?? ???
 *| OLE 2.3.1 W95                                 23 700
 *| OLE2 4.0  NT4SP6                     1993-98  40 4277
165 166 167
 *| OLE 2.1   W2K                        2000     10 3029
 *| OLE 2.1   WXP                        2002     10 3029
 *| OLE 2.1   Vista                      2007     10 3029
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
 */
DWORD WINAPI OaBuildVersion16(void)
{
    /* FIXME: I'd like to return the highest currently known version value
     * in case the user didn't force a --winver, but I don't know how
     * to retrieve the "versionForced" info from misc/version.c :(
     * (this would be useful in other places, too) */
    FIXME("If you get version error messages, please report them\n");
    switch(GetVersion() & 0x8000ffff)  /* mask off build number */
    {
    case 0x80000a03:  /* WIN31 */
		return MAKELONG(3027, 3); /* WfW 3.11 */
    case 0x80000004:  /* WIN95 */
		return MAKELONG(700, 23); /* Win95A */
    case 0x80000a04:  /* WIN98 */
		return MAKELONG(3024, 10); /* W98 SE */
    case 0x00000004:  /* NT4 */
		return MAKELONG(4277, 40); /* NT4 SP6 */
186 187 188 189 190 191
    case 0x00000005:  /* W2K */
		return MAKELONG(3029, 10); /* W2K SP4 */
    case 0x00000105:  /* WXP */
		return MAKELONG(3029, 10); /* WXP SP2 */
    case 0x00000006:  /* Vista */
		return MAKELONG(3029, 10); /* Vista */
192 193 194 195 196
    default:
	FIXME("Version value not known yet. Please investigate it!\n");
		return 0;
    }
}