setupapi: Implement FLG_PROFITEM_GROUP.
This commit is contained in:
parent
273357264a
commit
b7fe5e0aa5
|
@ -787,9 +787,6 @@ static BOOL profile_items_callback( HINF hinf, PCWSTR field, void *arg )
|
||||||
LPWSTR cmdline=NULL, lnkpath_end;
|
LPWSTR cmdline=NULL, lnkpath_end;
|
||||||
unsigned int name_size;
|
unsigned int name_size;
|
||||||
INFCONTEXT name_context, context;
|
INFCONTEXT name_context, context;
|
||||||
IShellLinkW* shelllink=NULL;
|
|
||||||
IPersistFile* persistfile=NULL;
|
|
||||||
HRESULT initresult=E_FAIL;
|
|
||||||
int attrs=0;
|
int attrs=0;
|
||||||
|
|
||||||
static const WCHAR dotlnk[] = {'.','l','n','k',0};
|
static const WCHAR dotlnk[] = {'.','l','n','k',0};
|
||||||
|
@ -799,7 +796,7 @@ static BOOL profile_items_callback( HINF hinf, PCWSTR field, void *arg )
|
||||||
if (SetupFindFirstLineW( hinf, field, Name, &name_context ))
|
if (SetupFindFirstLineW( hinf, field, Name, &name_context ))
|
||||||
{
|
{
|
||||||
SetupGetIntField( &name_context, 2, &attrs );
|
SetupGetIntField( &name_context, 2, &attrs );
|
||||||
if (attrs) FIXME( "unhandled attributes: %x\n", attrs );
|
if (attrs & ~FLG_PROFITEM_GROUP) FIXME( "unhandled attributes: %x\n", attrs );
|
||||||
}
|
}
|
||||||
else return TRUE;
|
else return TRUE;
|
||||||
|
|
||||||
|
@ -808,7 +805,7 @@ static BOOL profile_items_callback( HINF hinf, PCWSTR field, void *arg )
|
||||||
lnkpath_end = lnkpath + strlenW(lnkpath);
|
lnkpath_end = lnkpath + strlenW(lnkpath);
|
||||||
if (lnkpath_end[-1] != '\\') *lnkpath_end++ = '\\';
|
if (lnkpath_end[-1] != '\\') *lnkpath_end++ = '\\';
|
||||||
|
|
||||||
if (SetupFindFirstLineW( hinf, field, SubDir, &context ))
|
if (!(attrs & FLG_PROFITEM_GROUP) && SetupFindFirstLineW( hinf, field, SubDir, &context ))
|
||||||
{
|
{
|
||||||
unsigned int subdir_size;
|
unsigned int subdir_size;
|
||||||
|
|
||||||
|
@ -823,67 +820,80 @@ static BOOL profile_items_callback( HINF hinf, PCWSTR field, void *arg )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
lnkpath_end += name_size - 1;
|
lnkpath_end += name_size - 1;
|
||||||
if (lnkpath+MAX_PATH < lnkpath_end + 5) return TRUE;
|
|
||||||
strcpyW( lnkpath_end, dotlnk );
|
|
||||||
|
|
||||||
TRACE( "link path: %s\n", debugstr_w(lnkpath) );
|
if (attrs & FLG_PROFITEM_GROUP)
|
||||||
|
|
||||||
/* calculate command line */
|
|
||||||
if (SetupFindFirstLineW( hinf, field, CmdLine, &context ))
|
|
||||||
{
|
{
|
||||||
unsigned int dir_len=0, subdir_size=0, filename_size=0;
|
SHPathPrepareForWriteW( NULL, NULL, lnkpath, SHPPFW_DIRCREATE );
|
||||||
int dirid=0;
|
}
|
||||||
LPCWSTR dir;
|
else
|
||||||
LPWSTR cmdline_end;
|
{
|
||||||
|
IShellLinkW* shelllink=NULL;
|
||||||
|
IPersistFile* persistfile=NULL;
|
||||||
|
HRESULT initresult=E_FAIL;
|
||||||
|
|
||||||
SetupGetIntField( &context, 1, &dirid );
|
if (lnkpath+MAX_PATH < lnkpath_end + 5) return TRUE;
|
||||||
dir = DIRID_get_string( dirid );
|
strcpyW( lnkpath_end, dotlnk );
|
||||||
|
|
||||||
if (dir) dir_len = strlenW(dir);
|
TRACE( "link path: %s\n", debugstr_w(lnkpath) );
|
||||||
|
|
||||||
SetupGetStringFieldW( &context, 2, NULL, 0, &subdir_size );
|
/* calculate command line */
|
||||||
SetupGetStringFieldW( &context, 3, NULL, 0, &filename_size );
|
if (SetupFindFirstLineW( hinf, field, CmdLine, &context ))
|
||||||
|
|
||||||
if (dir_len && filename_size)
|
|
||||||
{
|
{
|
||||||
cmdline = cmdline_end = HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR) * (dir_len+subdir_size+filename_size+1) );
|
unsigned int dir_len=0, subdir_size=0, filename_size=0;
|
||||||
|
int dirid=0;
|
||||||
|
LPCWSTR dir;
|
||||||
|
LPWSTR cmdline_end;
|
||||||
|
|
||||||
strcpyW( cmdline_end, dir );
|
SetupGetIntField( &context, 1, &dirid );
|
||||||
cmdline_end += dir_len;
|
dir = DIRID_get_string( dirid );
|
||||||
if (cmdline_end[-1] != '\\') *cmdline_end++ = '\\';
|
|
||||||
|
|
||||||
if (subdir_size)
|
if (dir) dir_len = strlenW(dir);
|
||||||
|
|
||||||
|
SetupGetStringFieldW( &context, 2, NULL, 0, &subdir_size );
|
||||||
|
SetupGetStringFieldW( &context, 3, NULL, 0, &filename_size );
|
||||||
|
|
||||||
|
if (dir_len && filename_size)
|
||||||
{
|
{
|
||||||
SetupGetStringFieldW( &context, 2, cmdline_end, subdir_size, NULL );
|
cmdline = cmdline_end = HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR) * (dir_len+subdir_size+filename_size+1) );
|
||||||
cmdline_end += subdir_size-1;
|
|
||||||
|
strcpyW( cmdline_end, dir );
|
||||||
|
cmdline_end += dir_len;
|
||||||
if (cmdline_end[-1] != '\\') *cmdline_end++ = '\\';
|
if (cmdline_end[-1] != '\\') *cmdline_end++ = '\\';
|
||||||
|
|
||||||
|
if (subdir_size)
|
||||||
|
{
|
||||||
|
SetupGetStringFieldW( &context, 2, cmdline_end, subdir_size, NULL );
|
||||||
|
cmdline_end += subdir_size-1;
|
||||||
|
if (cmdline_end[-1] != '\\') *cmdline_end++ = '\\';
|
||||||
|
}
|
||||||
|
SetupGetStringFieldW( &context, 3, cmdline_end, filename_size, NULL );
|
||||||
|
TRACE( "cmdline: %s\n", debugstr_w(cmdline));
|
||||||
}
|
}
|
||||||
SetupGetStringFieldW( &context, 3, cmdline_end, filename_size, NULL );
|
|
||||||
TRACE( "cmdline: %s\n", debugstr_w(cmdline));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!cmdline) return TRUE;
|
||||||
|
|
||||||
|
initresult = CoInitialize(NULL);
|
||||||
|
|
||||||
|
if (!SUCCEEDED(CoCreateInstance( &CLSID_ShellLink, NULL,
|
||||||
|
CLSCTX_INPROC_SERVER, &IID_IShellLinkW, (LPVOID*)&shelllink)))
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
IShellLinkW_SetPath( shelllink, cmdline );
|
||||||
|
SHPathPrepareForWriteW( NULL, NULL, lnkpath, SHPPFW_DIRCREATE|SHPPFW_IGNOREFILENAME );
|
||||||
|
if (SUCCEEDED(IShellLinkW_QueryInterface( shelllink, &IID_IPersistFile, (LPVOID*)&persistfile)))
|
||||||
|
{
|
||||||
|
TRACE( "writing link: %s\n", debugstr_w(lnkpath) );
|
||||||
|
IPersistFile_Save( persistfile, lnkpath, FALSE );
|
||||||
|
IPersistFile_Release( persistfile );
|
||||||
|
}
|
||||||
|
IShellLinkW_Release( shelllink );
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (SUCCEEDED(initresult)) CoUninitialize();
|
||||||
|
HeapFree( GetProcessHeap(), 0, cmdline );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmdline) return TRUE;
|
|
||||||
|
|
||||||
initresult = CoInitialize(NULL);
|
|
||||||
|
|
||||||
if (!SUCCEEDED(CoCreateInstance( &CLSID_ShellLink, NULL,
|
|
||||||
CLSCTX_INPROC_SERVER, &IID_IShellLinkW, (LPVOID*)&shelllink)))
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
IShellLinkW_SetPath( shelllink, cmdline );
|
|
||||||
SHPathPrepareForWriteW( NULL, NULL, lnkpath, SHPPFW_DIRCREATE|SHPPFW_IGNOREFILENAME );
|
|
||||||
if (SUCCEEDED(IShellLinkW_QueryInterface( shelllink, &IID_IPersistFile, (LPVOID*)&persistfile)))
|
|
||||||
{
|
|
||||||
TRACE( "writing link: %s\n", debugstr_w(lnkpath) );
|
|
||||||
IPersistFile_Save( persistfile, lnkpath, FALSE );
|
|
||||||
IPersistFile_Release( persistfile );
|
|
||||||
}
|
|
||||||
IShellLinkW_Release( shelllink );
|
|
||||||
|
|
||||||
done:
|
|
||||||
if (SUCCEEDED(initresult)) CoUninitialize();
|
|
||||||
HeapFree( GetProcessHeap(), 0, cmdline );
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -393,7 +393,7 @@ static void test_profile_items(void)
|
||||||
"[Version]\n"
|
"[Version]\n"
|
||||||
"Signature=\"$Chicago$\"\n"
|
"Signature=\"$Chicago$\"\n"
|
||||||
"[DefaultInstall]\n"
|
"[DefaultInstall]\n"
|
||||||
"ProfileItems=TestItem,TestItem2\n"
|
"ProfileItems=TestItem,TestItem2,TestGroup\n"
|
||||||
"[TestItem]\n"
|
"[TestItem]\n"
|
||||||
"Name=TestItem\n"
|
"Name=TestItem\n"
|
||||||
"CmdLine=11,,notepad.exe\n"
|
"CmdLine=11,,notepad.exe\n"
|
||||||
|
@ -401,6 +401,8 @@ static void test_profile_items(void)
|
||||||
"Name=TestItem2\n"
|
"Name=TestItem2\n"
|
||||||
"CmdLine=11,,notepad.exe\n"
|
"CmdLine=11,,notepad.exe\n"
|
||||||
"SubDir=TestDir\n"
|
"SubDir=TestDir\n"
|
||||||
|
"[TestGroup]\n"
|
||||||
|
"Name=TestGroup,4\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
hShell32 = LoadLibraryA("shell32");
|
hShell32 = LoadLibraryA("shell32");
|
||||||
|
@ -432,6 +434,8 @@ static void test_profile_items(void)
|
||||||
ok(INVALID_FILE_ATTRIBUTES != GetFileAttributes(path), "directory not created\n");
|
ok(INVALID_FILE_ATTRIBUTES != GetFileAttributes(path), "directory not created\n");
|
||||||
snprintf(path, MAX_PATH, "%s\\TestDir\\TestItem2.lnk", commonprogs);
|
snprintf(path, MAX_PATH, "%s\\TestDir\\TestItem2.lnk", commonprogs);
|
||||||
ok(INVALID_FILE_ATTRIBUTES != GetFileAttributes(path), "link not created\n");
|
ok(INVALID_FILE_ATTRIBUTES != GetFileAttributes(path), "link not created\n");
|
||||||
|
snprintf(path, MAX_PATH, "%s\\TestGroup", commonprogs);
|
||||||
|
ok(INVALID_FILE_ATTRIBUTES != GetFileAttributes(path), "group not created\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(path, MAX_PATH, "%s\\TestItem.lnk", commonprogs);
|
snprintf(path, MAX_PATH, "%s\\TestItem.lnk", commonprogs);
|
||||||
|
@ -442,6 +446,8 @@ static void test_profile_items(void)
|
||||||
DeleteFile(path);
|
DeleteFile(path);
|
||||||
snprintf(path, MAX_PATH, "%s\\TestDir", commonprogs);
|
snprintf(path, MAX_PATH, "%s\\TestDir", commonprogs);
|
||||||
RemoveDirectory(path);
|
RemoveDirectory(path);
|
||||||
|
snprintf(path, MAX_PATH, "%s\\TestGroup", commonprogs);
|
||||||
|
RemoveDirectory(path);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (hShell32) FreeLibrary(hShell32);
|
if (hShell32) FreeLibrary(hShell32);
|
||||||
|
|
|
@ -1054,6 +1054,11 @@ DECL_WINELIB_SETUPAPI_TYPE_AW(PSP_INF_SIGNER_INFO)
|
||||||
#define FLG_REGSVR_DLLREGISTER 0x00000001
|
#define FLG_REGSVR_DLLREGISTER 0x00000001
|
||||||
#define FLG_REGSVR_DLLINSTALL 0x00000002
|
#define FLG_REGSVR_DLLINSTALL 0x00000002
|
||||||
|
|
||||||
|
#define FLG_PROFITEM_CURRENTUSER 0x00000001
|
||||||
|
#define FLG_PROFITEM_DELETE 0x00000002
|
||||||
|
#define FLG_PROFITEM_GROUP 0x00000004
|
||||||
|
#define FLG_PROFITEM_CSIDL 0x00000008
|
||||||
|
|
||||||
#define DI_NOVCP 0x00000008
|
#define DI_NOVCP 0x00000008
|
||||||
|
|
||||||
/* Class installer function codes */
|
/* Class installer function codes */
|
||||||
|
|
Loading…
Reference in New Issue