Stub implementation for MsiGetFileHashA/W.
[wine] / dlls / msi / install.c
1 /*
2  * Implementation of the Microsoft Installer (msi.dll)
3  *
4  * Copyright 2005 Aric Stewart for CodeWeavers
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 /* Msi top level apis directly related to installs */
22
23 #include <stdarg.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "wine/debug.h"
29 #include "msi.h"
30 #include "msidefs.h"
31 #include "msipriv.h"
32 #include "winuser.h"
33 #include "wine/unicode.h"
34 #include "action.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(msi);
37
38 /***********************************************************************
39  * MsiDoActionA       (MSI.@)
40  */
41 UINT WINAPI MsiDoActionA( MSIHANDLE hInstall, LPCSTR szAction )
42 {
43     LPWSTR szwAction;
44     UINT ret;
45
46     TRACE("%s\n", debugstr_a(szAction));
47
48     szwAction = strdupAtoW(szAction);
49     if (szAction && !szwAction)
50         return ERROR_FUNCTION_FAILED; 
51
52     ret = MsiDoActionW( hInstall, szwAction );
53     msi_free( szwAction );
54     return ret;
55 }
56
57 /***********************************************************************
58  * MsiDoActionW       (MSI.@)
59  */
60 UINT WINAPI MsiDoActionW( MSIHANDLE hInstall, LPCWSTR szAction )
61 {
62     MSIPACKAGE *package;
63     UINT ret;
64
65     TRACE("%s\n",debugstr_w(szAction));
66
67     if (!szAction)
68         return ERROR_INVALID_PARAMETER;
69
70     package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
71     if (!package)
72         return ERROR_INVALID_HANDLE;
73  
74     ret = ACTION_PerformUIAction( package, szAction );
75     msiobj_release( &package->hdr );
76
77     return ret;
78 }
79
80 /***********************************************************************
81  * MsiSequenceA       (MSI.@)
82  */
83 UINT WINAPI MsiSequenceA( MSIHANDLE hInstall, LPCSTR szTable, INT iSequenceMode )
84 {
85     LPWSTR szwTable;
86     UINT ret;
87
88     TRACE("%s\n", debugstr_a(szTable));
89
90     szwTable = strdupAtoW(szTable);
91     if (szTable && !szwTable)
92         return ERROR_FUNCTION_FAILED; 
93
94     ret = MsiSequenceW( hInstall, szwTable, iSequenceMode );
95     msi_free( szwTable );
96     return ret;
97 }
98
99 /***********************************************************************
100  * MsiSequenceW       (MSI.@)
101  */
102 UINT WINAPI MsiSequenceW( MSIHANDLE hInstall, LPCWSTR szTable, INT iSequenceMode )
103 {
104     MSIPACKAGE *package;
105     UINT ret;
106
107     TRACE("%s\n", debugstr_w(szTable));
108
109     package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
110     if (!package)
111         return ERROR_INVALID_HANDLE;
112
113     ret = MSI_Sequence( package, szTable, iSequenceMode );
114     msiobj_release( &package->hdr );
115  
116     return ret;
117 }
118
119 UINT msi_strcpy_to_awstring( LPCWSTR str, awstring *awbuf, DWORD *sz )
120 {
121     UINT len, r = ERROR_SUCCESS;
122
123     if (awbuf->str.w && !sz )
124         return ERROR_INVALID_PARAMETER;
125
126     if (!sz)
127         return r;
128  
129     if (awbuf->unicode)
130     {
131         len = lstrlenW( str );
132         if (awbuf->str.w) 
133             lstrcpynW( awbuf->str.w, str, *sz );
134     }
135     else
136     {
137         len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
138         if (len)
139             len--;
140         WideCharToMultiByte( CP_ACP, 0, str, -1, awbuf->str.a, *sz, NULL, NULL );
141         if ( *sz && (len >= *sz) )
142             awbuf->str.a[*sz - 1] = 0;
143     }
144
145     if (len >= *sz)
146         r = ERROR_MORE_DATA;
147     *sz = len;
148     return r;
149 }
150
151 /***********************************************************************
152  * MsiGetTargetPath   (internal)
153  */
154 UINT WINAPI MSI_GetTargetPath( MSIHANDLE hInstall, LPCWSTR szFolder,
155                                awstring *szPathBuf, DWORD* pcchPathBuf )
156 {
157     MSIPACKAGE *package;
158     LPWSTR path;
159     UINT r;
160
161     if (!szFolder)
162         return ERROR_INVALID_PARAMETER;
163
164     package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
165     if (!package)
166         return ERROR_INVALID_HANDLE;
167
168     path = resolve_folder( package, szFolder, FALSE, FALSE, NULL );
169     msiobj_release( &package->hdr );
170
171     if (!path)
172         return ERROR_DIRECTORY;
173
174     r = msi_strcpy_to_awstring( path, szPathBuf, pcchPathBuf );
175     msi_free( path );
176     return r;
177 }
178
179 /***********************************************************************
180  * MsiGetTargetPathA        (MSI.@)
181  */
182 UINT WINAPI MsiGetTargetPathA( MSIHANDLE hInstall, LPCSTR szFolder, 
183                                LPSTR szPathBuf, DWORD* pcchPathBuf )
184 {
185     LPWSTR szwFolder;
186     awstring path;
187     UINT r;
188
189     TRACE("%s %p %p\n", debugstr_a(szFolder), szPathBuf, pcchPathBuf);
190
191     szwFolder = strdupAtoW(szFolder);
192     if (szFolder && !szwFolder)
193         return ERROR_FUNCTION_FAILED; 
194
195     path.unicode = FALSE;
196     path.str.a = szPathBuf;
197
198     r = MSI_GetTargetPath( hInstall, szwFolder, &path, pcchPathBuf );
199
200     msi_free( szwFolder );
201
202     return r;
203 }
204
205 /***********************************************************************
206  * MsiGetTargetPathW        (MSI.@)
207  */
208 UINT WINAPI MsiGetTargetPathW( MSIHANDLE hInstall, LPCWSTR szFolder,
209                                LPWSTR szPathBuf, DWORD* pcchPathBuf )
210 {
211     awstring path;
212
213     TRACE("%s %p %p\n", debugstr_w(szFolder), szPathBuf, pcchPathBuf);
214
215     path.unicode = TRUE;
216     path.str.w = szPathBuf;
217
218     return MSI_GetTargetPath( hInstall, szFolder, &path, pcchPathBuf );
219 }
220
221 /***********************************************************************
222  * MsiGetSourcePath   (internal)
223  */
224 static UINT MSI_GetSourcePath( MSIHANDLE hInstall, LPCWSTR szFolder,
225                                awstring *szPathBuf, DWORD* pcchPathBuf )
226 {
227     MSIPACKAGE *package;
228     LPWSTR path;
229     UINT r;
230
231     TRACE("%s %p %p\n", debugstr_w(szFolder), szPathBuf, pcchPathBuf );
232
233     if (!szFolder)
234         return ERROR_INVALID_PARAMETER;
235
236     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
237     if (!package)
238         return ERROR_INVALID_HANDLE;
239
240     if (szPathBuf->str.w && !pcchPathBuf )
241     {
242         msiobj_release( &package->hdr );
243         return ERROR_INVALID_PARAMETER;
244     }
245
246     path = resolve_folder(package, szFolder, TRUE, FALSE, NULL);
247     msiobj_release( &package->hdr );
248
249     TRACE("path = %s\n",debugstr_w(path));
250     if (!path)
251         return ERROR_DIRECTORY;
252
253     r = msi_strcpy_to_awstring( path, szPathBuf, pcchPathBuf );
254     msi_free( path );
255     return r;
256 }
257
258 /***********************************************************************
259  * MsiGetSourcePathA     (MSI.@)
260  */
261 UINT WINAPI MsiGetSourcePathA( MSIHANDLE hInstall, LPCSTR szFolder, 
262                                LPSTR szPathBuf, DWORD* pcchPathBuf )
263 {
264     LPWSTR folder;
265     awstring str;
266     UINT r;
267
268     TRACE("%s %p %p\n", szFolder, debugstr_a(szPathBuf), pcchPathBuf);
269
270     str.unicode = FALSE;
271     str.str.a = szPathBuf;
272
273     folder = strdupAtoW( szFolder );
274     r = MSI_GetSourcePath( hInstall, folder, &str, pcchPathBuf );
275     msi_free( folder );
276
277     return r;
278 }
279
280 /***********************************************************************
281  * MsiGetSourcePathW     (MSI.@)
282  */
283 UINT WINAPI MsiGetSourcePathW( MSIHANDLE hInstall, LPCWSTR szFolder,
284                                LPWSTR szPathBuf, DWORD* pcchPathBuf )
285 {
286     awstring str;
287
288     TRACE("%s %p %p\n", debugstr_w(szFolder), szPathBuf, pcchPathBuf );
289
290     str.unicode = TRUE;
291     str.str.w = szPathBuf;
292
293     return MSI_GetSourcePath( hInstall, szFolder, &str, pcchPathBuf );
294 }
295
296 /***********************************************************************
297  * MsiSetTargetPathA  (MSI.@)
298  */
299 UINT WINAPI MsiSetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder, 
300                              LPCSTR szFolderPath)
301 {
302     LPWSTR szwFolder;
303     LPWSTR szwFolderPath;
304     UINT rc;
305
306     if (!szFolder)
307         return ERROR_FUNCTION_FAILED;
308     if (hInstall == 0)
309         return ERROR_FUNCTION_FAILED;
310
311     szwFolder = strdupAtoW(szFolder);
312     if (!szwFolder)
313         return ERROR_FUNCTION_FAILED; 
314
315     szwFolderPath = strdupAtoW(szFolderPath);
316     if (!szwFolderPath)
317     {
318         msi_free(szwFolder);
319         return ERROR_FUNCTION_FAILED; 
320     }
321
322     rc = MsiSetTargetPathW(hInstall, szwFolder, szwFolderPath);
323
324     msi_free(szwFolder);
325     msi_free(szwFolderPath);
326
327     return rc;
328 }
329
330 /*
331  * Ok my original interpretation of this was wrong. And it looks like msdn has
332  * changed a bit also. The given folder path does not have to actually already
333  * exist, it just cannot be read only and must be a legal folder path.
334  */
335 UINT MSI_SetTargetPathW(MSIPACKAGE *package, LPCWSTR szFolder, 
336                              LPCWSTR szFolderPath)
337 {
338     DWORD attrib;
339     LPWSTR path = NULL;
340     LPWSTR path2 = NULL;
341     MSIFOLDER *folder;
342
343     TRACE("(%p %s %s)\n",package, debugstr_w(szFolder),debugstr_w(szFolderPath));
344
345     if (package==NULL)
346         return ERROR_INVALID_HANDLE;
347
348     if (szFolderPath[0]==0)
349         return ERROR_FUNCTION_FAILED;
350
351     attrib = GetFileAttributesW(szFolderPath);
352     if ( attrib != INVALID_FILE_ATTRIBUTES &&
353           (!(attrib & FILE_ATTRIBUTE_DIRECTORY) ||
354            attrib & FILE_ATTRIBUTE_OFFLINE ||
355            attrib & FILE_ATTRIBUTE_READONLY))
356         return ERROR_FUNCTION_FAILED;
357
358     path = resolve_folder(package,szFolder,FALSE,FALSE,&folder);
359
360     if (!path)
361         return ERROR_INVALID_PARAMETER;
362
363     if (attrib == INVALID_FILE_ATTRIBUTES)
364     {
365         if (!CreateDirectoryW(szFolderPath,NULL))
366         {
367             msi_free( path );
368             return ERROR_FUNCTION_FAILED;
369         }
370         RemoveDirectoryW(szFolderPath);
371     }
372
373     msi_free(folder->Property);
374     folder->Property = build_directory_name(2, szFolderPath, NULL);
375
376     if (lstrcmpiW(path, folder->Property) == 0)
377     {
378         /*
379          *  Resolved Target has not really changed, so just 
380          *  set this folder and do not recalculate everything.
381          */
382         msi_free(folder->ResolvedTarget);
383         folder->ResolvedTarget = NULL;
384         path2 = resolve_folder(package,szFolder,FALSE,TRUE,NULL);
385         msi_free(path2);
386     }
387     else
388     {
389         MSIFOLDER *f;
390
391         LIST_FOR_EACH_ENTRY( f, &package->folders, MSIFOLDER, entry )
392         {
393             msi_free(f->ResolvedTarget);
394             f->ResolvedTarget=NULL;
395         }
396
397         LIST_FOR_EACH_ENTRY( f, &package->folders, MSIFOLDER, entry )
398         {
399             path2 = resolve_folder(package, f->Directory, FALSE, TRUE, NULL);
400             msi_free(path2);
401         }
402     }
403     msi_free(path);
404
405     return ERROR_SUCCESS;
406 }
407
408 /***********************************************************************
409  * MsiSetTargetPathW  (MSI.@)
410  */
411 UINT WINAPI MsiSetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder, 
412                              LPCWSTR szFolderPath)
413 {
414     MSIPACKAGE *package;
415     UINT ret;
416
417     TRACE("(%s %s)\n",debugstr_w(szFolder),debugstr_w(szFolderPath));
418
419     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
420     ret = MSI_SetTargetPathW( package, szFolder, szFolderPath );
421     msiobj_release( &package->hdr );
422     return ret;
423 }
424
425 /***********************************************************************
426  *           MsiGetMode    (MSI.@)
427  *
428  * Returns an internal installer state (if it is running in a mode iRunMode)
429  *
430  * PARAMS
431  *   hInstall    [I]  Handle to the installation
432  *   hRunMode    [I]  Checking run mode
433  *        MSIRUNMODE_ADMIN             Administrative mode
434  *        MSIRUNMODE_ADVERTISE         Advertisement mode
435  *        MSIRUNMODE_MAINTENANCE       Maintenance mode
436  *        MSIRUNMODE_ROLLBACKENABLED   Rollback is enabled
437  *        MSIRUNMODE_LOGENABLED        Log file is writing
438  *        MSIRUNMODE_OPERATIONS        Operations in progress??
439  *        MSIRUNMODE_REBOOTATEND       We need to reboot after installation completed
440  *        MSIRUNMODE_REBOOTNOW         We need to reboot to continue the installation
441  *        MSIRUNMODE_CABINET           Files from cabinet are installed
442  *        MSIRUNMODE_SOURCESHORTNAMES  Long names in source files is suppressed
443  *        MSIRUNMODE_TARGETSHORTNAMES  Long names in destination files is suppressed
444  *        MSIRUNMODE_RESERVED11        Reserved
445  *        MSIRUNMODE_WINDOWS9X         Running under Windows95/98
446  *        MSIRUNMODE_ZAWENABLED        Demand installation is supported
447  *        MSIRUNMODE_RESERVED14        Reserved
448  *        MSIRUNMODE_RESERVED15        Reserved
449  *        MSIRUNMODE_SCHEDULED         called from install script
450  *        MSIRUNMODE_ROLLBACK          called from rollback script
451  *        MSIRUNMODE_COMMIT            called from commit script
452  *
453  * RETURNS
454  *    In the state: TRUE
455  *    Not in the state: FALSE
456  *
457  */
458
459 BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode)
460 {
461     FIXME("STUB (iRunMode=%i)\n",iRunMode);
462     return TRUE;
463 }
464
465 /***********************************************************************
466  *           MsiSetMode    (MSI.@)
467  */
468 BOOL WINAPI MsiSetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode, BOOL fState)
469 {
470     switch (iRunMode)
471     {
472     case MSIRUNMODE_RESERVED11:
473     case MSIRUNMODE_WINDOWS9X:
474     case MSIRUNMODE_RESERVED14:
475     case MSIRUNMODE_RESERVED15:
476         return FALSE;
477     default:
478         FIXME("%ld %d %d\n", hInstall, iRunMode, fState);
479     }
480     return TRUE;
481 }
482
483 /***********************************************************************
484  * MsiSetFeatureStateA (MSI.@)
485  *
486  * According to the docs, when this is called it immediately recalculates
487  * all the component states as well
488  */
489 UINT WINAPI MsiSetFeatureStateA(MSIHANDLE hInstall, LPCSTR szFeature,
490                                 INSTALLSTATE iState)
491 {
492     LPWSTR szwFeature = NULL;
493     UINT rc;
494
495     szwFeature = strdupAtoW(szFeature);
496
497     if (!szwFeature)
498         return ERROR_FUNCTION_FAILED;
499    
500     rc = MsiSetFeatureStateW(hInstall,szwFeature, iState); 
501
502     msi_free(szwFeature);
503
504     return rc;
505 }
506
507
508
509 UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE* package, LPCWSTR szFeature,
510                                 INSTALLSTATE iState)
511 {
512     UINT rc = ERROR_SUCCESS;
513     MSIFEATURE *feature, *child;
514
515     TRACE(" %s to %i\n",debugstr_w(szFeature), iState);
516
517     feature = get_loaded_feature(package,szFeature);
518     if (!feature)
519         return ERROR_UNKNOWN_FEATURE;
520
521     if (iState == INSTALLSTATE_ADVERTISED && 
522         feature->Attributes & msidbFeatureAttributesDisallowAdvertise)
523         return ERROR_FUNCTION_FAILED;
524
525     feature->ActionRequest = iState;
526     feature->Action = iState;
527
528     ACTION_UpdateComponentStates(package,szFeature);
529
530     /* update all the features that are children of this feature */
531     LIST_FOR_EACH_ENTRY( child, &package->features, MSIFEATURE, entry )
532     {
533         if (lstrcmpW(szFeature, child->Feature_Parent) == 0)
534             MSI_SetFeatureStateW(package, child->Feature, iState);
535     }
536     
537     return rc;
538 }
539
540 /***********************************************************************
541  * MsiSetFeatureStateW (MSI.@)
542  */
543 UINT WINAPI MsiSetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature,
544                                 INSTALLSTATE iState)
545 {
546     MSIPACKAGE* package;
547     UINT rc = ERROR_SUCCESS;
548
549     TRACE(" %s to %i\n",debugstr_w(szFeature), iState);
550
551     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
552     if (!package)
553         return ERROR_INVALID_HANDLE;
554
555     rc = MSI_SetFeatureStateW(package,szFeature,iState);
556
557     msiobj_release( &package->hdr );
558     return rc;
559 }
560
561 /***********************************************************************
562 * MsiGetFeatureStateA   (MSI.@)
563 */
564 UINT WINAPI MsiGetFeatureStateA(MSIHANDLE hInstall, LPSTR szFeature,
565                   INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
566 {
567     LPWSTR szwFeature = NULL;
568     UINT rc;
569     
570     szwFeature = strdupAtoW(szFeature);
571
572     rc = MsiGetFeatureStateW(hInstall,szwFeature,piInstalled, piAction);
573
574     msi_free( szwFeature);
575
576     return rc;
577 }
578
579 UINT MSI_GetFeatureStateW(MSIPACKAGE *package, LPWSTR szFeature,
580                   INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
581 {
582     MSIFEATURE *feature;
583
584     feature = get_loaded_feature(package,szFeature);
585     if (!feature)
586         return ERROR_UNKNOWN_FEATURE;
587
588     if (piInstalled)
589         *piInstalled = feature->Installed;
590
591     if (piAction)
592         *piAction = feature->Action;
593
594     TRACE("returning %i %i\n", feature->Installed, feature->Action);
595
596     return ERROR_SUCCESS;
597 }
598
599 /***********************************************************************
600 * MsiGetFeatureStateW   (MSI.@)
601 */
602 UINT WINAPI MsiGetFeatureStateW(MSIHANDLE hInstall, LPWSTR szFeature,
603                   INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
604 {
605     MSIPACKAGE* package;
606     UINT ret;
607
608     TRACE("%ld %s %p %p\n", hInstall, debugstr_w(szFeature), piInstalled,
609 piAction);
610
611     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
612     if (!package)
613         return ERROR_INVALID_HANDLE;
614     ret = MSI_GetFeatureStateW(package, szFeature, piInstalled, piAction);
615     msiobj_release( &package->hdr );
616     return ret;
617 }
618
619 /***********************************************************************
620  * MsiSetComponentStateA (MSI.@)
621  */
622 UINT WINAPI MsiSetComponentStateA(MSIHANDLE hInstall, LPCSTR szComponent,
623                                   INSTALLSTATE iState)
624 {
625     UINT rc;
626     LPWSTR szwComponent = strdupAtoW(szComponent);
627
628     rc = MsiSetComponentStateW(hInstall, szwComponent, iState);
629
630     msi_free(szwComponent);
631
632     return rc;
633 }
634
635 /***********************************************************************
636  * MsiGetComponentStateA (MSI.@)
637  */
638 UINT WINAPI MsiGetComponentStateA(MSIHANDLE hInstall, LPSTR szComponent,
639                   INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
640 {
641     LPWSTR szwComponent= NULL;
642     UINT rc;
643     
644     szwComponent= strdupAtoW(szComponent);
645
646     rc = MsiGetComponentStateW(hInstall,szwComponent,piInstalled, piAction);
647
648     msi_free( szwComponent);
649
650     return rc;
651 }
652
653 static UINT MSI_SetComponentStateW(MSIPACKAGE *package, LPCWSTR szComponent,
654                                    INSTALLSTATE iState)
655 {
656     MSICOMPONENT *comp;
657
658     TRACE("%p %s %d\n", package, debugstr_w(szComponent), iState);
659
660     comp = get_loaded_component(package, szComponent);
661     if (!comp)
662         return ERROR_UNKNOWN_COMPONENT;
663
664     comp->Installed = iState;
665
666     return ERROR_SUCCESS;
667 }
668
669 UINT MSI_GetComponentStateW(MSIPACKAGE *package, LPWSTR szComponent,
670                   INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
671 {
672     MSICOMPONENT *comp;
673
674     TRACE("%p %s %p %p\n", package, debugstr_w(szComponent),
675            piInstalled, piAction);
676
677     comp = get_loaded_component(package,szComponent);
678     if (!comp)
679         return ERROR_UNKNOWN_COMPONENT;
680
681     if (piInstalled)
682         *piInstalled = comp->Installed;
683
684     if (piAction)
685         *piAction = comp->Action;
686
687     TRACE("states (%i, %i)\n", comp->Installed, comp->Action );
688
689     return ERROR_SUCCESS;
690 }
691
692 /***********************************************************************
693  * MsiSetComponentStateW (MSI.@)
694  */
695 UINT WINAPI MsiSetComponentStateW(MSIHANDLE hInstall, LPCWSTR szComponent,
696                                   INSTALLSTATE iState)
697 {
698     MSIPACKAGE* package;
699     UINT ret;
700
701     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
702     if (!package)
703         return ERROR_INVALID_HANDLE;
704     ret = MSI_SetComponentStateW(package, szComponent, iState);
705     msiobj_release(&package->hdr);
706     return ret;
707 }
708
709 /***********************************************************************
710  * MsiGetComponentStateW (MSI.@)
711  */
712 UINT WINAPI MsiGetComponentStateW(MSIHANDLE hInstall, LPWSTR szComponent,
713                   INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
714 {
715     MSIPACKAGE* package;
716     UINT ret;
717
718     TRACE("%ld %s %p %p\n", hInstall, debugstr_w(szComponent),
719            piInstalled, piAction);
720
721     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
722     if (!package)
723         return ERROR_INVALID_HANDLE;
724     ret = MSI_GetComponentStateW( package, szComponent, piInstalled, piAction);
725     msiobj_release( &package->hdr );
726     return ret;
727 }
728
729 /***********************************************************************
730  * MsiGetLanguage (MSI.@)
731  */
732 LANGID WINAPI MsiGetLanguage(MSIHANDLE hInstall)
733 {
734     MSIPACKAGE* package;
735     LANGID langid;
736     LPWSTR buffer;
737     static const WCHAR szProductLanguage[] =
738         {'P','r','o','d','u','c','t','L','a','n','g','u','a','g','e',0};
739     
740     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
741     if (!package)
742         return ERROR_INVALID_HANDLE;
743
744     buffer = msi_dup_property( package, szProductLanguage );
745     langid = atoiW(buffer);
746
747     msi_free(buffer);
748     msiobj_release (&package->hdr);
749     return langid;
750 }