| 1 | /* $Id: classes.cpp,v 1.2 1999-11-02 18:50:15 phaller Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Win32 SHELL32 for OS/2
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1997 Marcus Meissner
|
|---|
| 7 | * Copyright 1999 Patrick Haller (haller@zebra.fh-weingarten.de)
|
|---|
| 8 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 9 | *
|
|---|
| 10 | */
|
|---|
| 11 |
|
|---|
| 12 | /*
|
|---|
| 13 | * file type mapping
|
|---|
| 14 | * (HKEY_CLASSES_ROOT - Stuff)
|
|---|
| 15 | */
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 | /*****************************************************************************
|
|---|
| 19 | * Includes *
|
|---|
| 20 | *****************************************************************************/
|
|---|
| 21 |
|
|---|
| 22 | #include <stdlib.h>
|
|---|
| 23 | #include <string.h>
|
|---|
| 24 | #include <odin.h>
|
|---|
| 25 | #include <odinwrap.h>
|
|---|
| 26 | #include <os2sel.h>
|
|---|
| 27 |
|
|---|
| 28 | #define ICOM_CINTERFACE 1
|
|---|
| 29 | #define CINTERFACE 1
|
|---|
| 30 |
|
|---|
| 31 | #include "debugtools.h"
|
|---|
| 32 | #include "winerror.h"
|
|---|
| 33 | #include "winreg.h"
|
|---|
| 34 |
|
|---|
| 35 | #include "shlobj.h"
|
|---|
| 36 | #include "shell32_main.h"
|
|---|
| 37 | #include "shlguid.h"
|
|---|
| 38 | #include "shresdef.h"
|
|---|
| 39 |
|
|---|
| 40 | #include <misc.h>
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | /*****************************************************************************
|
|---|
| 44 | * Local Variables *
|
|---|
| 45 | *****************************************************************************/
|
|---|
| 46 |
|
|---|
| 47 | ODINDEBUGCHANNEL(shell32-classes)
|
|---|
| 48 |
|
|---|
| 49 | #define MAX_EXTENSION_LENGTH 20
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 | /*****************************************************************************
|
|---|
| 53 | * Implementation *
|
|---|
| 54 | *****************************************************************************/
|
|---|
| 55 |
|
|---|
| 56 | BOOL HCR_MapTypeToValue ( LPCSTR szExtension, LPSTR szFileType, DWORD len, BOOL bPrependDot)
|
|---|
| 57 | {
|
|---|
| 58 | HKEY hkey;
|
|---|
| 59 | char szTemp[MAX_EXTENSION_LENGTH + 2];
|
|---|
| 60 |
|
|---|
| 61 | dprintf(("SHELL32:classes:HCR_MapTypeToValue(%s,%08xh,%08xh,%08xh)\n",
|
|---|
| 62 | szExtension,
|
|---|
| 63 | szFileType,
|
|---|
| 64 | len,
|
|---|
| 65 | bPrependDot));
|
|---|
| 66 |
|
|---|
| 67 | if (bPrependDot)
|
|---|
| 68 | strcpy(szTemp, ".");
|
|---|
| 69 |
|
|---|
| 70 | lstrcpynA(szTemp+((bPrependDot)?1:0), szExtension, MAX_EXTENSION_LENGTH);
|
|---|
| 71 |
|
|---|
| 72 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,szTemp,0,0x02000000,&hkey))
|
|---|
| 73 | { return FALSE;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | if (RegQueryValueA(hkey,NULL,szFileType,(LPLONG)&len))
|
|---|
| 77 | { RegCloseKey(hkey);
|
|---|
| 78 | return FALSE;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | RegCloseKey(hkey);
|
|---|
| 82 |
|
|---|
| 83 | TRACE("-- %s\n", szFileType );
|
|---|
| 84 |
|
|---|
| 85 | return TRUE;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | BOOL HCR_GetExecuteCommand ( LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len )
|
|---|
| 89 | {
|
|---|
| 90 | HKEY hkey;
|
|---|
| 91 | char sTemp[256];
|
|---|
| 92 |
|
|---|
| 93 | dprintf(("SHELL32:classes:HCR_GetExecuteCommand(%s,%s,%08xh,%08xh)\n",
|
|---|
| 94 | szClass,
|
|---|
| 95 | szVerb,
|
|---|
| 96 | szDest,
|
|---|
| 97 | len));
|
|---|
| 98 |
|
|---|
| 99 | sprintf(sTemp, "%s\\shell\\%s\\command",szClass, szVerb);
|
|---|
| 100 |
|
|---|
| 101 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
|
|---|
| 102 | { return FALSE;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | if (RegQueryValueA(hkey,NULL,szDest,(LPLONG)&len))
|
|---|
| 106 | { RegCloseKey(hkey);
|
|---|
| 107 | return FALSE;
|
|---|
| 108 | }
|
|---|
| 109 | RegCloseKey(hkey);
|
|---|
| 110 |
|
|---|
| 111 | TRACE("-- %s\n", szDest );
|
|---|
| 112 |
|
|---|
| 113 | return TRUE;
|
|---|
| 114 |
|
|---|
| 115 | }
|
|---|
| 116 | /***************************************************************************************
|
|---|
| 117 | * HCR_GetDefaultIcon [internal]
|
|---|
| 118 | *
|
|---|
| 119 | * Gets the icon for a filetype
|
|---|
| 120 | */
|
|---|
| 121 | BOOL HCR_GetDefaultIcon (LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr)
|
|---|
| 122 | {
|
|---|
| 123 | HKEY hkey;
|
|---|
| 124 | char sTemp[256];
|
|---|
| 125 | char sNum[5];
|
|---|
| 126 |
|
|---|
| 127 | dprintf(("SHELL32:classes:HCR_GetDefaultIcon(%s,%08xh,%08xh,%08xh)\n",
|
|---|
| 128 | szClass,
|
|---|
| 129 | szDest,
|
|---|
| 130 | len,
|
|---|
| 131 | dwNr));
|
|---|
| 132 |
|
|---|
| 133 | sprintf(sTemp, "%s\\DefaultIcon",szClass);
|
|---|
| 134 |
|
|---|
| 135 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
|
|---|
| 136 | { return FALSE;
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | if (RegQueryValueA(hkey,NULL,szDest,(LPLONG)&len))
|
|---|
| 140 | { RegCloseKey(hkey);
|
|---|
| 141 | return FALSE;
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | RegCloseKey(hkey);
|
|---|
| 145 |
|
|---|
| 146 | if (ParseFieldA (szDest, 2, sNum, 5))
|
|---|
| 147 | { *dwNr=atoi(sNum);
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | ParseFieldA (szDest, 1, szDest, len);
|
|---|
| 151 |
|
|---|
| 152 | TRACE("-- %s %li\n", szDest, *dwNr );
|
|---|
| 153 |
|
|---|
| 154 | return TRUE;
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | /***************************************************************************************
|
|---|
| 158 | * HCR_GetClassName [internal]
|
|---|
| 159 | *
|
|---|
| 160 | * Gets the name of a registred class
|
|---|
| 161 | */
|
|---|
| 162 | BOOL HCR_GetClassName (REFIID riid, LPSTR szDest, DWORD len)
|
|---|
| 163 | {
|
|---|
| 164 | HKEY hkey;
|
|---|
| 165 | char xriid[50];
|
|---|
| 166 | BOOL ret = FALSE;
|
|---|
| 167 | DWORD buflen = len;
|
|---|
| 168 |
|
|---|
| 169 | dprintf(("SHELL32:classes:HCR_GetClassName(%08xh,%08xh,%08xh)\n",
|
|---|
| 170 | riid,
|
|---|
| 171 | szDest,
|
|---|
| 172 | len));
|
|---|
| 173 |
|
|---|
| 174 | strcpy(xriid,"CLSID\\");
|
|---|
| 175 | WINE_StringFromCLSID(riid,&xriid[strlen(xriid)]);
|
|---|
| 176 |
|
|---|
| 177 | TRACE("%s\n",xriid );
|
|---|
| 178 |
|
|---|
| 179 | if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
|
|---|
| 180 | {
|
|---|
| 181 | if (!RegQueryValueExA(hkey,"",0,NULL,(LPBYTE)szDest,&len))
|
|---|
| 182 | {
|
|---|
| 183 | ret = TRUE;
|
|---|
| 184 | }
|
|---|
| 185 | RegCloseKey(hkey);
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | if (!ret || !szDest[0])
|
|---|
| 189 | {
|
|---|
| 190 | if(IsEqualIID(riid, &CLSID_ShellDesktop))
|
|---|
| 191 | {
|
|---|
| 192 | LoadStringA(shell32_hInstance, IDS_DESKTOP, szDest, buflen);
|
|---|
| 193 | ret = TRUE;
|
|---|
| 194 | }
|
|---|
| 195 | else if (IsEqualIID(riid, &IID_MyComputer))
|
|---|
| 196 | {
|
|---|
| 197 | LoadStringA(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen);
|
|---|
| 198 | ret = TRUE;
|
|---|
| 199 | }
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | TRACE("-- %s\n", szDest);
|
|---|
| 203 |
|
|---|
| 204 | return ret;
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | /***************************************************************************************
|
|---|
| 208 | * HCR_GetFolderAttributes [internal]
|
|---|
| 209 | *
|
|---|
| 210 | * gets the folder attributes of a class
|
|---|
| 211 | */
|
|---|
| 212 | BOOL HCR_GetFolderAttributes (REFIID riid, LPDWORD szDest)
|
|---|
| 213 | {
|
|---|
| 214 | HKEY hkey;
|
|---|
| 215 | char xriid[60];
|
|---|
| 216 | DWORD attributes;
|
|---|
| 217 | DWORD len = 4;
|
|---|
| 218 |
|
|---|
| 219 | dprintf(("SHELL32:classes:HCR_GetFolderAttributes(%08xh,%08xh)\n",
|
|---|
| 220 | riid,
|
|---|
| 221 | szDest));
|
|---|
| 222 |
|
|---|
| 223 | strcpy(xriid,"CLSID\\");
|
|---|
| 224 | WINE_StringFromCLSID(riid,&xriid[strlen(xriid)]);
|
|---|
| 225 | TRACE("%s\n",xriid );
|
|---|
| 226 |
|
|---|
| 227 | strcat (xriid, "\\ShellFolder");
|
|---|
| 228 |
|
|---|
| 229 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
|
|---|
| 230 | {
|
|---|
| 231 | return FALSE;
|
|---|
| 232 | }
|
|---|
| 233 |
|
|---|
| 234 | if (RegQueryValueExA(hkey,"Attributes",0,NULL,(LPBYTE)&attributes,&len))
|
|---|
| 235 | {
|
|---|
| 236 | RegCloseKey(hkey);
|
|---|
| 237 | return FALSE;
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | RegCloseKey(hkey);
|
|---|
| 241 |
|
|---|
| 242 | TRACE("-- 0x%08lx\n", attributes);
|
|---|
| 243 |
|
|---|
| 244 | *szDest = attributes;
|
|---|
| 245 |
|
|---|
| 246 | return TRUE;
|
|---|
| 247 | }
|
|---|
| 248 |
|
|---|