2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #define NONAMELESSUNION
32 #include "wine/debug.h"
36 #include "wine/unicode.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
45 * This module will be all the helper functions for registry access by the
48 static const WCHAR szUserFeatures_fmt
[] = {
49 'S','o','f','t','w','a','r','e','\\',
50 'M','i','c','r','o','s','o','f','t','\\',
51 'I','n','s','t','a','l','l','e','r','\\',
52 'F','e','a','t','u','r','e','s','\\',
55 static const WCHAR szUserDataFeatures_fmt
[] = {
56 'S','o','f','t','w','a','r','e','\\',
57 'M','i','c','r','o','s','o','f','t','\\',
58 'W','i','n','d','o','w','s','\\',
59 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
60 'I','n','s','t','a','l','l','e','r','\\',
61 'U','s','e','r','D','a','t','a','\\',
62 '%','s','\\','P','r','o','d','u','c','t','s','\\',
63 '%','s','\\','F','e','a','t','u','r','e','s',0};
65 static const WCHAR szInstaller_Features_fmt
[] = {
66 'S','o','f','t','w','a','r','e','\\',
67 'M','i','c','r','o','s','o','f','t','\\',
68 'W','i','n','d','o','w','s','\\',
69 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
70 'I','n','s','t','a','l','l','e','r','\\',
71 'F','e','a','t','u','r','e','s','\\',
74 static const WCHAR szInstaller_Components
[] = {
75 'S','o','f','t','w','a','r','e','\\',
76 'M','i','c','r','o','s','o','f','t','\\',
77 'W','i','n','d','o','w','s','\\',
78 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
79 'I','n','s','t','a','l','l','e','r','\\',
80 'C','o','m','p','o','n','e','n','t','s',0 };
82 static const WCHAR szUser_Components_fmt
[] = {
83 'S','o','f','t','w','a','r','e','\\',
84 'M','i','c','r','o','s','o','f','t','\\',
85 'I','n','s','t','a','l','l','e','r','\\',
86 'C','o','m','p','o','n','e','n','t','s','\\',
89 static const WCHAR szUserDataComp_fmt
[] = {
90 'S','o','f','t','w','a','r','e','\\',
91 'M','i','c','r','o','s','o','f','t','\\',
92 'W','i','n','d','o','w','s','\\',
93 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
94 'I','n','s','t','a','l','l','e','r','\\',
95 'U','s','e','r','D','a','t','a','\\',
96 '%','s','\\','C','o','m','p','o','n','e','n','t','s','\\','%','s',0};
98 static const WCHAR szUninstall_fmt
[] = {
99 'S','o','f','t','w','a','r','e','\\',
100 'M','i','c','r','o','s','o','f','t','\\',
101 'W','i','n','d','o','w','s','\\',
102 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
103 'U','n','i','n','s','t','a','l','l','\\',
106 static const WCHAR szUserProduct_fmt
[] = {
107 'S','o','f','t','w','a','r','e','\\',
108 'M','i','c','r','o','s','o','f','t','\\',
109 'I','n','s','t','a','l','l','e','r','\\',
110 'P','r','o','d','u','c','t','s','\\',
113 static const WCHAR szUserPatch_fmt
[] = {
114 'S','o','f','t','w','a','r','e','\\',
115 'M','i','c','r','o','s','o','f','t','\\',
116 'I','n','s','t','a','l','l','e','r','\\',
117 'P','a','t','c','h','e','s','\\',
120 static const WCHAR szInstaller_Products
[] = {
121 'S','o','f','t','w','a','r','e','\\',
122 'M','i','c','r','o','s','o','f','t','\\',
123 'W','i','n','d','o','w','s','\\',
124 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
125 'I','n','s','t','a','l','l','e','r','\\',
126 'P','r','o','d','u','c','t','s',0};
128 static const WCHAR szInstaller_Products_fmt
[] = {
129 'S','o','f','t','w','a','r','e','\\',
130 'M','i','c','r','o','s','o','f','t','\\',
131 'W','i','n','d','o','w','s','\\',
132 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
133 'I','n','s','t','a','l','l','e','r','\\',
134 'P','r','o','d','u','c','t','s','\\',
137 static const WCHAR szInstaller_Patches_fmt
[] = {
138 'S','o','f','t','w','a','r','e','\\',
139 'M','i','c','r','o','s','o','f','t','\\',
140 'W','i','n','d','o','w','s','\\',
141 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
142 'I','n','s','t','a','l','l','e','r','\\',
143 'P','a','t','c','h','e','s','\\',
146 static const WCHAR szInstaller_UpgradeCodes_fmt
[] = {
147 'S','o','f','t','w','a','r','e','\\',
148 'M','i','c','r','o','s','o','f','t','\\',
149 'W','i','n','d','o','w','s','\\',
150 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
151 'I','n','s','t','a','l','l','e','r','\\',
152 'U','p','g','r','a','d','e','C','o','d','e','s','\\',
155 static const WCHAR szInstaller_UserUpgradeCodes_fmt
[] = {
156 'S','o','f','t','w','a','r','e','\\',
157 'M','i','c','r','o','s','o','f','t','\\',
158 'I','n','s','t','a','l','l','e','r','\\',
159 'U','p','g','r','a','d','e','C','o','d','e','s','\\',
162 static const WCHAR szUserDataProd_fmt
[] = {
163 'S','o','f','t','w','a','r','e','\\',
164 'M','i','c','r','o','s','o','f','t','\\',
165 'W','i','n','d','o','w','s','\\',
166 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
167 'I','n','s','t','a','l','l','e','r','\\',
168 'U','s','e','r','D','a','t','a','\\',
169 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s',0};
171 static const WCHAR szInstallProperties_fmt
[] = {
172 'S','o','f','t','w','a','r','e','\\',
173 'M','i','c','r','o','s','o','f','t','\\',
174 'W','i','n','d','o','w','s','\\',
175 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
176 'I','n','s','t','a','l','l','e','r','\\',
177 'U','s','e','r','D','a','t','a','\\',
178 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s','\\',
179 'I','n','s','t','a','l','l','P','r','o','p','e','r','t','i','e','s',0};
181 static const WCHAR szInstaller_LocalSystemProductCodes_fmt
[] = {
182 'S','o','f','t','w','a','r','e','\\',
183 'M','i','c','r','o','s','o','f','t','\\',
184 'W','i','n','d','o','w','s','\\',
185 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
186 'I','n','s','t','a','l','l','e','r','\\',
187 'U','s','e','r','D','a','t','a','\\',
188 'S','-','1','-','5','-','1','8','\\','P','r','o','d','u','c','t','s','\\',
189 '%','s','\\','I','n','s','t','a','l','l','P','r','o','p','e','r','t','i','e','s',0};
191 static const WCHAR szInstaller_LocalSystemComponent_fmt
[] = {
192 'S','o','f','t','w','a','r','e','\\',
193 'M','i','c','r','o','s','o','f','t','\\',
194 'W','i','n','d','o','w','s','\\',
195 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
196 'I','n','s','t','a','l','l','e','r','\\',
197 'U','s','e','r','D','a','t','a','\\',
198 'S','-','1','-','5','-','1','8','\\',
199 'C','o','m','p','o','n','e','n','t','s','\\','%','s',0};
201 static const WCHAR szInstaller_LocalClassesProd_fmt
[] = {
202 'S','o','f','t','w','a','r','e','\\',
203 'C','l','a','s','s','e','s','\\',
204 'I','n','s','t','a','l','l','e','r','\\',
205 'P','r','o','d','u','c','t','s','\\','%','s',0};
207 static const WCHAR szInstaller_LocalManagedProd_fmt
[] = {
208 'S','o','f','t','w','a','r','e','\\',
209 'M','i','c','r','o','s','o','f','t','\\',
210 'W','i','n','d','o','w','s','\\',
211 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
212 'I','n','s','t','a','l','l','e','r','\\',
213 'M','a','n','a','g','e','d','\\','%','s','\\',
214 'I','n','s','t','a','l','l','e','r','\\',
215 'P','r','o','d','u','c','t','s','\\','%','s',0};
217 BOOL
unsquash_guid(LPCWSTR in
, LPWSTR out
)
233 out
[n
++] = in
[17+i
*2];
234 out
[n
++] = in
[16+i
*2];
239 out
[n
++] = in
[17+i
*2];
240 out
[n
++] = in
[16+i
*2];
247 BOOL
squash_guid(LPCWSTR in
, LPWSTR out
)
254 if (FAILED(CLSIDFromString((LPOLESTR
)in
, &guid
)))
268 out
[17+i
*2] = in
[n
++];
269 out
[16+i
*2] = in
[n
++];
274 out
[17+i
*2] = in
[n
++];
275 out
[16+i
*2] = in
[n
++];
282 /* tables for encoding and decoding base85 */
283 static const unsigned char table_dec85
[0x80] = {
284 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
285 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
286 0xff,0x00,0xff,0xff,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0xff,
287 0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0xff,0xff,0xff,0x16,0xff,0x17,
288 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,
289 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0xff,0x34,0x35,0x36,
290 0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43,0x44,0x45,0x46,
291 0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0xff,0x53,0x54,0xff,
294 static const char table_enc85
[] =
295 "!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
296 "PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
300 * Converts a base85 encoded guid into a GUID pointer
301 * Base85 encoded GUIDs should be 20 characters long.
303 * returns TRUE if successful, FALSE if not
305 BOOL
decode_base85_guid( LPCWSTR str
, GUID
*guid
)
307 DWORD i
, val
= 0, base
= 1, *p
;
313 for( i
=0; i
<20; i
++ )
320 val
+= table_dec85
[str
[i
]] * base
;
323 if( table_dec85
[str
[i
]] == 0xff )
333 * Encodes a base85 guid given a GUID pointer
334 * Caller should provide a 21 character buffer for the encoded string.
336 * returns TRUE if successful, FALSE if not
338 BOOL
encode_base85_guid( GUID
*guid
, LPWSTR str
)
340 unsigned int x
, *p
, i
;
342 p
= (unsigned int*) guid
;
346 *str
++ = table_enc85
[x
%85];
348 *str
++ = table_enc85
[x
%85];
350 *str
++ = table_enc85
[x
%85];
352 *str
++ = table_enc85
[x
%85];
354 *str
++ = table_enc85
[x
%85];
361 DWORD
msi_version_str_to_dword(LPCWSTR p
)
363 DWORD major
, minor
= 0, build
= 0, version
= 0;
374 p
= strchrW(p
+1, '.');
379 return MAKELONG(build
, MAKEWORD(minor
, major
));
382 LPWSTR
msi_version_dword_to_str(DWORD version
)
384 const WCHAR fmt
[] = { '%','u','.','%','u','.','%','u',0 };
385 LPWSTR str
= msi_alloc(20);
387 (version
&0xff000000)>>24,
388 (version
&0x00ff0000)>>16,
393 LONG
msi_reg_set_val_str( HKEY hkey
, LPCWSTR name
, LPCWSTR value
)
395 DWORD len
= value
? (lstrlenW(value
) + 1) * sizeof (WCHAR
) : 0;
396 return RegSetValueExW( hkey
, name
, 0, REG_SZ
, (const BYTE
*)value
, len
);
399 LONG
msi_reg_set_val_multi_str( HKEY hkey
, LPCWSTR name
, LPCWSTR value
)
402 while (*p
) p
+= lstrlenW(p
) + 1;
403 return RegSetValueExW( hkey
, name
, 0, REG_MULTI_SZ
,
404 (const BYTE
*)value
, (p
+ 1 - value
) * sizeof(WCHAR
) );
407 LONG
msi_reg_set_val_dword( HKEY hkey
, LPCWSTR name
, DWORD val
)
409 return RegSetValueExW( hkey
, name
, 0, REG_DWORD
, (LPBYTE
)&val
, sizeof (DWORD
) );
412 LONG
msi_reg_set_subkey_val( HKEY hkey
, LPCWSTR path
, LPCWSTR name
, LPCWSTR val
)
417 r
= RegCreateKeyW( hkey
, path
, &hsubkey
);
418 if (r
!= ERROR_SUCCESS
)
420 r
= msi_reg_set_val_str( hsubkey
, name
, val
);
421 RegCloseKey( hsubkey
);
425 LPWSTR
msi_reg_get_val_str( HKEY hkey
, LPCWSTR name
)
431 r
= RegQueryValueExW(hkey
, name
, NULL
, NULL
, NULL
, &len
);
432 if (r
!= ERROR_SUCCESS
)
435 len
+= sizeof (WCHAR
);
436 val
= msi_alloc( len
);
440 RegQueryValueExW(hkey
, name
, NULL
, NULL
, (LPBYTE
) val
, &len
);
444 BOOL
msi_reg_get_val_dword( HKEY hkey
, LPCWSTR name
, DWORD
*val
)
446 DWORD type
, len
= sizeof (DWORD
);
447 LONG r
= RegQueryValueExW(hkey
, name
, NULL
, &type
, (LPBYTE
) val
, &len
);
448 return r
== ERROR_SUCCESS
&& type
== REG_DWORD
;
451 static UINT
get_user_sid(LPWSTR
*usersid
)
458 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
))
459 return ERROR_FUNCTION_FAILED
;
462 if (!GetTokenInformation(token
, TokenUser
, (void *)buf
, size
, &size
)) {
464 return ERROR_FUNCTION_FAILED
;
467 user
= (PTOKEN_USER
)buf
;
468 if (!ConvertSidToStringSidW(user
->User
.Sid
, usersid
)) {
470 return ERROR_FUNCTION_FAILED
;
473 return ERROR_SUCCESS
;
476 UINT
MSIREG_OpenUninstallKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
)
479 WCHAR keypath
[0x200];
480 TRACE("%s\n",debugstr_w(szProduct
));
482 sprintfW(keypath
,szUninstall_fmt
,szProduct
);
485 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
487 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
492 UINT
MSIREG_DeleteUninstallKey(LPCWSTR szProduct
)
494 WCHAR keypath
[0x200];
495 TRACE("%s\n",debugstr_w(szProduct
));
497 sprintfW(keypath
,szUninstall_fmt
,szProduct
);
499 return RegDeleteTreeW(HKEY_LOCAL_MACHINE
, keypath
);
502 UINT
MSIREG_OpenUserProductsKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
)
505 WCHAR squished_pc
[GUID_SIZE
];
506 WCHAR keypath
[0x200];
508 TRACE("%s\n",debugstr_w(szProduct
));
509 if (!squash_guid(szProduct
,squished_pc
))
510 return ERROR_FUNCTION_FAILED
;
511 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
513 sprintfW(keypath
,szUserProduct_fmt
,squished_pc
);
516 rc
= RegCreateKeyW(HKEY_CURRENT_USER
,keypath
,key
);
518 rc
= RegOpenKeyW(HKEY_CURRENT_USER
,keypath
,key
);
523 UINT
MSIREG_DeleteUserProductKey(LPCWSTR szProduct
)
525 WCHAR squished_pc
[GUID_SIZE
];
526 WCHAR keypath
[0x200];
528 TRACE("%s\n",debugstr_w(szProduct
));
529 if (!squash_guid(szProduct
,squished_pc
))
530 return ERROR_FUNCTION_FAILED
;
531 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
533 sprintfW(keypath
,szUserProduct_fmt
,squished_pc
);
535 return RegDeleteTreeW(HKEY_CURRENT_USER
, keypath
);
538 UINT
MSIREG_OpenUserPatchesKey(LPCWSTR szPatch
, HKEY
* key
, BOOL create
)
541 WCHAR squished_pc
[GUID_SIZE
];
542 WCHAR keypath
[0x200];
544 TRACE("%s\n",debugstr_w(szPatch
));
545 if (!squash_guid(szPatch
,squished_pc
))
546 return ERROR_FUNCTION_FAILED
;
547 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
549 sprintfW(keypath
,szUserPatch_fmt
,squished_pc
);
552 rc
= RegCreateKeyW(HKEY_CURRENT_USER
,keypath
,key
);
554 rc
= RegOpenKeyW(HKEY_CURRENT_USER
,keypath
,key
);
559 UINT
MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
)
562 WCHAR squished_pc
[GUID_SIZE
];
563 WCHAR keypath
[0x200];
565 TRACE("%s\n",debugstr_w(szProduct
));
566 if (!squash_guid(szProduct
,squished_pc
))
567 return ERROR_FUNCTION_FAILED
;
568 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
570 sprintfW(keypath
,szUserFeatures_fmt
,squished_pc
);
573 rc
= RegCreateKeyW(HKEY_CURRENT_USER
,keypath
,key
);
575 rc
= RegOpenKeyW(HKEY_CURRENT_USER
,keypath
,key
);
580 UINT
MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct
)
582 WCHAR squished_pc
[GUID_SIZE
];
583 WCHAR keypath
[0x200];
585 TRACE("%s\n",debugstr_w(szProduct
));
586 if (!squash_guid(szProduct
,squished_pc
))
587 return ERROR_FUNCTION_FAILED
;
588 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
590 sprintfW(keypath
,szUserFeatures_fmt
,squished_pc
);
591 return RegDeleteTreeW(HKEY_CURRENT_USER
, keypath
);
594 UINT
MSIREG_OpenFeaturesKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
)
597 WCHAR squished_pc
[GUID_SIZE
];
598 WCHAR keypath
[0x200];
600 TRACE("%s\n",debugstr_w(szProduct
));
601 if (!squash_guid(szProduct
,squished_pc
))
602 return ERROR_FUNCTION_FAILED
;
603 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
605 sprintfW(keypath
,szInstaller_Features_fmt
,squished_pc
);
608 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
610 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
615 UINT
MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct
, HKEY
*key
, BOOL create
)
618 WCHAR squished_pc
[GUID_SIZE
];
619 WCHAR keypath
[0x200];
622 TRACE("%s\n", debugstr_w(szProduct
));
623 if (!squash_guid(szProduct
, squished_pc
))
624 return ERROR_FUNCTION_FAILED
;
625 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
627 rc
= get_user_sid(&usersid
);
628 if (rc
!= ERROR_SUCCESS
|| !usersid
)
630 ERR("Failed to retrieve user SID: %d\n", rc
);
634 sprintfW(keypath
, szUserDataFeatures_fmt
, usersid
, squished_pc
);
637 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
639 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
645 UINT
MSIREG_OpenComponents(HKEY
* key
)
647 return RegCreateKeyW(HKEY_LOCAL_MACHINE
,szInstaller_Components
,key
);
650 UINT
MSIREG_OpenUserComponentsKey(LPCWSTR szComponent
, HKEY
* key
, BOOL create
)
653 WCHAR squished_cc
[GUID_SIZE
];
654 WCHAR keypath
[0x200];
656 TRACE("%s\n",debugstr_w(szComponent
));
657 if (!squash_guid(szComponent
,squished_cc
))
658 return ERROR_FUNCTION_FAILED
;
659 TRACE("squished (%s)\n", debugstr_w(squished_cc
));
661 sprintfW(keypath
,szUser_Components_fmt
,squished_cc
);
664 rc
= RegCreateKeyW(HKEY_CURRENT_USER
,keypath
,key
);
666 rc
= RegOpenKeyW(HKEY_CURRENT_USER
,keypath
,key
);
671 UINT
MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent
, HKEY
*key
, BOOL create
)
674 WCHAR comp
[GUID_SIZE
];
675 WCHAR keypath
[0x200];
678 TRACE("%s\n", debugstr_w(szComponent
));
679 if (!squash_guid(szComponent
, comp
))
680 return ERROR_FUNCTION_FAILED
;
681 TRACE("squished (%s)\n", debugstr_w(comp
));
683 rc
= get_user_sid(&usersid
);
684 if (rc
!= ERROR_SUCCESS
|| !usersid
)
686 ERR("Failed to retrieve user SID: %d\n", rc
);
690 sprintfW(keypath
, szUserDataComp_fmt
, usersid
, comp
);
693 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
695 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
701 UINT
MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent
)
704 WCHAR comp
[GUID_SIZE
];
705 WCHAR keypath
[0x200];
708 TRACE("%s\n", debugstr_w(szComponent
));
709 if (!squash_guid(szComponent
, comp
))
710 return ERROR_FUNCTION_FAILED
;
711 TRACE("squished (%s)\n", debugstr_w(comp
));
713 rc
= get_user_sid(&usersid
);
714 if (rc
!= ERROR_SUCCESS
|| !usersid
)
716 ERR("Failed to retrieve user SID: %d\n", rc
);
720 sprintfW(keypath
, szUserDataComp_fmt
, usersid
, comp
);
723 return RegDeleteTreeW(HKEY_LOCAL_MACHINE
, keypath
);
726 UINT
MSIREG_OpenUserDataProductKey(LPCWSTR szProduct
, HKEY
*key
, BOOL create
)
729 WCHAR squished_pc
[GUID_SIZE
];
730 WCHAR keypath
[0x200];
733 TRACE("%s\n", debugstr_w(szProduct
));
734 if (!squash_guid(szProduct
, squished_pc
))
735 return ERROR_FUNCTION_FAILED
;
736 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
738 rc
= get_user_sid(&usersid
);
739 if (rc
!= ERROR_SUCCESS
|| !usersid
)
741 ERR("Failed to retrieve user SID: %d\n", rc
);
745 sprintfW(keypath
, szUserDataProd_fmt
, usersid
, squished_pc
);
748 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
750 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
756 UINT
MSIREG_OpenInstallPropertiesKey(LPCWSTR szProduct
, HKEY
*key
, BOOL create
)
759 WCHAR squished_pc
[GUID_SIZE
];
760 WCHAR keypath
[0x200];
763 TRACE("%s\n", debugstr_w(szProduct
));
764 if (!squash_guid(szProduct
, squished_pc
))
765 return ERROR_FUNCTION_FAILED
;
766 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
768 rc
= get_user_sid(&usersid
);
769 if (rc
!= ERROR_SUCCESS
|| !usersid
)
771 ERR("Failed to retrieve user SID: %d\n", rc
);
775 sprintfW(keypath
, szInstallProperties_fmt
, usersid
, squished_pc
);
778 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
780 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
786 UINT
MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct
)
789 WCHAR squished_pc
[GUID_SIZE
];
790 WCHAR keypath
[0x200];
793 TRACE("%s\n", debugstr_w(szProduct
));
794 if (!squash_guid(szProduct
, squished_pc
))
795 return ERROR_FUNCTION_FAILED
;
796 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
798 rc
= get_user_sid(&usersid
);
799 if (rc
!= ERROR_SUCCESS
|| !usersid
)
801 ERR("Failed to retrieve user SID: %d\n", rc
);
805 sprintfW(keypath
, szUserDataProd_fmt
, usersid
, squished_pc
);
808 return RegDeleteTreeW(HKEY_LOCAL_MACHINE
, keypath
);
811 UINT
MSIREG_OpenProducts(HKEY
* key
)
813 return RegCreateKeyW(HKEY_LOCAL_MACHINE
,szInstaller_Products
,key
);
816 UINT
MSIREG_OpenProductsKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
)
819 WCHAR squished_pc
[GUID_SIZE
];
820 WCHAR keypath
[0x200];
822 TRACE("%s\n",debugstr_w(szProduct
));
823 if (!squash_guid(szProduct
,squished_pc
))
824 return ERROR_FUNCTION_FAILED
;
825 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
827 sprintfW(keypath
,szInstaller_Products_fmt
,squished_pc
);
830 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
832 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
837 UINT
MSIREG_DeleteProductKey(LPCWSTR szProduct
)
839 WCHAR squished_pc
[GUID_SIZE
];
840 WCHAR keypath
[0x200];
842 TRACE("%s\n", debugstr_w(szProduct
));
843 if (!squash_guid(szProduct
, squished_pc
))
844 return ERROR_FUNCTION_FAILED
;
845 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
847 sprintfW(keypath
, szInstaller_Products_fmt
, squished_pc
);
849 return RegDeleteTreeW(HKEY_LOCAL_MACHINE
, keypath
);
852 UINT
MSIREG_OpenPatchesKey(LPCWSTR szPatch
, HKEY
* key
, BOOL create
)
855 WCHAR squished_pc
[GUID_SIZE
];
856 WCHAR keypath
[0x200];
858 TRACE("%s\n",debugstr_w(szPatch
));
859 if (!squash_guid(szPatch
,squished_pc
))
860 return ERROR_FUNCTION_FAILED
;
861 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
863 sprintfW(keypath
,szInstaller_Patches_fmt
,squished_pc
);
866 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
868 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
873 UINT
MSIREG_OpenUpgradeCodesKey(LPCWSTR szUpgradeCode
, HKEY
* key
, BOOL create
)
876 WCHAR squished_pc
[GUID_SIZE
];
877 WCHAR keypath
[0x200];
879 TRACE("%s\n",debugstr_w(szUpgradeCode
));
880 if (!squash_guid(szUpgradeCode
,squished_pc
))
881 return ERROR_FUNCTION_FAILED
;
882 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
884 sprintfW(keypath
,szInstaller_UpgradeCodes_fmt
,squished_pc
);
887 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
889 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
894 UINT
MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szUpgradeCode
, HKEY
* key
, BOOL create
)
897 WCHAR squished_pc
[GUID_SIZE
];
898 WCHAR keypath
[0x200];
900 TRACE("%s\n",debugstr_w(szUpgradeCode
));
901 if (!squash_guid(szUpgradeCode
,squished_pc
))
902 return ERROR_FUNCTION_FAILED
;
903 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
905 sprintfW(keypath
,szInstaller_UserUpgradeCodes_fmt
,squished_pc
);
908 rc
= RegCreateKeyW(HKEY_CURRENT_USER
,keypath
,key
);
910 rc
= RegOpenKeyW(HKEY_CURRENT_USER
,keypath
,key
);
915 UINT
MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode
, HKEY
*key
, BOOL create
)
917 WCHAR squished_pc
[GUID_SIZE
];
918 WCHAR keypath
[0x200];
920 TRACE("%s\n", debugstr_w(szProductCode
));
922 if (!squash_guid(szProductCode
, squished_pc
))
923 return ERROR_FUNCTION_FAILED
;
925 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
927 sprintfW(keypath
, szInstaller_LocalSystemProductCodes_fmt
, squished_pc
);
930 return RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
932 return RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
935 UINT
MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent
, HKEY
*key
, BOOL create
)
937 WCHAR squished_pc
[GUID_SIZE
];
938 WCHAR keypath
[0x200];
940 TRACE("%s\n", debugstr_w(szComponent
));
942 if (!squash_guid(szComponent
, squished_pc
))
943 return ERROR_FUNCTION_FAILED
;
945 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
947 sprintfW(keypath
, szInstaller_LocalSystemComponent_fmt
, squished_pc
);
950 return RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
952 return RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
955 UINT
MSIREG_OpenLocalClassesProductKey(LPCWSTR szProductCode
, HKEY
*key
, BOOL create
)
957 WCHAR squished_pc
[GUID_SIZE
];
958 WCHAR keypath
[0x200];
960 TRACE("%s\n", debugstr_w(szProductCode
));
962 if (!squash_guid(szProductCode
, squished_pc
))
963 return ERROR_FUNCTION_FAILED
;
965 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
967 sprintfW(keypath
, szInstaller_LocalClassesProd_fmt
, squished_pc
);
970 return RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
972 return RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
975 UINT
MSIREG_OpenLocalManagedProductKey(LPCWSTR szProductCode
, HKEY
*key
, BOOL create
)
977 WCHAR squished_pc
[GUID_SIZE
];
978 WCHAR keypath
[0x200];
982 TRACE("%s\n", debugstr_w(szProductCode
));
984 if (!squash_guid(szProductCode
, squished_pc
))
985 return ERROR_FUNCTION_FAILED
;
987 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
989 r
= get_user_sid(&usersid
);
990 if (r
!= ERROR_SUCCESS
|| !usersid
)
992 ERR("Failed to retrieve user SID: %d\n", r
);
996 sprintfW(keypath
, szInstaller_LocalManagedProd_fmt
, usersid
, squished_pc
);
1000 return RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
1002 return RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
1005 /*************************************************************************
1006 * MsiDecomposeDescriptorW [MSI.@]
1008 * Decomposes an MSI descriptor into product, feature and component parts.
1009 * An MSI descriptor is a string of the form:
1010 * [base 85 guid] [feature code] '>' [base 85 guid]
1013 * szDescriptor [I] the descriptor to decompose
1014 * szProduct [O] buffer of MAX_FEATURE_CHARS+1 for the product guid
1015 * szFeature [O] buffer of MAX_FEATURE_CHARS+1 for the feature code
1016 * szComponent [O] buffer of MAX_FEATURE_CHARS+1 for the component guid
1017 * pUsed [O] the length of the descriptor
1020 * ERROR_SUCCESS if everything worked correctly
1021 * ERROR_INVALID_PARAMETER if the descriptor was invalid
1024 UINT WINAPI
MsiDecomposeDescriptorW( LPCWSTR szDescriptor
, LPWSTR szProduct
,
1025 LPWSTR szFeature
, LPWSTR szComponent
, LPDWORD pUsed
)
1029 GUID product
, component
;
1031 TRACE("%s %p %p %p %p\n", debugstr_w(szDescriptor
), szProduct
,
1032 szFeature
, szComponent
, pUsed
);
1034 r
= decode_base85_guid( szDescriptor
, &product
);
1036 return ERROR_INVALID_PARAMETER
;
1038 TRACE("product %s\n", debugstr_guid( &product
));
1040 p
= strchrW(&szDescriptor
[20],'>');
1042 return ERROR_INVALID_PARAMETER
;
1044 len
= (p
- &szDescriptor
[20]);
1045 if( len
> MAX_FEATURE_CHARS
)
1046 return ERROR_INVALID_PARAMETER
;
1048 TRACE("feature %s\n", debugstr_wn( &szDescriptor
[20], len
));
1050 r
= decode_base85_guid( p
+1, &component
);
1052 return ERROR_INVALID_PARAMETER
;
1054 TRACE("component %s\n", debugstr_guid( &component
));
1057 StringFromGUID2( &product
, szProduct
, MAX_FEATURE_CHARS
+1 );
1059 StringFromGUID2( &component
, szComponent
, MAX_FEATURE_CHARS
+1 );
1062 memcpy( szFeature
, &szDescriptor
[20], len
*sizeof(WCHAR
) );
1065 len
= ( &p
[21] - szDescriptor
);
1067 TRACE("length = %d\n", len
);
1070 return ERROR_SUCCESS
;
1073 UINT WINAPI
MsiDecomposeDescriptorA( LPCSTR szDescriptor
, LPSTR szProduct
,
1074 LPSTR szFeature
, LPSTR szComponent
, LPDWORD pUsed
)
1076 WCHAR product
[MAX_FEATURE_CHARS
+1];
1077 WCHAR feature
[MAX_FEATURE_CHARS
+1];
1078 WCHAR component
[MAX_FEATURE_CHARS
+1];
1079 LPWSTR str
= NULL
, p
= NULL
, f
= NULL
, c
= NULL
;
1082 TRACE("%s %p %p %p %p\n", debugstr_a(szDescriptor
), szProduct
,
1083 szFeature
, szComponent
, pUsed
);
1085 str
= strdupAtoW( szDescriptor
);
1086 if( szDescriptor
&& !str
)
1087 return ERROR_OUTOFMEMORY
;
1096 r
= MsiDecomposeDescriptorW( str
, p
, f
, c
, pUsed
);
1098 if (r
== ERROR_SUCCESS
)
1100 WideCharToMultiByte( CP_ACP
, 0, p
, -1,
1101 szProduct
, MAX_FEATURE_CHARS
+1, NULL
, NULL
);
1102 WideCharToMultiByte( CP_ACP
, 0, f
, -1,
1103 szFeature
, MAX_FEATURE_CHARS
+1, NULL
, NULL
);
1104 WideCharToMultiByte( CP_ACP
, 0, c
, -1,
1105 szComponent
, MAX_FEATURE_CHARS
+1, NULL
, NULL
);
1113 UINT WINAPI
MsiEnumProductsA(DWORD index
, LPSTR lpguid
)
1116 WCHAR szwGuid
[GUID_SIZE
];
1118 TRACE("%d %p\n", index
, lpguid
);
1121 return ERROR_INVALID_PARAMETER
;
1122 r
= MsiEnumProductsW(index
, szwGuid
);
1123 if( r
== ERROR_SUCCESS
)
1124 WideCharToMultiByte(CP_ACP
, 0, szwGuid
, -1, lpguid
, GUID_SIZE
, NULL
, NULL
);
1129 UINT WINAPI
MsiEnumProductsW(DWORD index
, LPWSTR lpguid
)
1131 HKEY hkeyProducts
= 0;
1133 WCHAR szKeyName
[SQUISH_GUID_SIZE
];
1135 TRACE("%d %p\n", index
, lpguid
);
1138 return ERROR_INVALID_PARAMETER
;
1140 r
= MSIREG_OpenProducts(&hkeyProducts
);
1141 if( r
!= ERROR_SUCCESS
)
1142 return ERROR_NO_MORE_ITEMS
;
1144 r
= RegEnumKeyW(hkeyProducts
, index
, szKeyName
, SQUISH_GUID_SIZE
);
1145 if( r
== ERROR_SUCCESS
)
1146 unsquash_guid(szKeyName
, lpguid
);
1147 RegCloseKey(hkeyProducts
);
1152 UINT WINAPI
MsiEnumFeaturesA(LPCSTR szProduct
, DWORD index
,
1153 LPSTR szFeature
, LPSTR szParent
)
1156 WCHAR szwFeature
[GUID_SIZE
], szwParent
[GUID_SIZE
];
1157 LPWSTR szwProduct
= NULL
;
1159 TRACE("%s %d %p %p\n", debugstr_a(szProduct
), index
, szFeature
, szParent
);
1163 szwProduct
= strdupAtoW( szProduct
);
1165 return ERROR_OUTOFMEMORY
;
1168 r
= MsiEnumFeaturesW(szwProduct
, index
, szwFeature
, szwParent
);
1169 if( r
== ERROR_SUCCESS
)
1171 WideCharToMultiByte(CP_ACP
, 0, szwFeature
, -1,
1172 szFeature
, GUID_SIZE
, NULL
, NULL
);
1173 WideCharToMultiByte(CP_ACP
, 0, szwParent
, -1,
1174 szParent
, GUID_SIZE
, NULL
, NULL
);
1177 msi_free( szwProduct
);
1182 UINT WINAPI
MsiEnumFeaturesW(LPCWSTR szProduct
, DWORD index
,
1183 LPWSTR szFeature
, LPWSTR szParent
)
1185 HKEY hkeyProduct
= 0;
1188 TRACE("%s %d %p %p\n", debugstr_w(szProduct
), index
, szFeature
, szParent
);
1191 return ERROR_INVALID_PARAMETER
;
1193 r
= MSIREG_OpenFeaturesKey(szProduct
,&hkeyProduct
,FALSE
);
1194 if( r
!= ERROR_SUCCESS
)
1195 return ERROR_NO_MORE_ITEMS
;
1198 r
= RegEnumValueW(hkeyProduct
, index
, szFeature
, &sz
, NULL
, NULL
, NULL
, NULL
);
1199 RegCloseKey(hkeyProduct
);
1204 UINT WINAPI
MsiEnumComponentsA(DWORD index
, LPSTR lpguid
)
1207 WCHAR szwGuid
[GUID_SIZE
];
1209 TRACE("%d %p\n", index
, lpguid
);
1211 r
= MsiEnumComponentsW(index
, szwGuid
);
1212 if( r
== ERROR_SUCCESS
)
1213 WideCharToMultiByte(CP_ACP
, 0, szwGuid
, -1, lpguid
, GUID_SIZE
, NULL
, NULL
);
1218 UINT WINAPI
MsiEnumComponentsW(DWORD index
, LPWSTR lpguid
)
1220 HKEY hkeyComponents
= 0;
1222 WCHAR szKeyName
[SQUISH_GUID_SIZE
];
1224 TRACE("%d %p\n", index
, lpguid
);
1226 r
= MSIREG_OpenComponents(&hkeyComponents
);
1227 if( r
!= ERROR_SUCCESS
)
1228 return ERROR_NO_MORE_ITEMS
;
1230 r
= RegEnumKeyW(hkeyComponents
, index
, szKeyName
, SQUISH_GUID_SIZE
);
1231 if( r
== ERROR_SUCCESS
)
1232 unsquash_guid(szKeyName
, lpguid
);
1233 RegCloseKey(hkeyComponents
);
1238 UINT WINAPI
MsiEnumClientsA(LPCSTR szComponent
, DWORD index
, LPSTR szProduct
)
1241 WCHAR szwProduct
[GUID_SIZE
];
1242 LPWSTR szwComponent
= NULL
;
1244 TRACE("%s %d %p\n", debugstr_a(szComponent
), index
, szProduct
);
1247 return ERROR_INVALID_PARAMETER
;
1251 szwComponent
= strdupAtoW( szComponent
);
1253 return ERROR_OUTOFMEMORY
;
1256 r
= MsiEnumClientsW(szComponent
?szwComponent
:NULL
, index
, szwProduct
);
1257 if( r
== ERROR_SUCCESS
)
1259 WideCharToMultiByte(CP_ACP
, 0, szwProduct
, -1,
1260 szProduct
, GUID_SIZE
, NULL
, NULL
);
1263 msi_free( szwComponent
);
1268 UINT WINAPI
MsiEnumClientsW(LPCWSTR szComponent
, DWORD index
, LPWSTR szProduct
)
1272 WCHAR szValName
[SQUISH_GUID_SIZE
];
1274 TRACE("%s %d %p\n", debugstr_w(szComponent
), index
, szProduct
);
1276 if (!szComponent
|| !*szComponent
|| !szProduct
)
1277 return ERROR_INVALID_PARAMETER
;
1279 if (MSIREG_OpenUserDataComponentKey(szComponent
, &hkeyComp
, FALSE
) != ERROR_SUCCESS
&&
1280 MSIREG_OpenLocalSystemComponentKey(szComponent
, &hkeyComp
, FALSE
) != ERROR_SUCCESS
)
1281 return ERROR_UNKNOWN_COMPONENT
;
1283 /* see if there are any products at all */
1284 sz
= SQUISH_GUID_SIZE
;
1285 r
= RegEnumValueW(hkeyComp
, 0, szValName
, &sz
, NULL
, NULL
, NULL
, NULL
);
1286 if (r
!= ERROR_SUCCESS
)
1288 RegCloseKey(hkeyComp
);
1291 return ERROR_INVALID_PARAMETER
;
1293 return ERROR_UNKNOWN_COMPONENT
;
1296 sz
= SQUISH_GUID_SIZE
;
1297 r
= RegEnumValueW(hkeyComp
, index
, szValName
, &sz
, NULL
, NULL
, NULL
, NULL
);
1298 if( r
== ERROR_SUCCESS
)
1299 unsquash_guid(szValName
, szProduct
);
1301 RegCloseKey(hkeyComp
);
1306 static UINT WINAPI
MSI_EnumComponentQualifiers( LPCWSTR szComponent
, DWORD iIndex
,
1307 awstring
*lpQualBuf
, LPDWORD pcchQual
,
1308 awstring
*lpAppBuf
, LPDWORD pcchAppBuf
)
1310 DWORD name_sz
, val_sz
, name_max
, val_max
, type
, ofs
;
1311 LPWSTR name
= NULL
, val
= NULL
;
1315 TRACE("%s %08x %p %p %p %p\n", debugstr_w(szComponent
), iIndex
,
1316 lpQualBuf
, pcchQual
, lpAppBuf
, pcchAppBuf
);
1319 return ERROR_INVALID_PARAMETER
;
1321 r
= MSIREG_OpenUserComponentsKey( szComponent
, &key
, FALSE
);
1322 if (r
!= ERROR_SUCCESS
)
1323 return ERROR_UNKNOWN_COMPONENT
;
1325 /* figure out how big the name is we want to return */
1327 r
= ERROR_OUTOFMEMORY
;
1328 name
= msi_alloc( name_max
* sizeof(WCHAR
) );
1333 r
= ERROR_OUTOFMEMORY
;
1334 val
= msi_alloc( val_max
);
1338 /* loop until we allocate enough memory */
1343 r
= RegEnumValueW( key
, iIndex
, name
, &name_sz
,
1344 NULL
, &type
, (LPBYTE
)val
, &val_sz
);
1345 if (r
== ERROR_SUCCESS
)
1347 if (r
!= ERROR_MORE_DATA
)
1350 if (type
!= REG_MULTI_SZ
)
1352 ERR("component data has wrong type (%d)\n", type
);
1356 r
= ERROR_OUTOFMEMORY
;
1357 if ((name_sz
+1) >= name_max
)
1361 name
= msi_alloc( name_max
* sizeof (WCHAR
) );
1366 if (val_sz
> val_max
)
1368 val_max
= val_sz
+ sizeof (WCHAR
);
1370 val
= msi_alloc( val_max
* sizeof (WCHAR
) );
1375 ERR("should be enough data, but isn't %d %d\n", name_sz
, val_sz
);
1380 r
= MsiDecomposeDescriptorW( val
, NULL
, NULL
, NULL
, &ofs
);
1381 if (r
!= ERROR_SUCCESS
)
1384 TRACE("Providing %s and %s\n", debugstr_w(name
), debugstr_w(val
+ofs
));
1386 r
= msi_strcpy_to_awstring( name
, lpQualBuf
, pcchQual
);
1387 r2
= msi_strcpy_to_awstring( val
+ofs
, lpAppBuf
, pcchAppBuf
);
1389 if (r2
!= ERROR_SUCCESS
)
1400 /*************************************************************************
1401 * MsiEnumComponentQualifiersA [MSI.@]
1403 UINT WINAPI
MsiEnumComponentQualifiersA( LPCSTR szComponent
, DWORD iIndex
,
1404 LPSTR lpQualifierBuf
, LPDWORD pcchQualifierBuf
,
1405 LPSTR lpApplicationDataBuf
, LPDWORD pcchApplicationDataBuf
)
1407 awstring qual
, appdata
;
1411 TRACE("%s %08x %p %p %p %p\n", debugstr_a(szComponent
), iIndex
,
1412 lpQualifierBuf
, pcchQualifierBuf
, lpApplicationDataBuf
,
1413 pcchApplicationDataBuf
);
1415 comp
= strdupAtoW( szComponent
);
1416 if (szComponent
&& !comp
)
1417 return ERROR_OUTOFMEMORY
;
1419 qual
.unicode
= FALSE
;
1420 qual
.str
.a
= lpQualifierBuf
;
1422 appdata
.unicode
= FALSE
;
1423 appdata
.str
.a
= lpApplicationDataBuf
;
1425 r
= MSI_EnumComponentQualifiers( comp
, iIndex
,
1426 &qual
, pcchQualifierBuf
, &appdata
, pcchApplicationDataBuf
);
1431 /*************************************************************************
1432 * MsiEnumComponentQualifiersW [MSI.@]
1434 UINT WINAPI
MsiEnumComponentQualifiersW( LPCWSTR szComponent
, DWORD iIndex
,
1435 LPWSTR lpQualifierBuf
, LPDWORD pcchQualifierBuf
,
1436 LPWSTR lpApplicationDataBuf
, LPDWORD pcchApplicationDataBuf
)
1438 awstring qual
, appdata
;
1440 TRACE("%s %08x %p %p %p %p\n", debugstr_w(szComponent
), iIndex
,
1441 lpQualifierBuf
, pcchQualifierBuf
, lpApplicationDataBuf
,
1442 pcchApplicationDataBuf
);
1444 qual
.unicode
= TRUE
;
1445 qual
.str
.w
= lpQualifierBuf
;
1447 appdata
.unicode
= TRUE
;
1448 appdata
.str
.w
= lpApplicationDataBuf
;
1450 return MSI_EnumComponentQualifiers( szComponent
, iIndex
,
1451 &qual
, pcchQualifierBuf
, &appdata
, pcchApplicationDataBuf
);
1454 /*************************************************************************
1455 * MsiEnumRelatedProductsW [MSI.@]
1458 UINT WINAPI
MsiEnumRelatedProductsW(LPCWSTR szUpgradeCode
, DWORD dwReserved
,
1459 DWORD iProductIndex
, LPWSTR lpProductBuf
)
1463 DWORD dwSize
= SQUISH_GUID_SIZE
;
1464 WCHAR szKeyName
[SQUISH_GUID_SIZE
];
1466 TRACE("%s %u %u %p\n", debugstr_w(szUpgradeCode
), dwReserved
,
1467 iProductIndex
, lpProductBuf
);
1469 if (NULL
== szUpgradeCode
)
1470 return ERROR_INVALID_PARAMETER
;
1471 if (NULL
== lpProductBuf
)
1472 return ERROR_INVALID_PARAMETER
;
1474 r
= MSIREG_OpenUpgradeCodesKey(szUpgradeCode
, &hkey
, FALSE
);
1475 if (r
!= ERROR_SUCCESS
)
1476 return ERROR_NO_MORE_ITEMS
;
1478 r
= RegEnumValueW(hkey
, iProductIndex
, szKeyName
, &dwSize
, NULL
, NULL
, NULL
, NULL
);
1479 if( r
== ERROR_SUCCESS
)
1480 unsquash_guid(szKeyName
, lpProductBuf
);
1486 /*************************************************************************
1487 * MsiEnumRelatedProductsA [MSI.@]
1490 UINT WINAPI
MsiEnumRelatedProductsA(LPCSTR szUpgradeCode
, DWORD dwReserved
,
1491 DWORD iProductIndex
, LPSTR lpProductBuf
)
1493 LPWSTR szwUpgradeCode
= NULL
;
1494 WCHAR productW
[GUID_SIZE
];
1497 TRACE("%s %u %u %p\n", debugstr_a(szUpgradeCode
), dwReserved
,
1498 iProductIndex
, lpProductBuf
);
1502 szwUpgradeCode
= strdupAtoW( szUpgradeCode
);
1503 if( !szwUpgradeCode
)
1504 return ERROR_OUTOFMEMORY
;
1507 r
= MsiEnumRelatedProductsW( szwUpgradeCode
, dwReserved
,
1508 iProductIndex
, productW
);
1509 if (r
== ERROR_SUCCESS
)
1511 WideCharToMultiByte( CP_ACP
, 0, productW
, GUID_SIZE
,
1512 lpProductBuf
, GUID_SIZE
, NULL
, NULL
);
1514 msi_free( szwUpgradeCode
);
1518 /***********************************************************************
1519 * MsiEnumPatchesA [MSI.@]
1521 UINT WINAPI
MsiEnumPatchesA( LPCSTR szProduct
, DWORD iPatchIndex
,
1522 LPSTR lpPatchBuf
, LPSTR lpTransformsBuf
, LPDWORD pcchTransformsBuf
)
1524 FIXME("%s %d %p %p %p\n", debugstr_a(szProduct
),
1525 iPatchIndex
, lpPatchBuf
, lpTransformsBuf
, pcchTransformsBuf
);
1526 return ERROR_NO_MORE_ITEMS
;
1529 /***********************************************************************
1530 * MsiEnumPatchesW [MSI.@]
1532 UINT WINAPI
MsiEnumPatchesW( LPCWSTR szProduct
, DWORD iPatchIndex
,
1533 LPWSTR lpPatchBuf
, LPWSTR lpTransformsBuf
, LPDWORD pcchTransformsBuf
)
1535 FIXME("%s %d %p %p %p\n", debugstr_w(szProduct
),
1536 iPatchIndex
, lpPatchBuf
, lpTransformsBuf
, pcchTransformsBuf
);
1537 return ERROR_NO_MORE_ITEMS
;
1540 UINT WINAPI
MsiEnumProductsExA( LPCSTR szProductCode
, LPCSTR szUserSid
,
1541 DWORD dwContext
, DWORD dwIndex
, CHAR szInstalledProductCode
[39],
1542 MSIINSTALLCONTEXT
* pdwInstalledContext
, LPSTR szSid
, LPDWORD pcchSid
)
1544 FIXME("%s %s %d %d %p %p %p %p\n", debugstr_a(szProductCode
), debugstr_a(szUserSid
),
1545 dwContext
, dwIndex
, szInstalledProductCode
, pdwInstalledContext
,
1547 return ERROR_NO_MORE_ITEMS
;
1550 UINT WINAPI
MsiEnumProductsExW( LPCWSTR szProductCode
, LPCWSTR szUserSid
,
1551 DWORD dwContext
, DWORD dwIndex
, WCHAR szInstalledProductCode
[39],
1552 MSIINSTALLCONTEXT
* pdwInstalledContext
, LPWSTR szSid
, LPDWORD pcchSid
)
1554 FIXME("%s %s %d %d %p %p %p %p\n", debugstr_w(szProductCode
), debugstr_w(szUserSid
),
1555 dwContext
, dwIndex
, szInstalledProductCode
, pdwInstalledContext
,
1557 return ERROR_NO_MORE_ITEMS
;