Rework CreateShortcuts to use MSI_IterateRecords.
This commit is contained in:
parent
b9a3f8fabf
commit
9adacf6a72
|
@ -2787,75 +2787,33 @@ static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
|
static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
|
MSIPACKAGE *package = (MSIPACKAGE*)param;
|
||||||
LPWSTR target_file, target_folder;
|
LPWSTR target_file, target_folder;
|
||||||
LPCWSTR buffer;
|
LPCWSTR buffer;
|
||||||
WCHAR filename[0x100];
|
WCHAR filename[0x100];
|
||||||
DWORD sz;
|
DWORD sz;
|
||||||
DWORD index;
|
DWORD index;
|
||||||
static const WCHAR szlnk[]={'.','l','n','k',0};
|
static const WCHAR szlnk[]={'.','l','n','k',0};
|
||||||
|
IShellLinkW *sl;
|
||||||
rc = MSI_ViewFetch(view,&row);
|
IPersistFile *pf;
|
||||||
if (rc != ERROR_SUCCESS)
|
HRESULT res;
|
||||||
{
|
|
||||||
rc = ERROR_SUCCESS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = MSI_RecordGetString(row,4);
|
buffer = MSI_RecordGetString(row,4);
|
||||||
index = get_loaded_component(package,buffer);
|
index = get_loaded_component(package,buffer);
|
||||||
|
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
return ERROR_SUCCESS;
|
||||||
msiobj_release(&row->hdr);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ACTION_VerifyComponentForAction(package, index,
|
if (!ACTION_VerifyComponentForAction(package, index, INSTALLSTATE_LOCAL))
|
||||||
INSTALLSTATE_LOCAL))
|
|
||||||
{
|
{
|
||||||
TRACE("Skipping shortcut creation due to disabled component\n");
|
TRACE("Skipping shortcut creation due to disabled component\n");
|
||||||
msiobj_release(&row->hdr);
|
|
||||||
|
|
||||||
package->components[index].Action =
|
package->components[index].Action =
|
||||||
package->components[index].Installed;
|
package->components[index].Installed;
|
||||||
|
|
||||||
continue;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
package->components[index].Action = INSTALLSTATE_LOCAL;
|
package->components[index].Action = INSTALLSTATE_LOCAL;
|
||||||
|
@ -2868,16 +2826,14 @@ static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
|
||||||
if (FAILED(res))
|
if (FAILED(res))
|
||||||
{
|
{
|
||||||
ERR("Is IID_IShellLink\n");
|
ERR("Is IID_IShellLink\n");
|
||||||
msiobj_release(&row->hdr);
|
return ERROR_SUCCESS;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res = IShellLinkW_QueryInterface( sl, &IID_IPersistFile,(LPVOID*) &pf );
|
res = IShellLinkW_QueryInterface( sl, &IID_IPersistFile,(LPVOID*) &pf );
|
||||||
if( FAILED( res ) )
|
if( FAILED( res ) )
|
||||||
{
|
{
|
||||||
ERR("Is IID_IPersistFile\n");
|
ERR("Is IID_IPersistFile\n");
|
||||||
msiobj_release(&row->hdr);
|
return ERROR_SUCCESS;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = MSI_RecordGetString(row,2);
|
buffer = MSI_RecordGetString(row,2);
|
||||||
|
@ -2963,11 +2919,34 @@ static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
|
||||||
IPersistFile_Release( pf );
|
IPersistFile_Release( pf );
|
||||||
IShellLinkW_Release( sl );
|
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();
|
CoUninitialize();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue