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
f96631e1
Commit
f96631e1
authored
Oct 24, 2013
by
Nikolay Sivov
Committed by
Alexandre Julliard
Oct 25, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32: Add a helper to map ProgID to CLSID using registry.
parent
5077fc89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
29 deletions
+41
-29
compobj.c
dlls/ole32/compobj.c
+32
-29
compobj.c
dlls/ole32/tests/compobj.c
+9
-0
No files found.
dlls/ole32/compobj.c
View file @
f96631e1
...
...
@@ -2066,6 +2066,36 @@ static HRESULT __CLSIDFromString(LPCWSTR s, LPCLSID id)
/*****************************************************************************/
static
HRESULT
clsid_from_string_reg
(
LPCOLESTR
progid
,
CLSID
*
clsid
)
{
static
const
WCHAR
clsidW
[]
=
{
'\\'
,
'C'
,
'L'
,
'S'
,
'I'
,
'D'
,
0
};
WCHAR
buf2
[
CHARS_IN_GUID
];
LONG
buf2len
=
sizeof
(
buf2
);
HKEY
xhkey
;
WCHAR
*
buf
;
memset
(
clsid
,
0
,
sizeof
(
*
clsid
));
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,(
strlenW
(
progid
)
+
8
)
*
sizeof
(
WCHAR
)
);
strcpyW
(
buf
,
progid
);
strcatW
(
buf
,
clsidW
);
if
(
open_classes_key
(
HKEY_CLASSES_ROOT
,
buf
,
MAXIMUM_ALLOWED
,
&
xhkey
))
{
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
WARN
(
"couldn't open key for ProgID %s
\n
"
,
debugstr_w
(
progid
));
return
CO_E_CLASSSTRING
;
}
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
if
(
RegQueryValueW
(
xhkey
,
NULL
,
buf2
,
&
buf2len
))
{
RegCloseKey
(
xhkey
);
WARN
(
"couldn't query clsid value for ProgID %s
\n
"
,
debugstr_w
(
progid
));
return
CO_E_CLASSSTRING
;
}
RegCloseKey
(
xhkey
);
return
__CLSIDFromString
(
buf2
,
clsid
);
}
HRESULT
WINAPI
CLSIDFromString
(
LPCOLESTR
idstr
,
LPCLSID
id
)
{
HRESULT
ret
;
...
...
@@ -2076,7 +2106,7 @@ HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id )
ret
=
__CLSIDFromString
(
idstr
,
id
);
if
(
ret
!=
S_OK
)
{
/* It appears a ProgID is also valid */
CLSID
tmp_id
;
ret
=
CLSIDFromProgID
(
idstr
,
&
tmp_id
);
ret
=
clsid_from_string_reg
(
idstr
,
&
tmp_id
);
if
(
SUCCEEDED
(
ret
))
*
id
=
tmp_id
;
}
...
...
@@ -2301,40 +2331,13 @@ HRESULT WINAPI ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *ppszProgID)
*/
HRESULT
WINAPI
CLSIDFromProgID
(
LPCOLESTR
progid
,
LPCLSID
clsid
)
{
static
const
WCHAR
clsidW
[]
=
{
'\\'
,
'C'
,
'L'
,
'S'
,
'I'
,
'D'
,
0
};
WCHAR
buf2
[
CHARS_IN_GUID
];
LONG
buf2len
=
sizeof
(
buf2
);
HKEY
xhkey
;
WCHAR
*
buf
;
if
(
!
progid
||
!
clsid
)
{
ERR
(
"neither progid (%p) nor clsid (%p) are optional
\n
"
,
progid
,
clsid
);
return
E_INVALIDARG
;
}
/* initialise clsid in case of failure */
memset
(
clsid
,
0
,
sizeof
(
*
clsid
));
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,(
strlenW
(
progid
)
+
8
)
*
sizeof
(
WCHAR
)
);
strcpyW
(
buf
,
progid
);
strcatW
(
buf
,
clsidW
);
if
(
open_classes_key
(
HKEY_CLASSES_ROOT
,
buf
,
MAXIMUM_ALLOWED
,
&
xhkey
))
{
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
WARN
(
"couldn't open key for ProgID %s
\n
"
,
debugstr_w
(
progid
));
return
CO_E_CLASSSTRING
;
}
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
if
(
RegQueryValueW
(
xhkey
,
NULL
,
buf2
,
&
buf2len
))
{
RegCloseKey
(
xhkey
);
WARN
(
"couldn't query clsid value for ProgID %s
\n
"
,
debugstr_w
(
progid
));
return
CO_E_CLASSSTRING
;
}
RegCloseKey
(
xhkey
);
return
__CLSIDFromString
(
buf2
,
clsid
);
return
clsid_from_string_reg
(
progid
,
clsid
);
}
/******************************************************************************
...
...
dlls/ole32/tests/compobj.c
View file @
f96631e1
...
...
@@ -368,6 +368,15 @@ static void test_CLSIDFromProgID(void)
{
GUID
clsid1
;
memset
(
&
clsid
,
0xcc
,
sizeof
(
clsid
));
hr
=
CLSIDFromProgID
(
wszNonExistent
,
&
clsid
);
ok
(
hr
==
CO_E_CLASSSTRING
,
"got 0x%08x
\n
"
,
hr
);
ok
(
IsEqualCLSID
(
&
clsid
,
&
CLSID_NULL
),
"should have zero CLSID on failure
\n
"
);
/* CLSIDFromString() doesn't check activation context */
hr
=
CLSIDFromString
(
progidW
,
&
clsid
);
ok
(
hr
==
CO_E_CLASSSTRING
,
"got 0x%08x
\n
"
,
hr
);
clsid
=
CLSID_NULL
;
hr
=
CLSIDFromProgID
(
progidW
,
&
clsid
);
todo_wine
...
...
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