-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
329 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.1.32210.238 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kervellis", "Kervellis\Kervellis.csproj", "{96B059F1-8D5F-4CFA-8392-BCBDD7F0C40A}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x64 = Debug|x64 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x64 = Release|x64 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{96B059F1-8D5F-4CFA-8392-BCBDD7F0C40A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{96B059F1-8D5F-4CFA-8392-BCBDD7F0C40A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{96B059F1-8D5F-4CFA-8392-BCBDD7F0C40A}.Debug|x64.ActiveCfg = Debug|x64 | ||
{96B059F1-8D5F-4CFA-8392-BCBDD7F0C40A}.Debug|x64.Build.0 = Debug|x64 | ||
{96B059F1-8D5F-4CFA-8392-BCBDD7F0C40A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{96B059F1-8D5F-4CFA-8392-BCBDD7F0C40A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{96B059F1-8D5F-4CFA-8392-BCBDD7F0C40A}.Release|x64.ActiveCfg = Release|x64 | ||
{96B059F1-8D5F-4CFA-8392-BCBDD7F0C40A}.Release|x64.Build.0 = Release|x64 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {F3A2C751-6AAA-4DE5-9485-CD95D697553F} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.ServiceProcess; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Kervellis | ||
{ | ||
public enum ServiceState | ||
{ | ||
SERVICE_STOPPED = 0x00000001, | ||
SERVICE_START_PENDING = 0x00000002, | ||
SERVICE_STOP_PENDING = 0x00000003, | ||
SERVICE_RUNNING = 0x00000004, | ||
SERVICE_CONTINUE_PENDING = 0x00000005, | ||
SERVICE_PAUSE_PENDING = 0x00000006, | ||
SERVICE_PAUSED = 0x00000007, | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
public struct ServiceStatus | ||
{ | ||
public int dwServiceType; | ||
public ServiceState dwCurrentState; | ||
public int dwControlsAccepted; | ||
public int dwWin32ExitCode; | ||
public int dwServiceSpecificExitCode; | ||
public int dwCheckPoint; | ||
public int dwWaitHint; | ||
}; | ||
|
||
static class NativeMethods | ||
{ | ||
[DllImport("kernel32.dll")] | ||
public static extern IntPtr LoadLibrary(string dllToLoad); | ||
|
||
[DllImport("kernel32.dll")] | ||
public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName); | ||
|
||
[DllImport("kernel32.dll")] | ||
public static extern bool FreeLibrary(IntPtr hModule); | ||
|
||
[DllImport("advapi32.dll", SetLastError = true)] | ||
public static extern bool SetServiceStatus(System.IntPtr handle, ref ServiceStatus serviceStatus); | ||
} | ||
|
||
|
||
public partial class Service1 : ServiceBase | ||
{ | ||
ServiceStatus serviceStatus; | ||
string kervellis_installation_folder; | ||
string dllName; | ||
string dllFullPath; | ||
Thread work; | ||
|
||
public Service1() | ||
{ | ||
InitializeComponent(); | ||
serviceStatus = new ServiceStatus(); | ||
kervellis_installation_folder = @"C:\kervellis\kervellis-1.0"; | ||
dllName = "kervellis.dll"; | ||
dllFullPath = Path.Combine(kervellis_installation_folder, dllName); | ||
} | ||
|
||
public void DoWork() | ||
{ | ||
if (!Directory.Exists(kervellis_installation_folder)) | ||
{ | ||
Directory.CreateDirectory(kervellis_installation_folder); | ||
} | ||
|
||
IntPtr pDll; | ||
do | ||
{ | ||
|
||
pDll = NativeMethods.LoadLibrary(dllFullPath); | ||
Thread.Sleep(5000); | ||
|
||
|
||
} while (pDll == IntPtr.Zero); | ||
|
||
NativeMethods.FreeLibrary(pDll); | ||
} | ||
|
||
protected override void OnStart(string[] args) | ||
{ | ||
/* | ||
serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING; | ||
serviceStatus.dwWaitHint = 100000; | ||
NativeMethods.SetServiceStatus(this.ServiceHandle, ref serviceStatus); | ||
*/ | ||
|
||
work = new Thread(DoWork); | ||
work.Start(); | ||
|
||
/* | ||
serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING; | ||
NativeMethods.SetServiceStatus(this.ServiceHandle, ref serviceStatus); | ||
*/ | ||
} | ||
|
||
protected override void OnStop() | ||
{ | ||
work.Abort(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{96B059F1-8D5F-4CFA-8392-BCBDD7F0C40A}</ProjectGuid> | ||
<OutputType>WinExe</OutputType> | ||
<RootNamespace>Kervellis</RootNamespace> | ||
<AssemblyName>Kervellis</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\x64\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<LangVersion>7.3</LangVersion> | ||
<ErrorReport>prompt</ErrorReport> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> | ||
<OutputPath>bin\x64\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<DebugType>pdbonly</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<LangVersion>7.3</LangVersion> | ||
<ErrorReport>prompt</ErrorReport> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.ServiceProcess" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Kervellis.cs"> | ||
<SubType>Component</SubType> | ||
</Compile> | ||
<Compile Include="Kervellis.Designer.cs"> | ||
<DependentUpon>Kervellis.cs</DependentUpon> | ||
</Compile> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.ServiceProcess; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Kervellis | ||
{ | ||
internal static class Program | ||
{ | ||
/// <summary> | ||
/// Point d'entrée principal de l'application. | ||
/// </summary> | ||
static void Main() | ||
{ | ||
ServiceBase[] ServicesToRun; | ||
ServicesToRun = new ServiceBase[] | ||
{ | ||
new Service1() | ||
}; | ||
ServiceBase.Run(ServicesToRun); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// Les informations générales relatives à un assembly dépendent de | ||
// l'ensemble d'attributs suivant. Pour modifier les informations | ||
// associées à un assembly. | ||
[assembly: AssemblyTitle("Kervellis")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Kervellis")] | ||
[assembly: AssemblyCopyright("Copyright © 2022")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly | ||
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de | ||
// COM, affectez la valeur True à l'attribut ComVisible sur ce type. | ||
[assembly: ComVisible(false)] | ||
|
||
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM | ||
[assembly: Guid("96b059f1-8d5f-4cfa-8392-bcbdd7f0c40a")] | ||
|
||
// Les informations de version pour un assembly se composent des quatre valeurs suivantes : | ||
// | ||
// Version principale | ||
// Version secondaire | ||
// Numéro de build | ||
// Révision | ||
// | ||
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut | ||
// en utilisant '*', comme indiqué ci-dessous : | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |