Rework CreateShortcuts to use MSI_IterateRecords.

This commit is contained in:
Aric Stewart 2005-06-24 11:58:21 +00:00 committed by Alexandre Julliard
parent b9a3f8fabf
commit 9adacf6a72
1 changed files with 144 additions and 165 deletions

View File

@ -2787,75 +2787,33 @@ static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package)
return rc;
}
static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
{
UINT rc;
MSIQUERY * view;
MSIRECORD * row = 0;
static const WCHAR Query[] =
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
'`','S','h','o','r','t','c','u','t','`',0};
IShellLinkW *sl;
IPersistFile *pf;
HRESULT res;
if (!package)
return ERROR_INVALID_HANDLE;
res = CoInitialize( NULL );
if (FAILED (res))
{
ERR("CoInitialize failed\n");
return ERROR_FUNCTION_FAILED;
}
rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
if (rc != ERROR_SUCCESS)
return ERROR_SUCCESS;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
while (1)
static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param)
{
MSIPACKAGE *package = (MSIPACKAGE*)param;
LPWSTR target_file, target_folder;
LPCWSTR buffer;
WCHAR filename[0x100];
DWORD sz;
DWORD index;
static const WCHAR szlnk[]={'.','l','n','k',0};
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
rc = ERROR_SUCCESS;
break;
}
IShellLinkW *sl;
IPersistFile *pf;
HRESULT res;
buffer = MSI_RecordGetString(row,4);
index = get_loaded_component(package,buffer);
if (index < 0)
{
msiobj_release(&row->hdr);
continue;
}
return ERROR_SUCCESS;
if (!ACTION_VerifyComponentForAction(package, index,
INSTALLSTATE_LOCAL))
if (!ACTION_VerifyComponentForAction(package, index, INSTALLSTATE_LOCAL))
{
TRACE("Skipping shortcut creation due to disabled component\n");
msiobj_release(&row->hdr);
package->components[index].Action =
package->components[index].Installed;
continue;
return ERROR_SUCCESS;
}
package->components[index].Action = INSTALLSTATE_LOCAL;
@ -2868,16 +2826,14 @@ static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
if (FAILED(res))
{
ERR("Is IID_IShellLink\n");
msiobj_release(&row->hdr);
continue;
return ERROR_SUCCESS;
}
res = IShellLinkW_QueryInterface( sl, &IID_IPersistFile,(LPVOID*) &pf );
if( FAILED( res ) )
{
ERR("Is IID_IPersistFile\n");
msiobj_release(&row->hdr);
continue;
return ERROR_SUCCESS;
}
buffer = MSI_RecordGetString(row,2);
@ -2963,11 +2919,34 @@ static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
IPersistFile_Release( pf );
IShellLinkW_Release( sl );
msiobj_release(&row->hdr);
return ERROR_SUCCESS;
}
MSI_ViewClose(view);
msiobj_release(&view->hdr);
static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
{
UINT rc;
HRESULT res;
MSIQUERY * view;
static const WCHAR Query[] =
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
'`','S','h','o','r','t','c','u','t','`',0};
if (!package)
return ERROR_INVALID_HANDLE;
rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
if (rc != ERROR_SUCCESS)
return ERROR_SUCCESS;
res = CoInitialize( NULL );
if (FAILED (res))
{
ERR("CoInitialize failed\n");
return ERROR_FUNCTION_FAILED;
}
rc = MSI_IterateRecords(view, NULL, ITERATE_CreateShortcuts, package);
msiobj_release(&view->hdr);
CoUninitialize();