独立Windows方法项目

This commit is contained in:
falcon 2023-02-16 18:12:17 +08:00
parent 368fdd5ddd
commit ee4854787e
5 changed files with 38 additions and 16 deletions

View File

@ -4,6 +4,11 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Description>WebService相关方法</Description>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Description>Windows系统相关方法</Description>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.0</Version>
</PropertyGroup>
</Project>

View File

@ -1,12 +1,8 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
namespace Falcon.SugarApi.WindowsSystem
namespace Falcon.SugarApi.Windows
{
/// <summary>
/// Windows系统时间
/// </summary>
public static class WindowsSystemTime
public partial class System
{
[StructLayout(LayoutKind.Sequential)]
private struct Systemtime
@ -31,16 +27,17 @@ namespace Falcon.SugarApi.WindowsSystem
/// <returns>返回系统时间设置状态true为成功false为失败</returns>
public static bool SetLocalDateTime(DateTime dt) {
Systemtime st;
st.year = (short)dt.Year;
st.month = (short)dt.Month;
st.dayOfWeek = (short)dt.DayOfWeek;
st.day = (short)dt.Day;
st.hour = (short)dt.Hour;
st.minute = (short)dt.Minute;
st.second = (short)dt.Second;
st.milliseconds = (short)dt.Millisecond;
st.year=(short)dt.Year;
st.month=(short)dt.Month;
st.dayOfWeek=(short)dt.DayOfWeek;
st.day=(short)dt.Day;
st.hour=(short)dt.Hour;
st.minute=(short)dt.Minute;
st.second=(short)dt.Second;
st.milliseconds=(short)dt.Millisecond;
bool rt = SetLocalTime(ref st);
return rt;
}
}
}
}

View File

@ -15,6 +15,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Falcon.SugarApi.WebService", "Falcon.SugarApi.WebService\Falcon.SugarApi.WebService.csproj", "{A02586C2-B485-47C3-988B-AC050BD2286C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Falcon.SugarApi.Windows", "Falcon.SugarApi.Windows\Falcon.SugarApi.Windows.csproj", "{68AF37DA-5B3E-4ADF-9054-CE5F42667625}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -33,6 +35,10 @@ Global
{A02586C2-B485-47C3-988B-AC050BD2286C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A02586C2-B485-47C3-988B-AC050BD2286C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A02586C2-B485-47C3-988B-AC050BD2286C}.Release|Any CPU.Build.0 = Release|Any CPU
{68AF37DA-5B3E-4ADF-9054-CE5F42667625}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68AF37DA-5B3E-4ADF-9054-CE5F42667625}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68AF37DA-5B3E-4ADF-9054-CE5F42667625}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68AF37DA-5B3E-4ADF-9054-CE5F42667625}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE