mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
fixup! invoke win32app functions from main
This commit is contained in:
parent
18c00f0a4b
commit
daad975f5d
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#include "Win32/Win32Service.h"
|
||||||
#include "Win32/Win32App.h"
|
#include "Win32/Win32App.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
@ -16,8 +17,46 @@ namespace i2p
|
|||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
SetConsoleCP(1251);
|
SetConsoleCP(1251);
|
||||||
SetConsoleOutputCP(1251);
|
SetConsoleOutputCP(1251);
|
||||||
setlocale(LC_ALL, "Russian");
|
|
||||||
return Daemon_Singleton::init(argc, argv);
|
if (!Daemon_Singleton::init(argc, argv))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::string serviceControl; i2p::config::GetOption("svcctl", serviceControl);
|
||||||
|
if (serviceControl == "install")
|
||||||
|
{
|
||||||
|
LogPrint(eLogInfo, "WinSVC: installing ", SERVICE_NAME, " as service");
|
||||||
|
InstallService(
|
||||||
|
SERVICE_NAME, // Name of service
|
||||||
|
SERVICE_DISPLAY_NAME, // Name to display
|
||||||
|
SERVICE_START_TYPE, // Service start type
|
||||||
|
SERVICE_DEPENDENCIES, // Dependencies
|
||||||
|
SERVICE_ACCOUNT, // Service running account
|
||||||
|
SERVICE_PASSWORD // Password of the account
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (serviceControl == "remove")
|
||||||
|
{
|
||||||
|
LogPrint(eLogInfo, "WinSVC: uninstalling ", SERVICE_NAME, " service");
|
||||||
|
UninstallService(SERVICE_NAME);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDaemon == 1)
|
||||||
|
{
|
||||||
|
LogPrint(eLogDebug, "Daemon: running as service");
|
||||||
|
I2PService service(SERVICE_NAME);
|
||||||
|
if (!I2PService::Run(service))
|
||||||
|
{
|
||||||
|
LogPrint(eLogError, "Daemon: Service failed to run w/err 0x%08lx\n", GetLastError());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
LogPrint(eLogDebug, "Daemon: running as user");
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DaemonWin32::start()
|
bool DaemonWin32::start()
|
||||||
|
@ -157,6 +157,7 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
|||||||
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonLinux.cpp")
|
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonLinux.cpp")
|
||||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR MSYS)
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR MSYS)
|
||||||
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonWin32.cpp")
|
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonWin32.cpp")
|
||||||
|
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/Win32/Win32App.cpp")
|
||||||
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/Win32/Win32Service.cpp")
|
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/Win32/Win32Service.cpp")
|
||||||
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/Win32/Resource.rc")
|
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/Win32/Resource.rc")
|
||||||
endif ()
|
endif ()
|
||||||
@ -309,11 +310,14 @@ include(GNUInstallDirs)
|
|||||||
|
|
||||||
if (WITH_BINARY)
|
if (WITH_BINARY)
|
||||||
add_executable ( "${PROJECT_NAME}" ${DAEMON_SRC} )
|
add_executable ( "${PROJECT_NAME}" ${DAEMON_SRC} )
|
||||||
if(NOT MSVC) # FIXME: incremental linker file name (.ilk) collision for dll & exe
|
if (WIN32)
|
||||||
if (WITH_STATIC)
|
set_target_properties("${PROJECT_NAME}" PROPERTIES WIN32_EXECUTABLE TRUE )
|
||||||
set_target_properties("${PROJECT_NAME}" PROPERTIES LINK_FLAGS "-static" )
|
endif()
|
||||||
endif ()
|
if(NOT MSVC)
|
||||||
endif()
|
if (WITH_STATIC)
|
||||||
|
set_target_properties("${PROJECT_NAME}" PROPERTIES LINK_FLAGS "-static" )
|
||||||
|
endif ()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (WITH_PCH)
|
if (WITH_PCH)
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
|
23
i2pd.cpp
23
i2pd.cpp
@ -3,10 +3,25 @@
|
|||||||
|
|
||||||
int main( int argc, char* argv[] )
|
int main( int argc, char* argv[] )
|
||||||
{
|
{
|
||||||
Daemon.init(argc, argv);
|
if (Daemon.init(argc, argv))
|
||||||
if (Daemon.start())
|
{
|
||||||
Daemon.run ();
|
if (Daemon.start())
|
||||||
Daemon.stop();
|
Daemon.run ();
|
||||||
|
Daemon.stop();
|
||||||
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
int CALLBACK WinMain(
|
||||||
|
_In_ HINSTANCE hInstance,
|
||||||
|
_In_ HINSTANCE hPrevInstance,
|
||||||
|
_In_ LPSTR lpCmdLine,
|
||||||
|
_In_ int nCmdShow
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return main(__argc, __argv);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user