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
a5cb5a2a
Commit
a5cb5a2a
authored
Mar 27, 2005
by
Mike McCormack
Committed by
Alexandre Julliard
Mar 27, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use api definitions, remove duplicate code.
parent
d0965ae8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
104 deletions
+48
-104
shelllink.c
dlls/shell32/shelllink.c
+48
-104
No files found.
dlls/shell32/shelllink.c
View file @
a5cb5a2a
...
...
@@ -78,18 +78,6 @@ DEFINE_GUID( SHELL32_AdvtShortcutComponent,
/* link file formats */
/* flag1: lnk elements: simple link has 0x0B */
#define SCF_PIDL 1
#define SCF_LOCATION 2
#define SCF_DESCRIPTION 4
#define SCF_RELATIVE 8
#define SCF_WORKDIR 0x10
#define SCF_ARGS 0x20
#define SCF_CUSTOMICON 0x40
#define SCF_UNICODE 0x80
#define SCF_PRODUCT 0x800
#define SCF_COMPONENT 0x1000
#include "pshpack1.h"
typedef
struct
_LINK_HEADER
...
...
@@ -131,14 +119,6 @@ typedef struct _LOCAL_VOLUME_INFO
DWORD
dwVolLabelOfs
;
}
LOCAL_VOLUME_INFO
;
typedef
struct
tagLINK_ADVERTISEINFO
{
DWORD
size
;
DWORD
magic
;
CHAR
bufA
[
MAX_PATH
];
WCHAR
bufW
[
MAX_PATH
];
}
LINK_ADVERTISEINFO
;
typedef
struct
volume_info_t
{
DWORD
type
;
...
...
@@ -638,40 +618,40 @@ static HRESULT Stream_LoadAdvertiseInfo( IStream* stm, LPWSTR *str )
DWORD
size
;
ULONG
count
;
HRESULT
r
;
LINK_ADVERTISEINFO
buffer
;
EXP_DARWIN_LINK
buffer
;
TRACE
(
"%p
\n
"
,
stm
);
r
=
IStream_Read
(
stm
,
&
buffer
.
s
ize
,
sizeof
(
DWORD
),
&
count
);
r
=
IStream_Read
(
stm
,
&
buffer
.
dbh
.
cbS
ize
,
sizeof
(
DWORD
),
&
count
);
if
(
FAILED
(
r
)
)
return
r
;
/* make sure that we read the size of the structure even on error */
size
=
sizeof
buffer
-
sizeof
(
DWORD
);
if
(
buffer
.
s
ize
!=
sizeof
buffer
)
if
(
buffer
.
dbh
.
cbS
ize
!=
sizeof
buffer
)
{
ERR
(
"Ooops. This structure is not as expected...
\n
"
);
return
E_FAIL
;
}
r
=
IStream_Read
(
stm
,
&
buffer
.
magic
,
size
,
&
count
);
r
=
IStream_Read
(
stm
,
&
buffer
.
dbh
.
dwSignature
,
size
,
&
count
);
if
(
FAILED
(
r
)
)
return
r
;
if
(
count
!=
size
)
return
E_FAIL
;
TRACE
(
"magic %08lx string = %s
\n
"
,
buffer
.
magic
,
debugstr_w
(
buffer
.
bufW
));
TRACE
(
"magic %08lx string = %s
\n
"
,
buffer
.
dbh
.
dwSignature
,
debugstr_w
(
buffer
.
szwDarwinID
));
if
(
(
buffer
.
magic
&
0xffff0000
)
!=
0xa0000000
)
if
(
(
buffer
.
dbh
.
dwSignature
&
0xffff0000
)
!=
0xa0000000
)
{
ERR
(
"Unknown magic number %08lx in advertised shortcut
\n
"
,
buffer
.
magic
);
ERR
(
"Unknown magic number %08lx in advertised shortcut
\n
"
,
buffer
.
dbh
.
dwSignature
);
return
E_FAIL
;
}
*
str
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
strlenW
(
buffer
.
bufW
)
+
1
)
*
sizeof
(
WCHAR
)
);
strcpyW
(
*
str
,
buffer
.
bufW
);
(
strlenW
(
buffer
.
szwDarwinID
)
+
1
)
*
sizeof
(
WCHAR
)
);
strcpyW
(
*
str
,
buffer
.
szwDarwinID
);
return
S_OK
;
}
...
...
@@ -680,7 +660,7 @@ static HRESULT Stream_LoadAdvertiseInfo( IStream* stm, LPWSTR *str )
* IPersistStream_Load (IPersistStream)
*/
static
HRESULT
WINAPI
IPersistStream_fnLoad
(
IPersistStream
*
iface
,
IPersistStream
*
iface
,
IStream
*
stm
)
{
LINK_HEADER
hdr
;
...
...
@@ -694,7 +674,7 @@ static HRESULT WINAPI IPersistStream_fnLoad(
TRACE
(
"%p %p
\n
"
,
This
,
stm
);
if
(
!
stm
)
return
STG_E_INVALIDPOINTER
;
return
STG_E_INVALIDPOINTER
;
dwBytesRead
=
0
;
r
=
IStream_Read
(
stm
,
&
hdr
,
sizeof
(
hdr
),
&
dwBytesRead
);
...
...
@@ -749,7 +729,7 @@ static HRESULT WINAPI IPersistStream_fnLoad(
}
/* load all the new stuff */
if
(
hdr
.
dwFlags
&
S
CF_PIDL
)
if
(
hdr
.
dwFlags
&
S
LDF_HAS_ID_LIST
)
{
r
=
ILLoadFromStream
(
stm
,
&
This
->
pPidl
);
if
(
FAILED
(
r
)
)
...
...
@@ -758,13 +738,13 @@ static HRESULT WINAPI IPersistStream_fnLoad(
pdump
(
This
->
pPidl
);
/* load the location information */
if
(
hdr
.
dwFlags
&
S
CF_LOCATION
)
if
(
hdr
.
dwFlags
&
S
LDF_HAS_LINK_INFO
)
r
=
Stream_LoadLocation
(
stm
,
&
This
->
volume
,
&
This
->
sPath
);
if
(
FAILED
(
r
)
)
goto
end
;
unicode
=
hdr
.
dwFlags
&
S
C
F_UNICODE
;
if
(
hdr
.
dwFlags
&
S
CF_DESCRIPTION
)
unicode
=
hdr
.
dwFlags
&
S
LD
F_UNICODE
;
if
(
hdr
.
dwFlags
&
S
LDF_HAS_NAME
)
{
r
=
Stream_LoadString
(
stm
,
unicode
,
&
This
->
sDescription
);
TRACE
(
"Description -> %s
\n
"
,
debugstr_w
(
This
->
sDescription
));
...
...
@@ -772,7 +752,7 @@ static HRESULT WINAPI IPersistStream_fnLoad(
if
(
FAILED
(
r
)
)
goto
end
;
if
(
hdr
.
dwFlags
&
S
CF_RELATIVE
)
if
(
hdr
.
dwFlags
&
S
LDF_HAS_RELPATH
)
{
r
=
Stream_LoadString
(
stm
,
unicode
,
&
This
->
sPathRel
);
TRACE
(
"Relative Path-> %s
\n
"
,
debugstr_w
(
This
->
sPathRel
));
...
...
@@ -780,7 +760,7 @@ static HRESULT WINAPI IPersistStream_fnLoad(
if
(
FAILED
(
r
)
)
goto
end
;
if
(
hdr
.
dwFlags
&
S
CF_WORK
DIR
)
if
(
hdr
.
dwFlags
&
S
LDF_HAS_WORKING
DIR
)
{
r
=
Stream_LoadString
(
stm
,
unicode
,
&
This
->
sWorkDir
);
TRACE
(
"Working Dir -> %s
\n
"
,
debugstr_w
(
This
->
sWorkDir
));
...
...
@@ -788,7 +768,7 @@ static HRESULT WINAPI IPersistStream_fnLoad(
if
(
FAILED
(
r
)
)
goto
end
;
if
(
hdr
.
dwFlags
&
S
CF
_ARGS
)
if
(
hdr
.
dwFlags
&
S
LDF_HAS
_ARGS
)
{
r
=
Stream_LoadString
(
stm
,
unicode
,
&
This
->
sArgs
);
TRACE
(
"Working Dir -> %s
\n
"
,
debugstr_w
(
This
->
sArgs
));
...
...
@@ -796,7 +776,7 @@ static HRESULT WINAPI IPersistStream_fnLoad(
if
(
FAILED
(
r
)
)
goto
end
;
if
(
hdr
.
dwFlags
&
S
CF_CUSTOMIC
ON
)
if
(
hdr
.
dwFlags
&
S
LDF_HAS_ICONLOCATI
ON
)
{
r
=
Stream_LoadString
(
stm
,
unicode
,
&
This
->
sIcoPath
);
TRACE
(
"Icon file -> %s
\n
"
,
debugstr_w
(
This
->
sIcoPath
));
...
...
@@ -804,7 +784,7 @@ static HRESULT WINAPI IPersistStream_fnLoad(
if
(
FAILED
(
r
)
)
goto
end
;
if
(
hdr
.
dwFlags
&
S
CF_PRODUCT
)
if
(
hdr
.
dwFlags
&
S
LDF_HAS_LOGO3ID
)
{
r
=
Stream_LoadAdvertiseInfo
(
stm
,
&
This
->
sProduct
);
TRACE
(
"Product -> %s
\n
"
,
debugstr_w
(
This
->
sProduct
));
...
...
@@ -812,7 +792,7 @@ static HRESULT WINAPI IPersistStream_fnLoad(
if
(
FAILED
(
r
)
)
goto
end
;
if
(
hdr
.
dwFlags
&
S
CF_COMPONENT
)
if
(
hdr
.
dwFlags
&
S
LDF_HAS_DARWINID
)
{
r
=
Stream_LoadAdvertiseInfo
(
stm
,
&
This
->
sComponent
);
TRACE
(
"Component -> %s
\n
"
,
debugstr_w
(
This
->
sComponent
));
...
...
@@ -922,17 +902,17 @@ static HRESULT Stream_WriteLocationInfo( IStream* stm, LPCWSTR path,
static
HRESULT
Stream_WriteAdvertiseInfo
(
IStream
*
stm
,
LPCWSTR
string
,
DWORD
magic
)
{
ULONG
count
;
LINK_ADVERTISEINFO
buffer
;
EXP_DARWIN_LINK
buffer
;
TRACE
(
"%p
\n
"
,
stm
);
memset
(
&
buffer
,
0
,
sizeof
buffer
);
buffer
.
s
ize
=
sizeof
buffer
;
buffer
.
magic
=
magic
;
strncpyW
(
buffer
.
bufW
,
string
,
MAX_PATH
);
WideCharToMultiByte
(
CP_ACP
,
0
,
string
,
-
1
,
buffer
.
bufA
,
MAX_PATH
,
NULL
,
NULL
);
buffer
.
dbh
.
cbS
ize
=
sizeof
buffer
;
buffer
.
dbh
.
dwSignature
=
magic
;
strncpyW
(
buffer
.
szwDarwinID
,
string
,
MAX_PATH
);
WideCharToMultiByte
(
CP_ACP
,
0
,
string
,
-
1
,
buffer
.
szDarwinID
,
MAX_PATH
,
NULL
,
NULL
);
return
IStream_Write
(
stm
,
&
buffer
,
buffer
.
s
ize
,
&
count
);
return
IStream_Write
(
stm
,
&
buffer
,
buffer
.
dbh
.
cbS
ize
,
&
count
);
}
/************************************************************************
...
...
@@ -978,23 +958,23 @@ static HRESULT WINAPI IPersistStream_fnSave(
header
.
wHotKey
=
This
->
wHotKey
;
header
.
nIcon
=
This
->
iIcoNdx
;
header
.
dwFlags
=
S
C
F_UNICODE
;
/* strings are in unicode */
header
.
dwFlags
=
S
LD
F_UNICODE
;
/* strings are in unicode */
if
(
This
->
pPidl
)
header
.
dwFlags
|=
S
CF_PIDL
;
header
.
dwFlags
|=
S
LDF_HAS_ID_LIST
;
if
(
This
->
sPath
)
header
.
dwFlags
|=
S
CF_LOCATION
;
header
.
dwFlags
|=
S
LDF_HAS_LINK_INFO
;
if
(
This
->
sDescription
)
header
.
dwFlags
|=
S
CF_DESCRIPTION
;
header
.
dwFlags
|=
S
LDF_HAS_NAME
;
if
(
This
->
sWorkDir
)
header
.
dwFlags
|=
S
CF_WORK
DIR
;
header
.
dwFlags
|=
S
LDF_HAS_WORKING
DIR
;
if
(
This
->
sArgs
)
header
.
dwFlags
|=
S
CF
_ARGS
;
header
.
dwFlags
|=
S
LDF_HAS
_ARGS
;
if
(
This
->
sIcoPath
)
header
.
dwFlags
|=
S
CF_CUSTOMIC
ON
;
header
.
dwFlags
|=
S
LDF_HAS_ICONLOCATI
ON
;
if
(
This
->
sProduct
)
header
.
dwFlags
|=
S
CF_PRODUCT
;
header
.
dwFlags
|=
S
LDF_HAS_LOGO3ID
;
if
(
This
->
sComponent
)
header
.
dwFlags
|=
S
CF_COMPONENT
;
header
.
dwFlags
|=
S
LDF_HAS_DARWINID
;
SystemTimeToFileTime
(
&
This
->
time1
,
&
header
.
Time1
);
SystemTimeToFileTime
(
&
This
->
time2
,
&
header
.
Time2
);
...
...
@@ -1040,10 +1020,10 @@ static HRESULT WINAPI IPersistStream_fnSave(
r
=
Stream_WriteString
(
stm
,
This
->
sIcoPath
);
if
(
This
->
sProduct
)
r
=
Stream_WriteAdvertiseInfo
(
stm
,
This
->
sProduct
,
0xa0000007
);
r
=
Stream_WriteAdvertiseInfo
(
stm
,
This
->
sProduct
,
EXP_SZ_ICON_SIG
);
if
(
This
->
sComponent
)
r
=
Stream_WriteAdvertiseInfo
(
stm
,
This
->
sComponent
,
0xa0000006
);
r
=
Stream_WriteAdvertiseInfo
(
stm
,
This
->
sComponent
,
EXP_DARWIN_ID_SIG
);
/* the last field is a single zero dword */
zero
=
0
;
...
...
@@ -1081,10 +1061,8 @@ static IPersistStreamVtbl psvt =
/**************************************************************************
* IShellLink_Constructor
*/
HRESULT
WINAPI
IShellLink_Constructor
(
IUnknown
*
pUnkOuter
,
REFIID
riid
,
LPVOID
*
ppv
)
HRESULT
WINAPI
IShellLink_Constructor
(
IUnknown
*
pUnkOuter
,
REFIID
riid
,
LPVOID
*
ppv
)
{
IShellLinkImpl
*
sl
;
...
...
@@ -1092,9 +1070,11 @@ HRESULT WINAPI IShellLink_Constructor (
*
ppv
=
NULL
;
if
(
pUnkOuter
)
return
CLASS_E_NOAGGREGATION
;
sl
=
(
IShellLinkImpl
*
)
LocalAlloc
(
LMEM_ZEROINIT
,
sizeof
(
IShellLinkImpl
));
if
(
!
sl
)
return
E_OUTOFMEMORY
;
if
(
pUnkOuter
)
return
CLASS_E_NOAGGREGATION
;
sl
=
LocalAlloc
(
LMEM_ZEROINIT
,
sizeof
(
IShellLinkImpl
));
if
(
!
sl
)
return
E_OUTOFMEMORY
;
sl
->
ref
=
1
;
sl
->
lpVtbl
=
&
slvt
;
...
...
@@ -1182,12 +1162,8 @@ static HRESULT ShellLink_UpdatePath(LPWSTR sPathRel, LPCWSTR path, LPCWSTR sWork
/**************************************************************************
* IShellLink_ConstructFromFile
*/
HRESULT
WINAPI
IShellLink_ConstructFromFile
(
IUnknown
*
pUnkOuter
,
REFIID
riid
,
LPCITEMIDLIST
pidl
,
LPVOID
*
ppv
)
HRESULT
WINAPI
IShellLink_ConstructFromFile
(
IUnknown
*
pUnkOuter
,
REFIID
riid
,
LPCITEMIDLIST
pidl
,
LPVOID
*
ppv
)
{
IShellLinkW
*
psl
;
...
...
@@ -1587,43 +1563,11 @@ static HRESULT WINAPI IShellLinkA_fnSetRelativePath(IShellLinkA * iface, LPCSTR
static
HRESULT
WINAPI
IShellLinkA_fnResolve
(
IShellLinkA
*
iface
,
HWND
hwnd
,
DWORD
fFlags
)
{
HRESULT
hr
=
S_OK
;
IShellLinkImpl
*
This
=
(
IShellLinkImpl
*
)
iface
;
TRACE
(
"(%p)->(hwnd=%p flags=%lx)
\n
"
,
This
,
hwnd
,
fFlags
);
/*FIXME: use IResolveShellLink interface */
if
(
!
This
->
sPath
&&
This
->
pPidl
)
{
WCHAR
buffer
[
MAX_PATH
];
hr
=
SHELL_GetPathFromIDListW
(
This
->
pPidl
,
buffer
,
MAX_PATH
);
if
(
SUCCEEDED
(
hr
)
&&
*
buffer
)
{
This
->
sPath
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
lstrlenW
(
buffer
)
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
This
->
sPath
)
return
E_OUTOFMEMORY
;
lstrcpyW
(
This
->
sPath
,
buffer
);
This
->
bDirty
=
TRUE
;
}
else
hr
=
S_OK
;
/* don't report an error occurred while just caching information */
}
if
(
!
This
->
sIcoPath
&&
This
->
sPath
)
{
This
->
sIcoPath
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
lstrlenW
(
This
->
sPath
)
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
This
->
sIcoPath
)
return
E_OUTOFMEMORY
;
lstrcpyW
(
This
->
sIcoPath
,
This
->
sPath
);
This
->
iIcoNdx
=
0
;
This
->
bDirty
=
TRUE
;
}
return
hr
;
return
IShellLinkW_Resolve
(
(
IShellLinkW
*
)
&
(
This
->
lpvtblw
),
hwnd
,
fFlags
);
}
static
HRESULT
WINAPI
IShellLinkA_fnSetPath
(
IShellLinkA
*
iface
,
LPCSTR
pszFile
)
...
...
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