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
9af543aa
Commit
9af543aa
authored
May 07, 2012
by
Nikolay Sivov
Committed by
Alexandre Julliard
May 08, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell32: Implement IShellDispatch2::IsServiceRunning().
parent
ecb1c602
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
3 deletions
+103
-3
shelldispatch.c
dlls/shell32/shelldispatch.c
+42
-3
shelldispatch.c
dlls/shell32/tests/shelldispatch.c
+61
-0
No files found.
dlls/shell32/shelldispatch.c
View file @
9af543aa
...
...
@@ -30,6 +30,7 @@
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "winsvc.h"
#include "shlwapi.h"
#include "shlobj.h"
#include "shldisp.h"
...
...
@@ -1038,10 +1039,48 @@ static HRESULT WINAPI ShellDispatch_ServiceStop(IShellDispatch2 *iface, BSTR ser
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
ShellDispatch_IsServiceRunning
(
IShellDispatch2
*
iface
,
BSTR
servic
e
,
VARIANT
*
running
)
static
HRESULT
WINAPI
ShellDispatch_IsServiceRunning
(
IShellDispatch2
*
iface
,
BSTR
nam
e
,
VARIANT
*
running
)
{
FIXME
(
"(%s, %p): stub
\n
"
,
debugstr_w
(
service
),
running
);
return
E_NOTIMPL
;
SERVICE_STATUS_PROCESS
status
;
SC_HANDLE
scm
,
service
;
DWORD
dummy
;
TRACE
(
"(%s, %p)
\n
"
,
debugstr_w
(
name
),
running
);
V_VT
(
running
)
=
VT_BOOL
;
V_BOOL
(
running
)
=
VARIANT_FALSE
;
scm
=
OpenSCManagerW
(
NULL
,
NULL
,
SC_MANAGER_CONNECT
);
if
(
!
scm
)
{
ERR
(
"failed to connect to service manager
\n
"
);
return
S_OK
;
}
service
=
OpenServiceW
(
scm
,
name
,
SERVICE_QUERY_STATUS
);
if
(
!
service
)
{
ERR
(
"Failed to open service %s (%u)
\n
"
,
debugstr_w
(
name
),
GetLastError
());
CloseServiceHandle
(
service
);
return
S_OK
;
}
if
(
!
QueryServiceStatusEx
(
service
,
SC_STATUS_PROCESS_INFO
,
(
BYTE
*
)
&
status
,
sizeof
(
SERVICE_STATUS_PROCESS
),
&
dummy
))
{
TRACE
(
"failed to query service status (%u)
\n
"
,
GetLastError
());
CloseServiceHandle
(
service
);
CloseServiceHandle
(
scm
);
return
S_OK
;
}
if
(
status
.
dwCurrentState
==
SERVICE_RUNNING
)
V_BOOL
(
running
)
=
VARIANT_TRUE
;
CloseServiceHandle
(
service
);
CloseServiceHandle
(
scm
);
return
S_OK
;
}
static
HRESULT
WINAPI
ShellDispatch_CanStartStopService
(
IShellDispatch2
*
iface
,
BSTR
service
,
VARIANT
*
ret
)
...
...
dlls/shell32/tests/shelldispatch.c
View file @
9af543aa
...
...
@@ -27,6 +27,9 @@
#include "shlwapi.h"
#include "wine/test.h"
#define EXPECT_HR(hr,hr_exp) \
ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
static
HRESULT
(
WINAPI
*
pSHGetFolderPathW
)(
HWND
,
int
,
HANDLE
,
DWORD
,
LPWSTR
);
static
HRESULT
(
WINAPI
*
pSHGetNameFromIDList
)(
PCIDLIST_ABSOLUTE
,
SIGDN
,
PWSTR
*
);
static
HRESULT
(
WINAPI
*
pSHGetSpecialFolderLocation
)(
HWND
,
int
,
LPITEMIDLIST
*
);
...
...
@@ -303,6 +306,63 @@ static void test_namespace(void)
IShellDispatch_Release
(
sd
);
}
static
void
test_service
(
void
)
{
static
const
WCHAR
spooler
[]
=
{
'S'
,
'p'
,
'o'
,
'o'
,
'l'
,
'e'
,
'r'
,
0
};
static
const
WCHAR
dummyW
[]
=
{
'd'
,
'u'
,
'm'
,
'm'
,
'y'
,
0
};
SERVICE_STATUS_PROCESS
status
;
SC_HANDLE
scm
,
service
;
IShellDispatch2
*
sd
;
DWORD
dummy
;
HRESULT
hr
;
BSTR
name
;
VARIANT
v
;
hr
=
CoCreateInstance
(
&
CLSID_Shell
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IShellDispatch2
,
(
void
**
)
&
sd
);
if
(
hr
!=
S_OK
)
{
win_skip
(
"IShellDispatch2 not supported
\n
"
);
return
;
}
V_VT
(
&
v
)
=
VT_I2
;
V_I2
(
&
v
)
=
10
;
hr
=
IShellDispatch2_IsServiceRunning
(
sd
,
NULL
,
&
v
);
ok
(
V_VT
(
&
v
)
==
VT_BOOL
,
"got %d
\n
"
,
V_VT
(
&
v
));
ok
(
V_BOOL
(
&
v
)
==
VARIANT_FALSE
,
"got %d
\n
"
,
V_BOOL
(
&
v
));
EXPECT_HR
(
hr
,
S_OK
);
scm
=
OpenSCManagerW
(
NULL
,
NULL
,
SC_MANAGER_CONNECT
);
service
=
OpenServiceW
(
scm
,
spooler
,
SERVICE_QUERY_STATUS
);
QueryServiceStatusEx
(
service
,
SC_STATUS_PROCESS_INFO
,
(
BYTE
*
)
&
status
,
sizeof
(
SERVICE_STATUS_PROCESS
),
&
dummy
);
CloseServiceHandle
(
service
);
CloseServiceHandle
(
scm
);
/* service should exist */
name
=
SysAllocString
(
spooler
);
V_VT
(
&
v
)
=
VT_I2
;
hr
=
IShellDispatch2_IsServiceRunning
(
sd
,
name
,
&
v
);
EXPECT_HR
(
hr
,
S_OK
);
ok
(
V_VT
(
&
v
)
==
VT_BOOL
,
"got %d
\n
"
,
V_VT
(
&
v
));
if
(
status
.
dwCurrentState
==
SERVICE_RUNNING
)
ok
(
V_BOOL
(
&
v
)
==
VARIANT_TRUE
,
"got %d
\n
"
,
V_BOOL
(
&
v
));
else
ok
(
V_BOOL
(
&
v
)
==
VARIANT_FALSE
,
"got %d
\n
"
,
V_BOOL
(
&
v
));
SysFreeString
(
name
);
/* service doesn't exist */
name
=
SysAllocString
(
dummyW
);
V_VT
(
&
v
)
=
VT_I2
;
hr
=
IShellDispatch2_IsServiceRunning
(
sd
,
name
,
&
v
);
EXPECT_HR
(
hr
,
S_OK
);
ok
(
V_VT
(
&
v
)
==
VT_BOOL
,
"got %d
\n
"
,
V_VT
(
&
v
));
ok
(
V_BOOL
(
&
v
)
==
VARIANT_FALSE
,
"got %d
\n
"
,
V_BOOL
(
&
v
));
SysFreeString
(
name
);
IShellDispatch_Release
(
sd
);
}
START_TEST
(
shelldispatch
)
{
HRESULT
r
;
...
...
@@ -314,6 +374,7 @@ START_TEST(shelldispatch)
init_function_pointers
();
test_namespace
();
test_service
();
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