2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2005 Aric Stewart for CodeWeavers
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.
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.
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
22 * Here are helper functions formally in action.c that are used by a variaty of
23 * actions and functions.
31 #include "wine/debug.h"
34 #include "wine/unicode.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
39 static const WCHAR cszTargetDir
[] = {'T','A','R','G','E','T','D','I','R',0};
40 static const WCHAR cszDatabase
[]={'D','A','T','A','B','A','S','E',0};
42 const WCHAR cszSourceDir
[] = {'S','o','u','r','c','e','D','i','r',0};
43 const WCHAR cszRootDrive
[] = {'R','O','O','T','D','R','I','V','E',0};
44 const WCHAR cszbs
[]={'\\',0};
46 DWORD
build_version_dword(LPCWSTR version_string
)
50 DWORD rc
= 0x00000000;
53 ptr1
= version_string
;
62 ptr1
= strchrW(ptr1
,'.');
72 ptr1
= strchrW(ptr1
,'.');
82 rc
= MAKELONG(build
,MAKEWORD(minor
,major
));
83 TRACE("%s -> 0x%lx\n",debugstr_w(version_string
),rc
);
87 LPWSTR
build_icon_path(MSIPACKAGE
*package
, LPCWSTR icon_name
)
89 LPWSTR SystemFolder
, dest
, FilePath
;
91 static const WCHAR szInstaller
[] =
92 {'M','i','c','r','o','s','o','f','t','\\',
93 'I','n','s','t','a','l','l','e','r','\\',0};
94 static const WCHAR szFolder
[] =
95 {'A','p','p','D','a','t','a','F','o','l','d','e','r',0};
97 SystemFolder
= msi_dup_property( package
, szFolder
);
99 dest
= build_directory_name(3, SystemFolder
, szInstaller
, package
->ProductCode
);
101 create_full_pathW(dest
);
103 FilePath
= build_directory_name(2, dest
, icon_name
);
105 msi_free(SystemFolder
);
110 WCHAR
*load_dynamic_stringW(MSIRECORD
*row
, INT index
)
117 if (MSI_RecordIsNull(row
,index
))
120 rc
= MSI_RecordGetStringW(row
,index
,NULL
,&sz
);
122 /* having an empty string is different than NULL */
125 ret
= msi_alloc(sizeof(WCHAR
));
131 ret
= msi_alloc(sz
* sizeof (WCHAR
));
132 rc
= MSI_RecordGetStringW(row
,index
,ret
,&sz
);
133 if (rc
!=ERROR_SUCCESS
)
135 ERR("Unable to load dynamic string\n");
142 LPWSTR
msi_dup_property(MSIPACKAGE
*package
, LPCWSTR prop
)
148 r
= MSI_GetPropertyW(package
, prop
, NULL
, &sz
);
149 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
153 str
= msi_alloc(sz
*sizeof(WCHAR
));
154 r
= MSI_GetPropertyW(package
, prop
, str
, &sz
);
155 if (r
!= ERROR_SUCCESS
)
163 MSICOMPONENT
* get_loaded_component( MSIPACKAGE
* package
, LPCWSTR Component
)
167 LIST_FOR_EACH_ENTRY( comp
, &package
->components
, MSICOMPONENT
, entry
)
169 if (lstrcmpW(Component
,comp
->Component
)==0)
175 MSIFEATURE
* get_loaded_feature(MSIPACKAGE
* package
, LPCWSTR Feature
)
179 LIST_FOR_EACH_ENTRY( feature
, &package
->features
, MSIFEATURE
, entry
)
181 if (lstrcmpW( Feature
, feature
->Feature
)==0)
187 MSIFILE
* get_loaded_file( MSIPACKAGE
* package
, LPCWSTR key
)
191 LIST_FOR_EACH_ENTRY( file
, &package
->files
, MSIFILE
, entry
)
193 if (lstrcmpW( key
, file
->File
)==0)
199 int track_tempfile( MSIPACKAGE
*package
, LPCWSTR name
, LPCWSTR path
)
206 LIST_FOR_EACH_ENTRY( temp
, &package
->tempfiles
, MSITEMPFILE
, entry
)
208 if (lstrcmpW( name
, temp
->File
)==0)
210 TRACE("tempfile %s already exists with path %s\n",
211 debugstr_w(temp
->File
), debugstr_w(temp
->Path
));
216 temp
= msi_alloc_zero( sizeof (MSITEMPFILE
) );
220 list_add_head( &package
->tempfiles
, &temp
->entry
);
222 temp
->File
= strdupW( name
);
223 temp
->Path
= strdupW( path
);
225 TRACE("adding tempfile %s with path %s\n",
226 debugstr_w(temp
->File
), debugstr_w(temp
->Path
));
231 MSIFOLDER
*get_loaded_folder( MSIPACKAGE
*package
, LPCWSTR dir
)
235 LIST_FOR_EACH_ENTRY( folder
, &package
->folders
, MSIFOLDER
, entry
)
237 if (lstrcmpW( dir
, folder
->Directory
)==0)
243 LPWSTR
resolve_folder(MSIPACKAGE
*package
, LPCWSTR name
, BOOL source
,
244 BOOL set_prop
, MSIFOLDER
**folder
)
247 LPWSTR p
, path
= NULL
;
249 TRACE("Working to resolve %s\n",debugstr_w(name
));
254 /* special resolving for Target and Source root dir */
255 if (strcmpW(name
,cszTargetDir
)==0 || strcmpW(name
,cszSourceDir
)==0)
260 check_path
= msi_dup_property( package
, cszTargetDir
);
263 check_path
= msi_dup_property( package
, cszRootDrive
);
265 MSI_SetPropertyW(package
,cszTargetDir
,check_path
);
268 /* correct misbuilt target dir */
269 path
= build_directory_name(2, check_path
, NULL
);
270 if (strcmpiW(path
,check_path
)!=0)
271 MSI_SetPropertyW(package
,cszTargetDir
,path
);
272 msi_free(check_path
);
276 path
= msi_dup_property( package
, cszSourceDir
);
279 path
= msi_dup_property( package
, cszDatabase
);
282 p
= strrchrW(path
,'\\');
289 *folder
= get_loaded_folder( package
, name
);
293 f
= get_loaded_folder( package
, name
);
300 if (!source
&& f
->ResolvedTarget
)
302 path
= strdupW( f
->ResolvedTarget
);
303 TRACE(" already resolved to %s\n",debugstr_w(path
));
306 else if (source
&& f
->ResolvedSource
)
308 path
= strdupW( f
->ResolvedSource
);
309 TRACE(" (source)already resolved to %s\n",debugstr_w(path
));
312 else if (!source
&& f
->Property
)
314 path
= build_directory_name( 2, f
->Property
, NULL
);
316 TRACE(" internally set to %s\n",debugstr_w(path
));
318 MSI_SetPropertyW( package
, name
, path
);
324 LPWSTR parent
= f
->Parent
->Directory
;
326 TRACE(" ! Parent is %s\n", debugstr_w(parent
));
328 p
= resolve_folder(package
, parent
, source
, set_prop
, NULL
);
331 TRACE(" TargetDefault = %s\n", debugstr_w(f
->TargetDefault
));
333 path
= build_directory_name( 3, p
, f
->TargetDefault
, NULL
);
334 f
->ResolvedTarget
= strdupW( path
);
335 TRACE(" resolved into %s\n",debugstr_w(path
));
337 MSI_SetPropertyW(package
,name
,path
);
341 if (f
->SourceDefault
&& f
->SourceDefault
[0]!='.')
342 path
= build_directory_name( 3, p
, f
->SourceDefault
, NULL
);
345 TRACE(" (source)resolved into %s\n",debugstr_w(path
));
346 f
->ResolvedSource
= strdupW( path
);
353 /* wrapper to resist a need for a full rewrite right now */
354 DWORD
deformat_string(MSIPACKAGE
*package
, LPCWSTR ptr
, WCHAR
** data
)
358 MSIRECORD
*rec
= MSI_CreateRecord(1);
361 MSI_RecordSetStringW(rec
,0,ptr
);
362 MSI_FormatRecordW(package
,rec
,NULL
,&size
);
366 *data
= msi_alloc(size
*sizeof(WCHAR
));
368 MSI_FormatRecordW(package
,rec
,*data
,&size
);
371 msiobj_release( &rec
->hdr
);
372 return sizeof(WCHAR
)*size
;
374 msiobj_release( &rec
->hdr
);
381 UINT
schedule_action(MSIPACKAGE
*package
, UINT script
, LPCWSTR action
)
384 LPWSTR
*newbuf
= NULL
;
385 if (script
>= TOTAL_SCRIPTS
)
387 FIXME("Unknown script requested %i\n",script
);
388 return ERROR_FUNCTION_FAILED
;
390 TRACE("Scheduling Action %s in script %i\n",debugstr_w(action
), script
);
392 count
= package
->script
->ActionCount
[script
];
393 package
->script
->ActionCount
[script
]++;
395 newbuf
= msi_realloc( package
->script
->Actions
[script
],
396 package
->script
->ActionCount
[script
]* sizeof(LPWSTR
));
398 newbuf
= msi_alloc( sizeof(LPWSTR
));
400 newbuf
[count
] = strdupW(action
);
401 package
->script
->Actions
[script
] = newbuf
;
403 return ERROR_SUCCESS
;
406 static void remove_tracked_tempfiles(MSIPACKAGE
* package
)
408 struct list
*item
, *cursor
;
410 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->tempfiles
)
412 MSITEMPFILE
*temp
= LIST_ENTRY( item
, MSITEMPFILE
, entry
);
414 list_remove( &temp
->entry
);
415 TRACE("deleting temp file %s\n", debugstr_w( temp
->Path
));
416 DeleteFileW( temp
->Path
);
417 msi_free( temp
->File
);
418 msi_free( temp
->Path
);
423 static void free_feature( MSIFEATURE
*feature
)
425 struct list
*item
, *cursor
;
427 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Components
)
429 ComponentList
*cl
= LIST_ENTRY( item
, ComponentList
, entry
);
430 list_remove( &cl
->entry
);
433 msi_free( feature
->Feature
);
434 msi_free( feature
->Feature_Parent
);
435 msi_free( feature
->Directory
);
436 msi_free( feature
->Description
);
437 msi_free( feature
->Title
);
441 void free_extension( MSIEXTENSION
*ext
)
443 struct list
*item
, *cursor
;
445 LIST_FOR_EACH_SAFE( item
, cursor
, &ext
->verbs
)
447 MSIVERB
*verb
= LIST_ENTRY( item
, MSIVERB
, entry
);
449 list_remove( &verb
->entry
);
450 msi_free( verb
->Verb
);
451 msi_free( verb
->Command
);
452 msi_free( verb
->Argument
);
456 msi_free( ext
->Extension
);
457 msi_free( ext
->ProgIDText
);
461 /* Called when the package is being closed */
462 void ACTION_free_package_structures( MSIPACKAGE
* package
)
465 struct list
*item
, *cursor
;
467 TRACE("Freeing package action data\n");
469 remove_tracked_tempfiles(package
);
471 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->features
)
473 MSIFEATURE
*feature
= LIST_ENTRY( item
, MSIFEATURE
, entry
);
474 list_remove( &feature
->entry
);
475 free_feature( feature
);
478 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->folders
)
480 MSIFOLDER
*folder
= LIST_ENTRY( item
, MSIFOLDER
, entry
);
482 list_remove( &folder
->entry
);
483 msi_free( folder
->Directory
);
484 msi_free( folder
->TargetDefault
);
485 msi_free( folder
->SourceDefault
);
486 msi_free( folder
->ResolvedTarget
);
487 msi_free( folder
->ResolvedSource
);
488 msi_free( folder
->Property
);
492 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->components
)
494 MSICOMPONENT
*comp
= LIST_ENTRY( item
, MSICOMPONENT
, entry
);
496 list_remove( &comp
->entry
);
497 msi_free( comp
->Component
);
498 msi_free( comp
->ComponentId
);
499 msi_free( comp
->Directory
);
500 msi_free( comp
->Condition
);
501 msi_free( comp
->KeyPath
);
502 msi_free( comp
->FullKeypath
);
506 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->files
)
508 MSIFILE
*file
= LIST_ENTRY( item
, MSIFILE
, entry
);
510 list_remove( &file
->entry
);
511 msi_free( file
->File
);
512 msi_free( file
->FileName
);
513 msi_free( file
->ShortName
);
514 msi_free( file
->Version
);
515 msi_free( file
->Language
);
516 msi_free( file
->SourcePath
);
517 msi_free( file
->TargetPath
);
521 /* clean up extension, progid, class and verb structures */
522 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->classes
)
524 MSICLASS
*cls
= LIST_ENTRY( item
, MSICLASS
, entry
);
526 list_remove( &cls
->entry
);
527 msi_free( cls
->clsid
);
528 msi_free( cls
->Context
);
529 msi_free( cls
->Description
);
530 msi_free( cls
->FileTypeMask
);
531 msi_free( cls
->IconPath
);
532 msi_free( cls
->DefInprocHandler
);
533 msi_free( cls
->DefInprocHandler32
);
534 msi_free( cls
->Argument
);
535 msi_free( cls
->ProgIDText
);
539 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->extensions
)
541 MSIEXTENSION
*ext
= LIST_ENTRY( item
, MSIEXTENSION
, entry
);
543 list_remove( &ext
->entry
);
544 free_extension( ext
);
547 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->progids
)
549 MSIPROGID
*progid
= LIST_ENTRY( item
, MSIPROGID
, entry
);
551 list_remove( &progid
->entry
);
552 msi_free( progid
->ProgID
);
553 msi_free( progid
->Description
);
554 msi_free( progid
->IconPath
);
558 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->mimes
)
560 MSIMIME
*mt
= LIST_ENTRY( item
, MSIMIME
, entry
);
562 list_remove( &mt
->entry
);
563 msi_free( mt
->clsid
);
564 msi_free( mt
->ContentType
);
568 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->appids
)
570 MSIAPPID
*appid
= LIST_ENTRY( item
, MSIAPPID
, entry
);
572 list_remove( &appid
->entry
);
573 msi_free( appid
->AppID
);
574 msi_free( appid
->RemoteServerName
);
575 msi_free( appid
->LocalServer
);
576 msi_free( appid
->ServiceParameters
);
577 msi_free( appid
->DllSurrogate
);
583 for (i
= 0; i
< TOTAL_SCRIPTS
; i
++)
586 for (j
= 0; j
< package
->script
->ActionCount
[i
]; j
++)
587 msi_free(package
->script
->Actions
[i
][j
]);
589 msi_free(package
->script
->Actions
[i
]);
592 for (i
= 0; i
< package
->script
->UniqueActionsCount
; i
++)
593 msi_free(package
->script
->UniqueActions
[i
]);
595 msi_free(package
->script
->UniqueActions
);
596 msi_free(package
->script
);
599 msi_free(package
->PackagePath
);
600 msi_free(package
->ProductCode
);
601 msi_free(package
->ActionFormat
);
602 msi_free(package
->LastAction
);
604 /* cleanup control event subscriptions */
605 ControlEvent_CleanupSubscriptions(package
);
609 * build_directory_name()
611 * This function is to save messing round with directory names
612 * It handles adding backslashes between path segments,
613 * and can add \ at the end of the directory name if told to.
615 * It takes a variable number of arguments.
616 * It always allocates a new string for the result, so make sure
617 * to free the return value when finished with it.
619 * The first arg is the number of path segments that follow.
620 * The arguments following count are a list of path segments.
621 * A path segment may be NULL.
623 * Path segments will be added with a \ separating them.
624 * A \ will not be added after the last segment, however if the
625 * last segment is NULL, then the last character will be a \
628 LPWSTR
build_directory_name(DWORD count
, ...)
635 for(i
=0; i
<count
; i
++)
637 LPCWSTR str
= va_arg(va
,LPCWSTR
);
639 sz
+= strlenW(str
) + 1;
643 dir
= msi_alloc(sz
*sizeof(WCHAR
));
647 for(i
=0; i
<count
; i
++)
649 LPCWSTR str
= va_arg(va
,LPCWSTR
);
653 if( ((i
+1)!=count
) && dir
[strlenW(dir
)-1]!='\\')
659 /***********************************************************************
662 * Recursively create all directories in the path.
664 * shamelessly stolen from setupapi/queue.c
666 BOOL
create_full_pathW(const WCHAR
*path
)
672 new_path
= msi_alloc( (strlenW(path
) + 1) * sizeof(WCHAR
));
674 strcpyW(new_path
, path
);
676 while((len
= strlenW(new_path
)) && new_path
[len
- 1] == '\\')
677 new_path
[len
- 1] = 0;
679 while(!CreateDirectoryW(new_path
, NULL
))
682 DWORD last_error
= GetLastError();
683 if(last_error
== ERROR_ALREADY_EXISTS
)
686 if(last_error
!= ERROR_PATH_NOT_FOUND
)
692 if(!(slash
= strrchrW(new_path
, '\\')))
698 len
= slash
- new_path
;
700 if(!create_full_pathW(new_path
))
705 new_path
[len
] = '\\';
712 void ui_progress(MSIPACKAGE
*package
, int a
, int b
, int c
, int d
)
716 row
= MSI_CreateRecord(4);
717 MSI_RecordSetInteger(row
,1,a
);
718 MSI_RecordSetInteger(row
,2,b
);
719 MSI_RecordSetInteger(row
,3,c
);
720 MSI_RecordSetInteger(row
,4,d
);
721 MSI_ProcessMessage(package
, INSTALLMESSAGE_PROGRESS
, row
);
722 msiobj_release(&row
->hdr
);
724 msi_dialog_check_messages(NULL
);
727 void ui_actiondata(MSIPACKAGE
*package
, LPCWSTR action
, MSIRECORD
* record
)
729 static const WCHAR Query_t
[] =
730 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
731 '`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
732 'W','H','E','R','E',' ', '`','A','c','t','i','o','n','`',' ','=',
733 ' ','\'','%','s','\'',0};
737 static const WCHAR szActionData
[] =
738 {'A','c','t','i','o','n','D','a','t','a',0};
740 if (!package
->LastAction
|| strcmpW(package
->LastAction
,action
))
742 row
= MSI_QueryGetRecord(package
->db
, Query_t
, action
);
746 if (MSI_RecordIsNull(row
,3))
748 msiobj_release(&row
->hdr
);
752 /* update the cached actionformat */
753 msi_free(package
->ActionFormat
);
754 package
->ActionFormat
= load_dynamic_stringW(row
,3);
756 msi_free(package
->LastAction
);
757 package
->LastAction
= strdupW(action
);
759 msiobj_release(&row
->hdr
);
762 MSI_RecordSetStringW(record
,0,package
->ActionFormat
);
764 MSI_FormatRecordW(package
,record
,message
,&size
);
766 row
= MSI_CreateRecord(1);
767 MSI_RecordSetStringW(row
,1,message
);
769 MSI_ProcessMessage(package
, INSTALLMESSAGE_ACTIONDATA
, row
);
771 ControlEvent_FireSubscribedEvent(package
,szActionData
, row
);
773 msiobj_release(&row
->hdr
);
776 BOOL
ACTION_VerifyComponentForAction(MSIPACKAGE
* package
, MSICOMPONENT
* comp
,
782 if (comp
->Installed
== check
)
785 if (comp
->ActionRequest
== check
)
791 BOOL
ACTION_VerifyFeatureForAction( MSIFEATURE
* feature
, INSTALLSTATE check
)
796 if (feature
->Installed
== check
)
799 if (feature
->ActionRequest
== check
)
805 void reduce_to_longfilename(WCHAR
* filename
)
807 LPWSTR p
= strchrW(filename
,'|');
809 memmove(filename
, p
+1, (strlenW(p
+1)+1)*sizeof(WCHAR
));
812 void reduce_to_shortfilename(WCHAR
* filename
)
814 LPWSTR p
= strchrW(filename
,'|');
819 LPWSTR
create_component_advertise_string(MSIPACKAGE
* package
,
820 MSICOMPONENT
* component
, LPCWSTR feature
)
823 WCHAR productid_85
[21];
824 WCHAR component_85
[21];
826 * I have a fair bit of confusion as to when a < is used and when a > is
827 * used. I do not think i have it right...
829 * Ok it appears that the > is used if there is a guid for the compoenent
830 * and the < is used if not.
832 static WCHAR fmt1
[] = {'%','s','%','s','<',0,0};
833 static WCHAR fmt2
[] = {'%','s','%','s','>','%','s',0,0};
834 LPWSTR output
= NULL
;
837 memset(productid_85
,0,sizeof(productid_85
));
838 memset(component_85
,0,sizeof(component_85
));
840 CLSIDFromString(package
->ProductCode
, &clsid
);
842 encode_base85_guid(&clsid
,productid_85
);
844 CLSIDFromString(component
->ComponentId
, &clsid
);
845 encode_base85_guid(&clsid
,component_85
);
847 TRACE("Doing something with this... %s %s %s\n",
848 debugstr_w(productid_85
), debugstr_w(feature
),
849 debugstr_w(component_85
));
851 sz
= lstrlenW(productid_85
) + lstrlenW(feature
);
853 sz
+= lstrlenW(component_85
);
858 output
= msi_alloc(sz
);
862 sprintfW(output
,fmt2
,productid_85
,feature
,component_85
);
864 sprintfW(output
,fmt1
,productid_85
,feature
);
869 /* update compoennt state based on a feature change */
870 void ACTION_UpdateComponentStates(MSIPACKAGE
*package
, LPCWSTR szFeature
)
872 INSTALLSTATE newstate
;
876 feature
= get_loaded_feature(package
,szFeature
);
880 newstate
= feature
->ActionRequest
;
882 LIST_FOR_EACH_ENTRY( cl
, &feature
->Components
, ComponentList
, entry
)
884 MSICOMPONENT
* component
= cl
->component
;
886 TRACE("MODIFYING(%i): Component %s (Installed %i, Action %i, Request %i)\n",
887 newstate
, debugstr_w(component
->Component
), component
->Installed
,
888 component
->Action
, component
->ActionRequest
);
890 if (!component
->Enabled
)
893 if (newstate
== INSTALLSTATE_LOCAL
)
895 component
->ActionRequest
= INSTALLSTATE_LOCAL
;
896 component
->Action
= INSTALLSTATE_LOCAL
;
900 ComponentList
*clist
;
903 component
->ActionRequest
= newstate
;
904 component
->Action
= newstate
;
906 /*if any other feature wants is local we need to set it local*/
907 LIST_FOR_EACH_ENTRY( f
, &package
->features
, MSIFEATURE
, entry
)
909 if ( component
->ActionRequest
!= INSTALLSTATE_LOCAL
)
912 LIST_FOR_EACH_ENTRY( clist
, &f
->Components
, ComponentList
, entry
)
914 if ( clist
->component
== component
)
916 if (f
->ActionRequest
== INSTALLSTATE_LOCAL
)
918 TRACE("Saved by %s\n", debugstr_w(f
->Feature
));
919 component
->ActionRequest
= INSTALLSTATE_LOCAL
;
920 component
->Action
= INSTALLSTATE_LOCAL
;
927 TRACE("Result (%i): Component %s (Installed %i, Action %i, Request %i)\n",
928 newstate
, debugstr_w(component
->Component
), component
->Installed
,
929 component
->Action
, component
->ActionRequest
);
933 UINT
register_unique_action(MSIPACKAGE
*package
, LPCWSTR action
)
936 LPWSTR
*newbuf
= NULL
;
938 if (!package
|| !package
->script
)
941 TRACE("Registering Action %s as having fun\n",debugstr_w(action
));
943 count
= package
->script
->UniqueActionsCount
;
944 package
->script
->UniqueActionsCount
++;
946 newbuf
= msi_realloc( package
->script
->UniqueActions
,
947 package
->script
->UniqueActionsCount
* sizeof(LPWSTR
));
949 newbuf
= msi_alloc( sizeof(LPWSTR
));
951 newbuf
[count
] = strdupW(action
);
952 package
->script
->UniqueActions
= newbuf
;
954 return ERROR_SUCCESS
;
957 BOOL
check_unique_action(MSIPACKAGE
*package
, LPCWSTR action
)
961 if (!package
|| !package
->script
)
964 for (i
= 0; i
< package
->script
->UniqueActionsCount
; i
++)
965 if (!strcmpW(package
->script
->UniqueActions
[i
],action
))
971 WCHAR
* generate_error_string(MSIPACKAGE
*package
, UINT error
, DWORD count
, ... )
973 static const WCHAR query
[] = {'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ','F','R','O','M',' ','`','E','r','r','o','r','`',' ','W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ','%','i',0};
983 row
= MSI_QueryGetRecord(package
->db
, query
, error
);
987 rec
= MSI_CreateRecord(count
+2);
989 str
= MSI_RecordGetString(row
,1);
990 MSI_RecordSetStringW(rec
,0,str
);
991 msiobj_release( &row
->hdr
);
992 MSI_RecordSetInteger(rec
,1,error
);
995 for (i
= 0; i
< count
; i
++)
997 str
= va_arg(va
,LPCWSTR
);
998 MSI_RecordSetStringW(rec
,(i
+2),str
);
1002 MSI_FormatRecordW(package
,rec
,NULL
,&size
);
1006 data
= msi_alloc(size
*sizeof(WCHAR
));
1008 MSI_FormatRecordW(package
,rec
,data
,&size
);
1011 msiobj_release( &rec
->hdr
);
1015 msiobj_release( &rec
->hdr
);