1 | /*
|
---|
2 | * file type mapping
|
---|
3 | * (HKEY_CLASSES_ROOT - Stuff)
|
---|
4 | *
|
---|
5 | *
|
---|
6 | */
|
---|
7 | #include <stdlib.h>
|
---|
8 | #include <string.h>
|
---|
9 | #include <odin.h>
|
---|
10 |
|
---|
11 | #define ICOM_CINTERFACE 1
|
---|
12 | #define CINTERFACE 1
|
---|
13 |
|
---|
14 | #include "debugtools.h"
|
---|
15 | #include "winerror.h"
|
---|
16 | #include "winreg.h"
|
---|
17 |
|
---|
18 | #include "shlobj.h"
|
---|
19 | #include "shell32_main.h"
|
---|
20 | #include "shlguid.h"
|
---|
21 | #include "shresdef.h"
|
---|
22 |
|
---|
23 | #include <misc.h>
|
---|
24 |
|
---|
25 | DEFAULT_DEBUG_CHANNEL(shell)
|
---|
26 |
|
---|
27 | #define MAX_EXTENSION_LENGTH 20
|
---|
28 |
|
---|
29 | BOOL HCR_MapTypeToValue ( LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL bPrependDot)
|
---|
30 | { HKEY hkey;
|
---|
31 | char szTemp[MAX_EXTENSION_LENGTH + 2];
|
---|
32 |
|
---|
33 | TRACE("%s %p\n",szExtension, szFileType );
|
---|
34 |
|
---|
35 | if (bPrependDot)
|
---|
36 | strcpy(szTemp, ".");
|
---|
37 |
|
---|
38 | lstrcpynA(szTemp+((bPrependDot)?1:0), szExtension, MAX_EXTENSION_LENGTH);
|
---|
39 |
|
---|
40 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,szTemp,0,0x02000000,&hkey))
|
---|
41 | { return FALSE;
|
---|
42 | }
|
---|
43 |
|
---|
44 | if (RegQueryValueA(hkey,NULL,szFileType,&len))
|
---|
45 | { RegCloseKey(hkey);
|
---|
46 | return FALSE;
|
---|
47 | }
|
---|
48 |
|
---|
49 | RegCloseKey(hkey);
|
---|
50 |
|
---|
51 | TRACE("-- %s\n", szFileType );
|
---|
52 |
|
---|
53 | return TRUE;
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | BOOL HCR_GetExecuteCommand ( LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, LONG len )
|
---|
58 | { HKEY hkey;
|
---|
59 | char sTemp[256];
|
---|
60 |
|
---|
61 | TRACE("%s %s\n",szClass, szVerb );
|
---|
62 |
|
---|
63 | sprintf(sTemp, "%s\\shell\\%s\\command",szClass, szVerb);
|
---|
64 |
|
---|
65 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
|
---|
66 | { return FALSE;
|
---|
67 | }
|
---|
68 |
|
---|
69 | if (RegQueryValueA(hkey,NULL,szDest,&len))
|
---|
70 | { RegCloseKey(hkey);
|
---|
71 | return FALSE;
|
---|
72 | }
|
---|
73 | RegCloseKey(hkey);
|
---|
74 |
|
---|
75 | TRACE("-- %s\n", szDest );
|
---|
76 |
|
---|
77 | return TRUE;
|
---|
78 |
|
---|
79 | }
|
---|
80 | /***************************************************************************************
|
---|
81 | * HCR_GetDefaultIcon [internal]
|
---|
82 | *
|
---|
83 | * Gets the icon for a filetype
|
---|
84 | */
|
---|
85 | BOOL HCR_GetDefaultIcon (LPCSTR szClass, LPSTR szDest, LONG len, LPDWORD dwNr)
|
---|
86 | { HKEY hkey;
|
---|
87 | char sTemp[256];
|
---|
88 | char sNum[5];
|
---|
89 |
|
---|
90 | TRACE("%s\n",szClass );
|
---|
91 |
|
---|
92 | sprintf(sTemp, "%s\\DefaultIcon",szClass);
|
---|
93 |
|
---|
94 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
|
---|
95 | { return FALSE;
|
---|
96 | }
|
---|
97 |
|
---|
98 | if (RegQueryValueA(hkey,NULL,szDest,&len))
|
---|
99 | { RegCloseKey(hkey);
|
---|
100 | return FALSE;
|
---|
101 | }
|
---|
102 |
|
---|
103 | RegCloseKey(hkey);
|
---|
104 |
|
---|
105 | if (ParseFieldA (szDest, 2, sNum, 5))
|
---|
106 | { *dwNr=atoi(sNum);
|
---|
107 | }
|
---|
108 |
|
---|
109 | ParseFieldA (szDest, 1, szDest, len);
|
---|
110 |
|
---|
111 | TRACE("-- %s %li\n", szDest, *dwNr );
|
---|
112 |
|
---|
113 | return TRUE;
|
---|
114 | }
|
---|
115 |
|
---|
116 | /***************************************************************************************
|
---|
117 | * HCR_GetClassName [internal]
|
---|
118 | *
|
---|
119 | * Gets the name of a registred class
|
---|
120 | */
|
---|
121 | BOOL HCR_GetClassName (REFIID riid, LPSTR szDest, DWORD len)
|
---|
122 | { HKEY hkey;
|
---|
123 | char xriid[50];
|
---|
124 | BOOL ret = FALSE;
|
---|
125 | DWORD buflen = len;
|
---|
126 |
|
---|
127 | strcpy(xriid,"CLSID\\");
|
---|
128 | WINE_StringFromCLSID(riid,&xriid[strlen(xriid)]);
|
---|
129 |
|
---|
130 | TRACE("%s\n",xriid );
|
---|
131 |
|
---|
132 | if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
|
---|
133 | {
|
---|
134 | if (!RegQueryValueExA(hkey,"",0,NULL,(LPBYTE)szDest,&len))
|
---|
135 | {
|
---|
136 | ret = TRUE;
|
---|
137 | }
|
---|
138 | RegCloseKey(hkey);
|
---|
139 | }
|
---|
140 |
|
---|
141 | if (!ret || !szDest[0])
|
---|
142 | {
|
---|
143 | if(IsEqualIID(riid, &CLSID_ShellDesktop))
|
---|
144 | {
|
---|
145 | LoadStringA(shell32_hInstance, IDS_DESKTOP, szDest, buflen);
|
---|
146 | ret = TRUE;
|
---|
147 | }
|
---|
148 | else if (IsEqualIID(riid, &IID_MyComputer))
|
---|
149 | {
|
---|
150 | LoadStringA(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen);
|
---|
151 | ret = TRUE;
|
---|
152 | }
|
---|
153 | }
|
---|
154 |
|
---|
155 | TRACE("-- %s\n", szDest);
|
---|
156 |
|
---|
157 | return ret;
|
---|
158 | }
|
---|
159 |
|
---|
160 | /***************************************************************************************
|
---|
161 | * HCR_GetFolderAttributes [internal]
|
---|
162 | *
|
---|
163 | * gets the folder attributes of a class
|
---|
164 | */
|
---|
165 | BOOL HCR_GetFolderAttributes (REFIID riid, LPDWORD szDest)
|
---|
166 | { HKEY hkey;
|
---|
167 | char xriid[60];
|
---|
168 | DWORD attributes;
|
---|
169 | DWORD len = 4;
|
---|
170 |
|
---|
171 | strcpy(xriid,"CLSID\\");
|
---|
172 | WINE_StringFromCLSID(riid,&xriid[strlen(xriid)]);
|
---|
173 | TRACE("%s\n",xriid );
|
---|
174 |
|
---|
175 | strcat (xriid, "\\ShellFolder");
|
---|
176 |
|
---|
177 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
|
---|
178 | {
|
---|
179 | return FALSE;
|
---|
180 | }
|
---|
181 |
|
---|
182 | if (RegQueryValueExA(hkey,"Attributes",0,NULL,(LPBYTE)&attributes,&len))
|
---|
183 | {
|
---|
184 | RegCloseKey(hkey);
|
---|
185 | return FALSE;
|
---|
186 | }
|
---|
187 |
|
---|
188 | RegCloseKey(hkey);
|
---|
189 |
|
---|
190 | TRACE("-- 0x%08lx\n", attributes);
|
---|
191 |
|
---|
192 | *szDest = attributes;
|
---|
193 |
|
---|
194 | return TRUE;
|
---|
195 | }
|
---|
196 |
|
---|