Skip to content

Commit

Permalink
Merge pull request #8 from ntoskrnl7/fix/service-install-method
Browse files Browse the repository at this point in the history
Fix Service::Install method.
  • Loading branch information
ntoskrnl7 authored Aug 18, 2022
2 parents 0412690 + 3bd367e commit f1a00d5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,7 @@ jobs:
working-directory: test/build

- name: Configure CMake
if: ${{ (matrix.gen != '') && ((matrix.sys == 'CLANG32') || (matrix.sys == 'CLANG64')) }}
run: cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G "${{matrix.gen}}" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
working-directory: test/build

- name: Configure CMake
if: ${{ (matrix.gen != '') && (!((matrix.sys == 'CLANG32') || (matrix.sys == 'CLANG64'))) }}
if: ${{ (matrix.gen != '') }}
run: cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G "${{matrix.gen}}"
working-directory: test/build

Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ add_executable(tests tests.cpp)
# add dependencies
include(cmake/CPM.cmake)
CPMAddPackage("gh:ntoskrnl7/win32-ex@0.8.20")
CPMAddPackage("gh:ntoskrnl7/win32-ex@0.8.21")
# link dependencies
target_link_libraries(tests win32ex)
Expand All @@ -223,13 +223,35 @@ target_link_libraries(tests win32ex)

```C++
#include <iostream>

#include <Win32Ex/System/Process.hpp>
#include <Win32Ex/System/Service.hpp>
// or #include <Win32Ex.h>
// or #include <Win32Ex/System.h>

Win32Ex::System::Service SimpleService("SimpleSvc");

int main()
{
std::cout << Win32Ex::System::Process::All().size();

Win32Ex::System::Service::Instance<SimpleService>::Get()
.OnStart([]() {
// TODO
})
.OnStop([]() {
// TODO
})
.OnPause([]() {
// TODO
})
.OnContinue([]() {
// TODO
})
.OnError([](DWORD ErrorCode, PCSTR Message) {
// TODO
})
.Run();
return 0;
}
```
2 changes: 1 addition & 1 deletion include/Win32Ex/Internal/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ Module Name:

#define WIN32EX_VERSION_MAJOR 0
#define WIN32EX_VERSION_MINOR 8
#define WIN32EX_VERSION_PATCH 20
#define WIN32EX_VERSION_PATCH 21

#endif // _WIN32EX_VERSION_H_
3 changes: 3 additions & 0 deletions include/Win32Ex/System/Service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ template <class _StringType = StringT> class ServiceT
}
dependencies.push_back(0);

if (binaryPathName_.empty())
this->BinaryPathName();

if (!handle.Attach(CreateServiceT<CharType>(
handle.hSCManager, name_.c_str(), displayName_.empty() ? NULL : displayName_.c_str(),
SERVICE_CHANGE_CONFIG, ServiceType, StartType, ErrorControl, binaryPathName_.c_str(),
Expand Down

0 comments on commit f1a00d5

Please sign in to comment.