Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
d55061b9
Commit
d55061b9
authored
Mar 27, 2012
by
Piotr Caban
Committed by
Alexandre Julliard
Mar 27, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell32: Prepare QueryAssociations helper functions to work on non LPWSTR data.
parent
ed416733
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
24 deletions
+38
-24
assoc.c
dlls/shell32/assoc.c
+38
-24
No files found.
dlls/shell32/assoc.c
View file @
d55061b9
...
...
@@ -215,27 +215,28 @@ static HRESULT WINAPI IQueryAssociations_fnInit(
return
E_INVALIDARG
;
}
static
HRESULT
ASSOC_GetValue
(
HKEY
hkey
,
WCHAR
**
pszText
)
static
HRESULT
ASSOC_GetValue
(
HKEY
hkey
,
const
WCHAR
*
name
,
void
**
data
,
DWORD
*
data_size
)
{
DWORD
len
;
DWORD
size
;
LONG
ret
;
assert
(
pszText
);
ret
=
RegQueryValueExW
(
hkey
,
NULL
,
0
,
NULL
,
NULL
,
&
len
);
assert
(
data
);
ret
=
RegQueryValueExW
(
hkey
,
name
,
0
,
NULL
,
NULL
,
&
size
);
if
(
ret
!=
ERROR_SUCCESS
)
return
HRESULT_FROM_WIN32
(
ret
);
if
(
!
len
)
if
(
!
size
)
return
E_FAIL
;
*
pszText
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
if
(
!*
pszText
)
*
data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
!*
data
)
return
E_OUTOFMEMORY
;
ret
=
RegQueryValueExW
(
hkey
,
NULL
,
0
,
NULL
,
(
LPBYTE
)
*
pszText
,
&
len
);
ret
=
RegQueryValueExW
(
hkey
,
name
,
0
,
NULL
,
(
LPBYTE
)
*
data
,
&
size
);
if
(
ret
!=
ERROR_SUCCESS
)
{
HeapFree
(
GetProcessHeap
(),
0
,
*
pszText
);
HeapFree
(
GetProcessHeap
(),
0
,
*
data
);
return
HRESULT_FROM_WIN32
(
ret
);
}
if
(
data_size
)
*
data_size
=
size
;
return
S_OK
;
}
...
...
@@ -253,7 +254,7 @@ static HRESULT ASSOC_GetCommand(IQueryAssociationsImpl *This,
static
const
WCHAR
commandW
[]
=
{
'c'
,
'o'
,
'm'
,
'm'
,
'a'
,
'n'
,
'd'
,
0
};
static
const
WCHAR
shellW
[]
=
{
's'
,
'h'
,
'e'
,
'l'
,
'l'
,
0
};
hr
=
ASSOC_GetValue
(
This
->
hkeySource
,
&
pszFileType
);
hr
=
ASSOC_GetValue
(
This
->
hkeySource
,
NULL
,
(
void
**
)
&
pszFileType
,
NULL
);
if
(
FAILED
(
hr
))
return
hr
;
ret
=
RegOpenKeyExW
(
HKEY_CLASSES_ROOT
,
pszFileType
,
0
,
KEY_READ
,
&
hkeyFile
);
...
...
@@ -268,7 +269,7 @@ static HRESULT ASSOC_GetCommand(IQueryAssociationsImpl *This,
if
(
!
pszExtra
)
{
hr
=
ASSOC_GetValue
(
hkeyShell
,
&
pszExtraFromReg
);
hr
=
ASSOC_GetValue
(
hkeyShell
,
NULL
,
(
void
**
)
&
pszExtraFromReg
,
NULL
);
/* if no default action */
if
(
hr
==
E_FAIL
||
hr
==
HRESULT_FROM_WIN32
(
ERROR_FILE_NOT_FOUND
))
{
...
...
@@ -311,7 +312,7 @@ static HRESULT ASSOC_GetCommand(IQueryAssociationsImpl *This,
RegCloseKey
(
hkeyVerb
);
if
(
ret
!=
ERROR_SUCCESS
)
return
HRESULT_FROM_WIN32
(
ret
);
hr
=
ASSOC_GetValue
(
hkeyCommand
,
ppszCommand
);
hr
=
ASSOC_GetValue
(
hkeyCommand
,
NULL
,
(
void
**
)
ppszCommand
,
NULL
);
RegCloseKey
(
hkeyCommand
);
return
hr
;
}
...
...
@@ -361,7 +362,7 @@ static HRESULT ASSOC_GetExecutable(IQueryAssociationsImpl *This,
return
S_OK
;
}
static
HRESULT
ASSOC_ReturnData
(
LPWSTR
out
,
DWORD
*
outlen
,
LPCWSTR
data
,
static
HRESULT
ASSOC_ReturnData
(
void
*
out
,
DWORD
*
outlen
,
const
void
*
data
,
DWORD
datalen
)
{
assert
(
outlen
);
...
...
@@ -374,7 +375,7 @@ static HRESULT ASSOC_ReturnData(LPWSTR out, DWORD *outlen, LPCWSTR data,
return
E_POINTER
;
}
*
outlen
=
datalen
;
lstrcpynW
(
out
,
data
,
datalen
);
memcpy
(
out
,
data
,
datalen
);
return
S_OK
;
}
else
...
...
@@ -384,6 +385,19 @@ static HRESULT ASSOC_ReturnData(LPWSTR out, DWORD *outlen, LPCWSTR data,
}
}
static
HRESULT
ASSOC_ReturnString
(
LPWSTR
out
,
DWORD
*
outlen
,
LPCWSTR
data
,
DWORD
datalen
)
{
HRESULT
hres
;
assert
(
outlen
);
*
outlen
*=
sizeof
(
WCHAR
);
hres
=
ASSOC_ReturnData
(
out
,
outlen
,
data
,
datalen
*
sizeof
(
WCHAR
));
*
outlen
/=
sizeof
(
WCHAR
);
return
hres
;
}
/**************************************************************************
* IQueryAssociations_GetString
*
...
...
@@ -432,7 +446,7 @@ static HRESULT WINAPI IQueryAssociations_fnGetString(
hr
=
ASSOC_GetCommand
(
This
,
pszExtra
,
&
command
);
if
(
SUCCEEDED
(
hr
))
{
hr
=
ASSOC_Return
Data
(
pszOut
,
pcchOut
,
command
,
strlenW
(
command
)
+
1
);
hr
=
ASSOC_Return
String
(
pszOut
,
pcchOut
,
command
,
strlenW
(
command
)
+
1
);
HeapFree
(
GetProcessHeap
(),
0
,
command
);
}
return
hr
;
...
...
@@ -444,7 +458,7 @@ static HRESULT WINAPI IQueryAssociations_fnGetString(
if
(
FAILED
(
hr
))
return
hr
;
len
++
;
return
ASSOC_Return
Data
(
pszOut
,
pcchOut
,
path
,
len
);
return
ASSOC_Return
String
(
pszOut
,
pcchOut
,
path
,
len
);
}
case
ASSOCSTR_FRIENDLYDOCNAME
:
...
...
@@ -453,7 +467,7 @@ static HRESULT WINAPI IQueryAssociations_fnGetString(
DWORD
ret
;
DWORD
size
;
hr
=
ASSOC_GetValue
(
This
->
hkeySource
,
&
pszFileType
);
hr
=
ASSOC_GetValue
(
This
->
hkeySource
,
NULL
,
(
void
**
)
&
pszFileType
,
NULL
);
if
(
FAILED
(
hr
))
return
hr
;
size
=
0
;
...
...
@@ -465,7 +479,7 @@ static HRESULT WINAPI IQueryAssociations_fnGetString(
{
ret
=
RegGetValueW
(
HKEY_CLASSES_ROOT
,
pszFileType
,
NULL
,
RRF_RT_REG_SZ
,
NULL
,
docName
,
&
size
);
if
(
ret
==
ERROR_SUCCESS
)
hr
=
ASSOC_Return
Data
(
pszOut
,
pcchOut
,
docName
,
strlenW
(
docName
)
+
1
);
hr
=
ASSOC_Return
String
(
pszOut
,
pcchOut
,
docName
,
strlenW
(
docName
)
+
1
);
else
hr
=
HRESULT_FROM_WIN32
(
ret
);
HeapFree
(
GetProcessHeap
(),
0
,
docName
);
...
...
@@ -521,7 +535,7 @@ static HRESULT WINAPI IQueryAssociations_fnGetString(
/* Does strlenW(bufW) == 0 mean we use the filename? */
len
=
strlenW
(
bufW
)
+
1
;
TRACE
(
"found FileDescription: %s
\n
"
,
debugstr_w
(
bufW
));
hr
=
ASSOC_Return
Data
(
pszOut
,
pcchOut
,
bufW
,
len
);
hr
=
ASSOC_Return
String
(
pszOut
,
pcchOut
,
bufW
,
len
);
HeapFree
(
GetProcessHeap
(),
0
,
verinfoW
);
return
hr
;
}
...
...
@@ -531,7 +545,7 @@ get_friendly_name_fail:
PathRemoveExtensionW
(
path
);
PathStripPathW
(
path
);
TRACE
(
"using filename: %s
\n
"
,
debugstr_w
(
path
));
hr
=
ASSOC_Return
Data
(
pszOut
,
pcchOut
,
path
,
strlenW
(
path
)
+
1
);
hr
=
ASSOC_Return
String
(
pszOut
,
pcchOut
,
path
,
strlenW
(
path
)
+
1
);
HeapFree
(
GetProcessHeap
(),
0
,
verinfoW
);
return
hr
;
}
...
...
@@ -552,7 +566,7 @@ get_friendly_name_fail:
{
ret
=
RegGetValueW
(
This
->
hkeySource
,
NULL
,
Content_TypeW
,
RRF_RT_REG_SZ
,
NULL
,
contentType
,
&
size
);
if
(
ret
==
ERROR_SUCCESS
)
hr
=
ASSOC_Return
Data
(
pszOut
,
pcchOut
,
contentType
,
strlenW
(
contentType
)
+
1
);
hr
=
ASSOC_Return
String
(
pszOut
,
pcchOut
,
contentType
,
strlenW
(
contentType
)
+
1
);
else
hr
=
HRESULT_FROM_WIN32
(
ret
);
HeapFree
(
GetProcessHeap
(),
0
,
contentType
);
...
...
@@ -570,7 +584,7 @@ get_friendly_name_fail:
DWORD
size
;
HKEY
hkeyFile
;
hr
=
ASSOC_GetValue
(
This
->
hkeySource
,
&
pszFileType
);
hr
=
ASSOC_GetValue
(
This
->
hkeySource
,
NULL
,
(
void
**
)
&
pszFileType
,
NULL
);
if
(
FAILED
(
hr
))
return
hr
;
ret
=
RegOpenKeyExW
(
HKEY_CLASSES_ROOT
,
pszFileType
,
0
,
KEY_READ
,
&
hkeyFile
);
...
...
@@ -585,7 +599,7 @@ get_friendly_name_fail:
{
ret
=
RegGetValueW
(
hkeyFile
,
DefaultIconW
,
NULL
,
RRF_RT_REG_SZ
,
NULL
,
icon
,
&
size
);
if
(
ret
==
ERROR_SUCCESS
)
hr
=
ASSOC_Return
Data
(
pszOut
,
pcchOut
,
icon
,
strlenW
(
icon
)
+
1
);
hr
=
ASSOC_Return
String
(
pszOut
,
pcchOut
,
icon
,
strlenW
(
icon
)
+
1
);
else
hr
=
HRESULT_FROM_WIN32
(
ret
);
HeapFree
(
GetProcessHeap
(),
0
,
icon
);
...
...
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