Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
6f84c8bb
Commit
6f84c8bb
authored
Jan 14, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using unicode API for service creation
parent
0adbfcba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
17 deletions
+15
-17
main.c
build/main.c
+15
-17
No files found.
build/main.c
View file @
6f84c8bb
...
...
@@ -557,8 +557,7 @@ static HICON hIcon;
static
HANDLE
hThread
;
// Serving thread
static
SERVICE_STATUS
ss
;
static
SERVICE_STATUS_HANDLE
hStatus
;
static
const
char
*
service_magic_argument
=
"--"
;
static
const
char
*
service_name
=
"Mongoose"
;
static
const
wchar_t
*
service_name
=
L"Mongoose"
;
static
NOTIFYICONDATA
TrayIcon
;
static
void
WINAPI
ControlHandler
(
DWORD
code
)
{
...
...
@@ -574,7 +573,7 @@ static void WINAPI ControlHandler(DWORD code) {
}
static
void
WINAPI
ServiceMain
(
void
)
{
hStatus
=
RegisterServiceCtrlHandler
(
service_name
,
ControlHandler
);
hStatus
=
RegisterServiceCtrlHandler
W
(
service_name
,
ControlHandler
);
ControlHandler
(
SERVICE_CONTROL_INTERROGATE
);
while
(
ss
.
dwCurrentState
==
SERVICE_RUNNING
)
{
...
...
@@ -863,7 +862,7 @@ static void show_settings_dialog() {
static
int
manage_service
(
int
action
)
{
SC_HANDLE
hSCM
=
NULL
,
hService
=
NULL
;
SERVICE_DESCRIPTION
descr
=
{
server_name
};
char
path
[
PATH_MAX
+
20
];
// Path to executable plus magic argument
wchar_t
w
path
[
PATH_MAX
+
20
];
// Path to executable plus magic argument
int
success
=
1
;
if
((
hSCM
=
OpenSCManager
(
NULL
,
NULL
,
action
==
ID_INSTALL_SERVICE
?
...
...
@@ -871,25 +870,24 @@ static int manage_service(int action) {
success
=
0
;
show_error
();
}
else
if
(
action
==
ID_INSTALL_SERVICE
)
{
GetModuleFileName
(
NULL
,
path
,
sizeof
(
path
));
strncat
(
path
,
" "
,
sizeof
(
path
));
strncat
(
path
,
service_magic_argument
,
sizeof
(
path
));
hService
=
CreateService
(
hSCM
,
service_name
,
service_name
,
SERVICE_ALL_ACCESS
,
SERVICE_WIN32_OWN_PROCESS
,
SERVICE_AUTO_START
,
SERVICE_ERROR_NORMAL
,
path
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
GetModuleFileNameW
(
NULL
,
wpath
,
sizeof
(
wpath
)
/
sizeof
(
wpath
[
0
]));
wcsncat
(
wpath
,
L" --"
,
sizeof
(
wpath
)
/
sizeof
(
wpath
[
0
]));
hService
=
CreateServiceW
(
hSCM
,
service_name
,
service_name
,
SERVICE_ALL_ACCESS
,
SERVICE_WIN32_OWN_PROCESS
,
SERVICE_AUTO_START
,
SERVICE_ERROR_NORMAL
,
wpath
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
hService
)
{
ChangeServiceConfig2
(
hService
,
SERVICE_CONFIG_DESCRIPTION
,
&
descr
);
}
else
{
show_error
();
}
}
else
if
(
action
==
ID_REMOVE_SERVICE
)
{
if
((
hService
=
OpenService
(
hSCM
,
service_name
,
DELETE
))
==
NULL
||
if
((
hService
=
OpenService
W
(
hSCM
,
service_name
,
DELETE
))
==
NULL
||
!
DeleteService
(
hService
))
{
show_error
();
}
}
else
if
((
hService
=
OpenService
(
hSCM
,
service_name
,
SERVICE_QUERY_STATUS
))
==
NULL
)
{
}
else
if
((
hService
=
OpenService
W
(
hSCM
,
service_name
,
SERVICE_QUERY_STATUS
))
==
NULL
)
{
success
=
0
;
}
...
...
@@ -906,15 +904,15 @@ static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam,
{
NULL
,
NULL
}
};
int
service_installed
;
char
buf
[
200
],
*
service_argv
[]
=
{
__argv
[
0
]
,
NULL
};
char
buf
[
200
],
*
service_argv
[]
=
{
NULL
,
NULL
};
POINT
pt
;
HMENU
hMenu
;
static
UINT
s_uTaskbarRestart
;
// for taskbar creation
switch
(
msg
)
{
case
WM_CREATE
:
if
(
__argv
[
1
]
!=
NULL
&&
!
strcmp
(
__argv
[
1
],
service_magic_argument
))
{
if
(
my_argv
[
1
]
!=
NULL
&&
!
strcmp
(
my_argv
[
1
],
"--"
))
{
service_argv
[
0
]
=
my_argv
[
0
];
start_mongoose
(
1
,
service_argv
);
hThread
=
mg_start_thread
(
serving_thread_func
,
server
);
StartServiceCtrlDispatcher
(
service_table
);
...
...
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