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 UINT build_icon_path(MSIPACKAGE *package, LPCWSTR icon_name,
93 static const WCHAR szInstaller[] =
94 {'M','i','c','r','o','s','o','f','t','\\',
95 'I','n','s','t','a','l','l','e','r','\\',0};
96 static const WCHAR szFolder[] =
97 {'A','p','p','D','a','t','a','F','o','l','d','e','r',0};
99 SystemFolder = load_dynamic_property(package,szFolder,NULL);
101 dest = build_directory_name(3, SystemFolder, szInstaller, package->ProductCode);
103 create_full_pathW(dest);
105 *FilePath = build_directory_name(2, dest, icon_name);
107 HeapFree(GetProcessHeap(),0,SystemFolder);
108 HeapFree(GetProcessHeap(),0,dest);
109 return ERROR_SUCCESS;
112 WCHAR *load_dynamic_stringW(MSIRECORD *row, INT index)
119 if (MSI_RecordIsNull(row,index))
122 rc = MSI_RecordGetStringW(row,index,NULL,&sz);
124 /* having an empty string is different than NULL */
127 ret = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR));
133 ret = HeapAlloc(GetProcessHeap(),0,sz * sizeof (WCHAR));
134 rc = MSI_RecordGetStringW(row,index,ret,&sz);
135 if (rc!=ERROR_SUCCESS)
137 ERR("Unable to load dynamic string\n");
138 HeapFree(GetProcessHeap(), 0, ret);
144 LPWSTR load_dynamic_property(MSIPACKAGE *package, LPCWSTR prop, UINT* rc)
150 r = MSI_GetPropertyW(package, prop, NULL, &sz);
151 if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA)
158 str = HeapAlloc(GetProcessHeap(),0,sz*sizeof(WCHAR));
159 r = MSI_GetPropertyW(package, prop, str, &sz);
160 if (r != ERROR_SUCCESS)
162 HeapFree(GetProcessHeap(),0,str);
170 MSICOMPONENT* get_loaded_component( MSIPACKAGE* package, LPCWSTR Component )
174 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
176 if (lstrcmpW(Component,comp->Component)==0)
182 MSIFEATURE* get_loaded_feature(MSIPACKAGE* package, LPCWSTR Feature )
186 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
188 if (lstrcmpW( Feature, feature->Feature )==0)
194 MSIFILE* get_loaded_file( MSIPACKAGE* package, LPCWSTR key )
198 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
200 if (lstrcmpW( key, file->File )==0)
206 int track_tempfile( MSIPACKAGE *package, LPCWSTR name, LPCWSTR path )
213 LIST_FOR_EACH_ENTRY( temp, &package->tempfiles, MSITEMPFILE, entry )
215 if (lstrcmpW( name, temp->File )==0)
217 TRACE("tempfile %s already exists with path %s\n",
218 debugstr_w(temp->File), debugstr_w(temp->Path));
223 temp = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof (MSITEMPFILE) );
227 list_add_head( &package->tempfiles, &temp->entry );
229 temp->File = strdupW( name );
230 temp->Path = strdupW( path );
232 TRACE("adding tempfile %s with path %s\n",
233 debugstr_w(temp->File), debugstr_w(temp->Path));
238 MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir )
242 LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry )
244 if (lstrcmpW( dir, folder->Directory )==0)
250 LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
251 BOOL set_prop, MSIFOLDER **folder)
254 LPWSTR p, path = NULL;
256 TRACE("Working to resolve %s\n",debugstr_w(name));
261 /* special resolving for Target and Source root dir */
262 if (strcmpW(name,cszTargetDir)==0 || strcmpW(name,cszSourceDir)==0)
267 check_path = load_dynamic_property(package,cszTargetDir,NULL);
270 check_path = load_dynamic_property(package,cszRootDrive,NULL);
272 MSI_SetPropertyW(package,cszTargetDir,check_path);
275 /* correct misbuilt target dir */
276 path = build_directory_name(2, check_path, NULL);
277 if (strcmpiW(path,check_path)!=0)
278 MSI_SetPropertyW(package,cszTargetDir,path);
279 HeapFree(GetProcessHeap(),0,check_path);
283 path = load_dynamic_property(package,cszSourceDir,NULL);
286 path = load_dynamic_property(package,cszDatabase,NULL);
289 p = strrchrW(path,'\\');
296 *folder = get_loaded_folder( package, name );
300 f = get_loaded_folder( package, name );
307 if (!source && f->ResolvedTarget)
309 path = strdupW( f->ResolvedTarget );
310 TRACE(" already resolved to %s\n",debugstr_w(path));
313 else if (source && f->ResolvedSource)
315 path = strdupW( f->ResolvedSource );
316 TRACE(" (source)already resolved to %s\n",debugstr_w(path));
319 else if (!source && f->Property)
321 path = build_directory_name( 2, f->Property, NULL );
323 TRACE(" internally set to %s\n",debugstr_w(path));
325 MSI_SetPropertyW( package, name, path );
331 LPWSTR parent = f->Parent->Directory;
333 TRACE(" ! Parent is %s\n", debugstr_w(parent));
335 p = resolve_folder(package, parent, source, set_prop, NULL);
338 TRACE(" TargetDefault = %s\n", debugstr_w(f->TargetDefault));
340 path = build_directory_name( 3, p, f->TargetDefault, NULL );
341 f->ResolvedTarget = strdupW( path );
342 TRACE(" resolved into %s\n",debugstr_w(path));
344 MSI_SetPropertyW(package,name,path);
348 if (f->SourceDefault && f->SourceDefault[0]!='.')
349 path = build_directory_name( 3, p, f->SourceDefault, NULL );
352 TRACE(" (source)resolved into %s\n",debugstr_w(path));
353 f->ResolvedSource = strdupW( path );
355 HeapFree(GetProcessHeap(),0,p);
360 /* wrapper to resist a need for a full rewrite right now */
361 DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data )
365 MSIRECORD *rec = MSI_CreateRecord(1);
368 MSI_RecordSetStringW(rec,0,ptr);
369 MSI_FormatRecordW(package,rec,NULL,&size);
373 *data = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR));
375 MSI_FormatRecordW(package,rec,*data,&size);
378 msiobj_release( &rec->hdr );
379 return sizeof(WCHAR)*size;
381 msiobj_release( &rec->hdr );
388 UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action)
391 LPWSTR *newbuf = NULL;
392 if (script >= TOTAL_SCRIPTS)
394 FIXME("Unknown script requested %i\n",script);
395 return ERROR_FUNCTION_FAILED;
397 TRACE("Scheduling Action %s in script %i\n",debugstr_w(action), script);
399 count = package->script->ActionCount[script];
400 package->script->ActionCount[script]++;
402 newbuf = HeapReAlloc(GetProcessHeap(),0,
403 package->script->Actions[script],
404 package->script->ActionCount[script]* sizeof(LPWSTR));
406 newbuf = HeapAlloc(GetProcessHeap(),0, sizeof(LPWSTR));
408 newbuf[count] = strdupW(action);
409 package->script->Actions[script] = newbuf;
411 return ERROR_SUCCESS;
414 static void remove_tracked_tempfiles(MSIPACKAGE* package)
416 struct list *item, *cursor;
418 LIST_FOR_EACH_SAFE( item, cursor, &package->tempfiles )
420 MSITEMPFILE *temp = LIST_ENTRY( item, MSITEMPFILE, entry );
422 list_remove( &temp->entry );
423 TRACE("deleting temp file %s\n", debugstr_w( temp->Path ));
424 DeleteFileW( temp->Path );
425 HeapFree( GetProcessHeap(), 0, temp->File );
426 HeapFree( GetProcessHeap(), 0, temp->Path );
427 HeapFree( GetProcessHeap(), 0, temp );
431 static void free_feature( MSIFEATURE *feature )
433 struct list *item, *cursor;
435 LIST_FOR_EACH_SAFE( item, cursor, &feature->Components )
437 ComponentList *cl = LIST_ENTRY( item, ComponentList, entry );
438 list_remove( &cl->entry );
439 HeapFree( GetProcessHeap(), 0, cl );
441 HeapFree( GetProcessHeap(), 0, feature->Description );
442 HeapFree( GetProcessHeap(), 0, feature->Title );
443 HeapFree( GetProcessHeap(), 0, feature );
446 void free_extension( MSIEXTENSION *ext )
448 struct list *item, *cursor;
450 LIST_FOR_EACH_SAFE( item, cursor, &ext->verbs )
452 MSIVERB *verb = LIST_ENTRY( item, MSIVERB, entry );
454 list_remove( &verb->entry );
455 HeapFree( GetProcessHeap(), 0, verb->Verb );
456 HeapFree( GetProcessHeap(), 0, verb->Command );
457 HeapFree( GetProcessHeap(), 0, verb->Argument );
458 HeapFree( GetProcessHeap(), 0, verb );
461 HeapFree( GetProcessHeap(), 0, ext->Extension );
462 HeapFree( GetProcessHeap(), 0, ext->ProgIDText );
463 HeapFree( GetProcessHeap(), 0, ext );
466 /* Called when the package is being closed */
467 void ACTION_free_package_structures( MSIPACKAGE* package)
470 struct list *item, *cursor;
472 TRACE("Freeing package action data\n");
474 remove_tracked_tempfiles(package);
476 LIST_FOR_EACH_SAFE( item, cursor, &package->features )
478 MSIFEATURE *feature = LIST_ENTRY( item, MSIFEATURE, entry );
479 list_remove( &feature->entry );
480 free_feature( feature );
483 LIST_FOR_EACH_SAFE( item, cursor, &package->folders )
485 MSIFOLDER *folder = LIST_ENTRY( item, MSIFOLDER, entry );
487 list_remove( &folder->entry );
488 HeapFree( GetProcessHeap(), 0, folder->Directory );
489 HeapFree( GetProcessHeap(), 0, folder->TargetDefault );
490 HeapFree( GetProcessHeap(), 0, folder->SourceDefault );
491 HeapFree( GetProcessHeap(), 0, folder->ResolvedTarget );
492 HeapFree( GetProcessHeap(), 0, folder->ResolvedSource );
493 HeapFree( GetProcessHeap(), 0, folder->Property );
496 LIST_FOR_EACH_SAFE( item, cursor, &package->components )
498 MSICOMPONENT *comp = LIST_ENTRY( item, MSICOMPONENT, entry );
500 list_remove( &comp->entry );
501 HeapFree( GetProcessHeap(), 0, comp->Condition );
502 HeapFree( GetProcessHeap(), 0, comp->FullKeypath );
503 HeapFree( GetProcessHeap(), 0, comp );
506 LIST_FOR_EACH_SAFE( item, cursor, &package->files )
508 MSIFILE *file = LIST_ENTRY( item, MSIFILE, entry );
510 list_remove( &file->entry );
511 HeapFree( GetProcessHeap(), 0, file->File );
512 HeapFree( GetProcessHeap(), 0, file->FileName );
513 HeapFree( GetProcessHeap(), 0, file->ShortName );
514 HeapFree( GetProcessHeap(), 0, file->Version );
515 HeapFree( GetProcessHeap(), 0, file->Language );
516 HeapFree( GetProcessHeap(), 0, file->SourcePath );
517 HeapFree( GetProcessHeap(), 0, file->TargetPath );
518 HeapFree( GetProcessHeap(), 0, file );
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 HeapFree( GetProcessHeap(), 0, cls->Description );
528 HeapFree( GetProcessHeap(), 0, cls->FileTypeMask );
529 HeapFree( GetProcessHeap(), 0, cls->IconPath );
530 HeapFree( GetProcessHeap(), 0, cls->DefInprocHandler );
531 HeapFree( GetProcessHeap(), 0, cls->DefInprocHandler32 );
532 HeapFree( GetProcessHeap(), 0, cls->Argument );
533 HeapFree( GetProcessHeap(), 0, cls->ProgIDText );
534 HeapFree( GetProcessHeap(), 0, cls );
537 LIST_FOR_EACH_SAFE( item, cursor, &package->extensions )
539 MSIEXTENSION *ext = LIST_ENTRY( item, MSIEXTENSION, entry );
541 list_remove( &ext->entry );
542 free_extension( ext );
545 LIST_FOR_EACH_SAFE( item, cursor, &package->progids )
547 MSIPROGID *progid = LIST_ENTRY( item, MSIPROGID, entry );
549 list_remove( &progid->entry );
550 HeapFree( GetProcessHeap(), 0, progid->ProgID );
551 HeapFree( GetProcessHeap(), 0, progid->Description );
552 HeapFree( GetProcessHeap(), 0, progid->IconPath );
553 HeapFree( GetProcessHeap(), 0, progid );
556 LIST_FOR_EACH_SAFE( item, cursor, &package->mimes )
558 MSIMIME *mt = LIST_ENTRY( item, MSIMIME, entry );
560 list_remove( &mt->entry );
561 HeapFree( GetProcessHeap(), 0, mt->ContentType );
562 HeapFree( GetProcessHeap(), 0, mt );
565 LIST_FOR_EACH_SAFE( item, cursor, &package->appids )
567 MSIAPPID *appid = LIST_ENTRY( item, MSIAPPID, entry );
569 list_remove( &appid->entry );
570 HeapFree( GetProcessHeap(), 0, appid->RemoteServerName );
571 HeapFree( GetProcessHeap(), 0, appid->LocalServer );
572 HeapFree( GetProcessHeap(), 0, appid->ServiceParameters );
573 HeapFree( GetProcessHeap(), 0, appid->DllSurrogate );
574 HeapFree( GetProcessHeap(), 0, appid );
579 for (i = 0; i < TOTAL_SCRIPTS; i++)
582 for (j = 0; j < package->script->ActionCount[i]; j++)
583 HeapFree(GetProcessHeap(),0,package->script->Actions[i][j]);
585 HeapFree(GetProcessHeap(),0,package->script->Actions[i]);
588 for (i = 0; i < package->script->UniqueActionsCount; i++)
589 HeapFree(GetProcessHeap(),0,package->script->UniqueActions[i]);
591 HeapFree(GetProcessHeap(),0,package->script->UniqueActions);
592 HeapFree(GetProcessHeap(),0,package->script);
595 HeapFree(GetProcessHeap(),0,package->PackagePath);
596 HeapFree(GetProcessHeap(),0,package->msiFilePath);
597 HeapFree(GetProcessHeap(),0,package->ProductCode);
599 /* cleanup control event subscriptions */
600 ControlEvent_CleanupSubscriptions(package);
604 * build_directory_name()
606 * This function is to save messing round with directory names
607 * It handles adding backslashes between path segments,
608 * and can add \ at the end of the directory name if told to.
610 * It takes a variable number of arguments.
611 * It always allocates a new string for the result, so make sure
612 * to free the return value when finished with it.
614 * The first arg is the number of path segments that follow.
615 * The arguments following count are a list of path segments.
616 * A path segment may be NULL.
618 * Path segments will be added with a \ separating them.
619 * A \ will not be added after the last segment, however if the
620 * last segment is NULL, then the last character will be a \
623 LPWSTR build_directory_name(DWORD count, ...)
630 for(i=0; i<count; i++)
632 LPCWSTR str = va_arg(va,LPCWSTR);
634 sz += strlenW(str) + 1;
638 dir = HeapAlloc(GetProcessHeap(), 0, sz*sizeof(WCHAR));
642 for(i=0; i<count; i++)
644 LPCWSTR str = va_arg(va,LPCWSTR);
648 if( ((i+1)!=count) && dir[strlenW(dir)-1]!='\\')
654 /***********************************************************************
657 * Recursively create all directories in the path.
659 * shamelessly stolen from setupapi/queue.c
661 BOOL create_full_pathW(const WCHAR *path)
667 new_path = HeapAlloc(GetProcessHeap(), 0, (strlenW(path) + 1) *
670 strcpyW(new_path, path);
672 while((len = strlenW(new_path)) && new_path[len - 1] == '\\')
673 new_path[len - 1] = 0;
675 while(!CreateDirectoryW(new_path, NULL))
678 DWORD last_error = GetLastError();
679 if(last_error == ERROR_ALREADY_EXISTS)
682 if(last_error != ERROR_PATH_NOT_FOUND)
688 if(!(slash = strrchrW(new_path, '\\')))
694 len = slash - new_path;
696 if(!create_full_pathW(new_path))
701 new_path[len] = '\\';
704 HeapFree(GetProcessHeap(), 0, new_path);
708 void ui_progress(MSIPACKAGE *package, int a, int b, int c, int d )
712 row = MSI_CreateRecord(4);
713 MSI_RecordSetInteger(row,1,a);
714 MSI_RecordSetInteger(row,2,b);
715 MSI_RecordSetInteger(row,3,c);
716 MSI_RecordSetInteger(row,4,d);
717 MSI_ProcessMessage(package, INSTALLMESSAGE_PROGRESS, row);
718 msiobj_release(&row->hdr);
720 msi_dialog_check_messages(NULL);
723 void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * record)
725 static const WCHAR Query_t[] =
726 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
727 '`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
728 'W','H','E','R','E',' ', '`','A','c','t','i','o','n','`',' ','=',
729 ' ','\'','%','s','\'',0};
733 static const WCHAR szActionData[] =
734 {'A','c','t','i','o','n','D','a','t','a',0};
736 if (!package->LastAction || strcmpW(package->LastAction,action))
738 row = MSI_QueryGetRecord(package->db, Query_t, action);
742 if (MSI_RecordIsNull(row,3))
744 msiobj_release(&row->hdr);
748 /* update the cached actionformat */
749 HeapFree(GetProcessHeap(),0,package->ActionFormat);
750 package->ActionFormat = load_dynamic_stringW(row,3);
752 HeapFree(GetProcessHeap(),0,package->LastAction);
753 package->LastAction = strdupW(action);
755 msiobj_release(&row->hdr);
758 MSI_RecordSetStringW(record,0,package->ActionFormat);
760 MSI_FormatRecordW(package,record,message,&size);
762 row = MSI_CreateRecord(1);
763 MSI_RecordSetStringW(row,1,message);
765 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, row);
767 ControlEvent_FireSubscribedEvent(package,szActionData, row);
769 msiobj_release(&row->hdr);
772 BOOL ACTION_VerifyComponentForAction(MSIPACKAGE* package, MSICOMPONENT* comp,
775 if (comp->Installed == check)
778 if (comp->ActionRequest == check)
784 BOOL ACTION_VerifyFeatureForAction( MSIFEATURE* feature, INSTALLSTATE check )
786 if (feature->Installed == check)
789 if (feature->ActionRequest == check)
795 void reduce_to_longfilename(WCHAR* filename)
797 LPWSTR p = strchrW(filename,'|');
799 memmove(filename, p+1, (strlenW(p+1)+1)*sizeof(WCHAR));
802 void reduce_to_shortfilename(WCHAR* filename)
804 LPWSTR p = strchrW(filename,'|');
809 LPWSTR create_component_advertise_string(MSIPACKAGE* package,
810 MSICOMPONENT* component, LPCWSTR feature)
813 WCHAR productid_85[21];
814 WCHAR component_85[21];
816 * I have a fair bit of confusion as to when a < is used and when a > is
817 * used. I do not think i have it right...
819 * Ok it appears that the > is used if there is a guid for the compoenent
820 * and the < is used if not.
822 static WCHAR fmt1[] = {'%','s','%','s','<',0,0};
823 static WCHAR fmt2[] = {'%','s','%','s','>','%','s',0,0};
824 LPWSTR output = NULL;
827 memset(productid_85,0,sizeof(productid_85));
828 memset(component_85,0,sizeof(component_85));
830 CLSIDFromString(package->ProductCode, &clsid);
832 encode_base85_guid(&clsid,productid_85);
834 CLSIDFromString(component->ComponentId, &clsid);
835 encode_base85_guid(&clsid,component_85);
837 TRACE("Doing something with this... %s %s %s\n",
838 debugstr_w(productid_85), debugstr_w(feature),
839 debugstr_w(component_85));
841 sz = lstrlenW(productid_85) + lstrlenW(feature);
843 sz += lstrlenW(component_85);
848 output = HeapAlloc(GetProcessHeap(),0,sz);
852 sprintfW(output,fmt2,productid_85,feature,component_85);
854 sprintfW(output,fmt1,productid_85,feature);
859 /* update compoennt state based on a feature change */
860 void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature)
862 INSTALLSTATE newstate;
866 feature = get_loaded_feature(package,szFeature);
870 newstate = feature->ActionRequest;
872 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
874 MSICOMPONENT* component = cl->component;
876 TRACE("MODIFYING(%i): Component %s (Installed %i, Action %i, Request %i)\n",
877 newstate, debugstr_w(component->Component), component->Installed,
878 component->Action, component->ActionRequest);
880 if (!component->Enabled)
883 if (newstate == INSTALLSTATE_LOCAL)
885 component->ActionRequest = INSTALLSTATE_LOCAL;
886 component->Action = INSTALLSTATE_LOCAL;
890 ComponentList *clist;
893 component->ActionRequest = newstate;
894 component->Action = newstate;
896 /*if any other feature wants is local we need to set it local*/
897 LIST_FOR_EACH_ENTRY( f, &package->features, MSIFEATURE, entry )
899 if ( component->ActionRequest != INSTALLSTATE_LOCAL )
902 LIST_FOR_EACH_ENTRY( clist, &f->Components, ComponentList, entry )
904 if ( clist->component == component )
906 if (f->ActionRequest == INSTALLSTATE_LOCAL)
908 TRACE("Saved by %s\n", debugstr_w(f->Feature));
909 component->ActionRequest = INSTALLSTATE_LOCAL;
910 component->Action = INSTALLSTATE_LOCAL;
917 TRACE("Result (%i): Component %s (Installed %i, Action %i, Request %i)\n",
918 newstate, debugstr_w(component->Component), component->Installed,
919 component->Action, component->ActionRequest);
923 UINT register_unique_action(MSIPACKAGE *package, LPCWSTR action)
926 LPWSTR *newbuf = NULL;
928 if (!package || !package->script)
931 TRACE("Registering Action %s as having fun\n",debugstr_w(action));
933 count = package->script->UniqueActionsCount;
934 package->script->UniqueActionsCount++;
936 newbuf = HeapReAlloc(GetProcessHeap(),0,
937 package->script->UniqueActions,
938 package->script->UniqueActionsCount* sizeof(LPWSTR));
940 newbuf = HeapAlloc(GetProcessHeap(),0, sizeof(LPWSTR));
942 newbuf[count] = strdupW(action);
943 package->script->UniqueActions = newbuf;
945 return ERROR_SUCCESS;
948 BOOL check_unique_action(MSIPACKAGE *package, LPCWSTR action)
952 if (!package || !package->script)
955 for (i = 0; i < package->script->UniqueActionsCount; i++)
956 if (!strcmpW(package->script->UniqueActions[i],action))
962 WCHAR* generate_error_string(MSIPACKAGE *package, UINT error, DWORD count, ... )
964 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};
974 row = MSI_QueryGetRecord(package->db, query, error);
978 rec = MSI_CreateRecord(count+2);
980 str = MSI_RecordGetString(row,1);
981 MSI_RecordSetStringW(rec,0,str);
982 msiobj_release( &row->hdr );
983 MSI_RecordSetInteger(rec,1,error);
986 for (i = 0; i < count; i++)
988 str = va_arg(va,LPCWSTR);
989 MSI_RecordSetStringW(rec,(i+2),str);
993 MSI_FormatRecordW(package,rec,NULL,&size);
997 data = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR));
999 MSI_FormatRecordW(package,rec,data,&size);
1002 msiobj_release( &rec->hdr );
1006 msiobj_release( &rec->hdr );