Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
9adacf6a
Commit
9adacf6a
authored
Jun 24, 2005
by
Aric Stewart
Committed by
Alexandre Julliard
Jun 24, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework CreateShortcuts to use MSI_IterateRecords.
parent
b9a3f8fa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
143 deletions
+122
-143
action.c
dlls/msi/action.c
+122
-143
No files found.
dlls/msi/action.c
View file @
9adacf6a
...
...
@@ -2787,187 +2787,166 @@ static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package)
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
};
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
};
IShellLinkW
*
sl
;
IPersistFile
*
pf
;
HRESULT
res
;
if
(
!
package
)
return
ERROR_INVALID_HANDLE
;
buffer
=
MSI_RecordGetString
(
row
,
4
);
index
=
get_loaded_component
(
package
,
buffer
)
;
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
)
if
(
index
<
0
)
return
ERROR_SUCCESS
;
rc
=
MSI_ViewExecute
(
view
,
0
);
if
(
rc
!=
ERROR_SUCCESS
)
if
(
!
ACTION_VerifyComponentForAction
(
package
,
index
,
INSTALLSTATE_LOCAL
))
{
MSI_ViewClose
(
view
);
msiobj_release
(
&
view
->
hdr
);
return
rc
;
}
TRACE
(
"Skipping shortcut creation due to disabled component
\n
"
);
while
(
1
)
{
LPWSTR
target_file
,
target_folder
;
LPCWSTR
buffer
;
WCHAR
filename
[
0x100
];
DWORD
sz
;
DWORD
index
;
static
const
WCHAR
szlnk
[]
=
{
'.'
,
'l'
,
'n'
,
'k'
,
0
};
package
->
components
[
index
].
Action
=
package
->
components
[
index
].
Installed
;
rc
=
MSI_ViewFetch
(
view
,
&
row
);
if
(
rc
!=
ERROR_SUCCESS
)
{
rc
=
ERROR_SUCCESS
;
break
;
}
buffer
=
MSI_RecordGetString
(
row
,
4
);
index
=
get_loaded_component
(
package
,
buffer
);
return
ERROR_SUCCESS
;
}
if
(
index
<
0
)
{
msiobj_release
(
&
row
->
hdr
);
continue
;
}
package
->
components
[
index
].
Action
=
INSTALLSTATE_LOCAL
;
if
(
!
ACTION_VerifyComponentForAction
(
package
,
index
,
INSTALLSTATE_LOCAL
))
{
TRACE
(
"Skipping shortcut creation due to disabled component
\n
"
);
msiobj_release
(
&
row
->
hdr
);
ui_actiondata
(
package
,
szCreateShortcuts
,
row
);
package
->
components
[
index
].
Action
=
package
->
components
[
index
].
Installed
;
res
=
CoCreateInstance
(
&
CLSID_ShellLink
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IShellLinkW
,
(
LPVOID
*
)
&
sl
)
;
continue
;
}
if
(
FAILED
(
res
))
{
ERR
(
"Is IID_IShellLink
\n
"
);
return
ERROR_SUCCESS
;
}
package
->
components
[
index
].
Action
=
INSTALLSTATE_LOCAL
;
res
=
IShellLinkW_QueryInterface
(
sl
,
&
IID_IPersistFile
,(
LPVOID
*
)
&
pf
);
if
(
FAILED
(
res
)
)
{
ERR
(
"Is IID_IPersistFile
\n
"
);
return
ERROR_SUCCESS
;
}
ui_actiondata
(
package
,
szCreateShortcuts
,
row
);
buffer
=
MSI_RecordGetString
(
row
,
2
);
target_folder
=
resolve_folder
(
package
,
buffer
,
FALSE
,
FALSE
,
NULL
);
res
=
CoCreateInstance
(
&
CLSID_ShellLink
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IShellLinkW
,
(
LPVOID
*
)
&
sl
);
/* may be needed because of a bug somehwere else */
create_full_pathW
(
target_folder
);
if
(
FAILED
(
res
))
{
ERR
(
"Is IID_IShellLink
\n
"
);
msiobj_release
(
&
row
->
hdr
);
continue
;
}
sz
=
0x100
;
MSI_RecordGetStringW
(
row
,
3
,
filename
,
&
sz
);
reduce_to_longfilename
(
filename
);
if
(
!
strchrW
(
filename
,
'.'
)
||
strcmpiW
(
strchrW
(
filename
,
'.'
),
szlnk
))
strcatW
(
filename
,
szlnk
);
target_file
=
build_directory_name
(
2
,
target_folder
,
filename
);
HeapFree
(
GetProcessHeap
(),
0
,
target_folder
);
buffer
=
MSI_RecordGetString
(
row
,
5
);
if
(
strchrW
(
buffer
,
'['
))
{
LPWSTR
deformated
;
deformat_string
(
package
,
buffer
,
&
deformated
);
IShellLinkW_SetPath
(
sl
,
deformated
);
HeapFree
(
GetProcessHeap
(),
0
,
deformated
);
}
else
{
LPWSTR
keypath
;
FIXME
(
"poorly handled shortcut format, advertised shortcut
\n
"
);
keypath
=
strdupW
(
package
->
components
[
index
].
FullKeypath
);
IShellLinkW_SetPath
(
sl
,
keypath
);
HeapFree
(
GetProcessHeap
(),
0
,
keypath
);
}
res
=
IShellLinkW_QueryInterface
(
sl
,
&
IID_IPersistFile
,(
LPVOID
*
)
&
pf
);
if
(
FAILED
(
res
)
)
{
ERR
(
"Is IID_IPersistFile
\n
"
);
msiobj_release
(
&
row
->
hdr
);
continue
;
}
if
(
!
MSI_RecordIsNull
(
row
,
6
))
{
LPWSTR
deformated
;
buffer
=
MSI_RecordGetString
(
row
,
6
);
deformat_string
(
package
,
buffer
,
&
deformated
);
IShellLinkW_SetArguments
(
sl
,
deformated
);
HeapFree
(
GetProcessHeap
(),
0
,
deformated
);
}
buffer
=
MSI_RecordGetString
(
row
,
2
);
target_folder
=
resolve_folder
(
package
,
buffer
,
FALSE
,
FALSE
,
NULL
);
if
(
!
MSI_RecordIsNull
(
row
,
7
))
{
buffer
=
MSI_RecordGetString
(
row
,
7
);
IShellLinkW_SetDescription
(
sl
,
buffer
);
}
/* may be needed because of a bug somehwere else */
create_full_pathW
(
target_folder
);
if
(
!
MSI_RecordIsNull
(
row
,
8
))
IShellLinkW_SetHotkey
(
sl
,
MSI_RecordGetInteger
(
row
,
8
)
);
sz
=
0x100
;
MSI_RecordGetStringW
(
row
,
3
,
filename
,
&
sz
);
reduce_to_longfilename
(
filename
);
if
(
!
strchrW
(
filename
,
'.'
)
||
strcmpiW
(
strchrW
(
filename
,
'.'
),
szlnk
))
strcatW
(
filename
,
szlnk
);
target_file
=
build_directory_name
(
2
,
target_folder
,
filename
);
HeapFree
(
GetProcessHeap
(),
0
,
target_folder
);
if
(
!
MSI_RecordIsNull
(
row
,
9
))
{
WCHAR
*
Path
=
NULL
;
INT
index
;
buffer
=
MSI_RecordGetString
(
row
,
5
);
if
(
strchrW
(
buffer
,
'['
))
{
LPWSTR
deformated
;
deformat_string
(
package
,
buffer
,
&
deformated
);
IShellLinkW_SetPath
(
sl
,
deformated
);
HeapFree
(
GetProcessHeap
(),
0
,
deformated
);
}
else
{
LPWSTR
keypath
;
FIXME
(
"poorly handled shortcut format, advertised shortcut
\n
"
);
keypath
=
strdupW
(
package
->
components
[
index
].
FullKeypath
);
IShellLinkW_SetPath
(
sl
,
keypath
);
HeapFree
(
GetProcessHeap
(),
0
,
keypath
);
}
buffer
=
MSI_RecordGetString
(
row
,
9
);
if
(
!
MSI_RecordIsNull
(
row
,
6
))
{
LPWSTR
deformated
;
buffer
=
MSI_RecordGetString
(
row
,
6
);
deformat_string
(
package
,
buffer
,
&
deformated
);
IShellLinkW_SetArguments
(
sl
,
deformated
);
HeapFree
(
GetProcessHeap
(),
0
,
deformated
);
}
build_icon_path
(
package
,
buffer
,
&
Path
);
index
=
MSI_RecordGetInteger
(
row
,
10
);
if
(
!
MSI_RecordIsNull
(
row
,
7
))
{
buffer
=
MSI_RecordGetString
(
row
,
7
);
IShellLinkW_SetDescription
(
sl
,
buffer
);
}
IShellLinkW_SetIconLocation
(
sl
,
Path
,
index
);
HeapFree
(
GetProcessHeap
(),
0
,
Path
);
}
if
(
!
MSI_RecordIsNull
(
row
,
8
))
IShellLinkW_SetHotkey
(
sl
,
MSI_RecordGetInteger
(
row
,
8
));
if
(
!
MSI_RecordIsNull
(
row
,
11
))
IShellLinkW_SetShowCmd
(
sl
,
MSI_RecordGetInteger
(
row
,
11
));
if
(
!
MSI_RecordIsNull
(
row
,
9
))
{
WCHAR
*
Path
=
NULL
;
INT
index
;
if
(
!
MSI_RecordIsNull
(
row
,
12
))
{
LPWSTR
Path
;
buffer
=
MSI_RecordGetString
(
row
,
12
);
Path
=
resolve_folder
(
package
,
buffer
,
FALSE
,
FALSE
,
NULL
);
IShellLinkW_SetWorkingDirectory
(
sl
,
Path
);
HeapFree
(
GetProcessHeap
(),
0
,
Path
);
}
buffer
=
MSI_RecordGetString
(
row
,
9
);
TRACE
(
"Writing shortcut to %s
\n
"
,
debugstr_w
(
target_file
));
IPersistFile_Save
(
pf
,
target_file
,
FALSE
);
build_icon_path
(
package
,
buffer
,
&
Path
);
index
=
MSI_RecordGetInteger
(
row
,
10
);
HeapFree
(
GetProcessHeap
(),
0
,
target_file
);
IShellLinkW_SetIconLocation
(
sl
,
Path
,
index
);
HeapFree
(
GetProcessHeap
(),
0
,
Path
);
}
IPersistFile_Release
(
pf
);
IShellLinkW_Release
(
sl
);
if
(
!
MSI_RecordIsNull
(
row
,
11
))
IShellLinkW_SetShowCmd
(
sl
,
MSI_RecordGetInteger
(
row
,
11
));
return
ERROR_SUCCESS
;
}
if
(
!
MSI_RecordIsNull
(
row
,
12
)
)
{
LPWSTR
Path
;
buffer
=
MSI_RecordGetString
(
row
,
12
)
;
Path
=
resolve_folder
(
package
,
buffer
,
FALSE
,
FALSE
,
NULL
)
;
IShellLinkW_SetWorkingDirectory
(
sl
,
Path
);
HeapFree
(
GetProcessHeap
(),
0
,
Path
);
}
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
};
TRACE
(
"Writing shortcut to %s
\n
"
,
debugstr_w
(
target_file
));
IPersistFile_Save
(
pf
,
target_file
,
FALSE
);
HeapFree
(
GetProcessHeap
(),
0
,
target_file
);
if
(
!
package
)
return
ERROR_INVALID_HANDLE
;
IPersistFile_Release
(
pf
);
IShellLinkW_Release
(
sl
);
rc
=
MSI_DatabaseOpenViewW
(
package
->
db
,
Query
,
&
view
);
if
(
rc
!=
ERROR_SUCCESS
)
return
ERROR_SUCCESS
;
msiobj_release
(
&
row
->
hdr
);
res
=
CoInitialize
(
NULL
);
if
(
FAILED
(
res
))
{
ERR
(
"CoInitialize failed
\n
"
);
return
ERROR_FUNCTION_FAILED
;
}
MSI_ViewClose
(
view
);
msiobj_release
(
&
view
->
hdr
);
rc
=
MSI_IterateRecords
(
view
,
NULL
,
ITERATE_CreateShortcuts
,
package
);
msiobj_release
(
&
view
->
hdr
);
CoUninitialize
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment