資源簡介
C#調(diào)用Windows API獲取和修改本地/系統(tǒng)時間,C#提升進(jìn)程修改時間權(quán)限
代碼片段和文件信息
using?System;
using?System.Runtime.InteropServices;
namespace?TimeOperate
{
????/*?這里提供的是簡化版的提升權(quán)限,對于修改系統(tǒng)時間而言已經(jīng)足夠了
?????*?
?????*?如果需要下載完整版,可以通過以下鏈接:
?????*?http://download.csdn.net/download/softimite_zifeng/10007365
?????*/
????class?PrivilegeAPI
????{
????????[DllImport(“kernel32.dll“?CharSet?=?CharSet.Auto?SetLastError?=?true)]
????????public?static?extern?IntPtr?GetCurrentProcess();
????????[DllImport(“Advapi32.dll“?CharSet?=?CharSet.Auto?SetLastError?=?true)]
????????[return:?MarshalAs(UnmanagedType.Bool)]
????????public?static?extern?bool?OpenProcessToken(IntPtr?ProcessHandle?uint?DesiredAccesss?out?IntPtr?TokenHandle);
????????[DllImport(“kernel32.dll“?CharSet?=?CharSet.Auto?SetLastError?=?true)]
????????[return:?MarshalAs(UnmanagedType.Bool)]
????????public?static?extern?bool?CloseHandle(IntPtr?hobject);
????????[DllImport(“advapi32.dll“?CharSet?=?CharSet.Unicode?SetLastError?=?true)]
????????[return:?MarshalAs(UnmanagedType.Bool)]
????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????2855??2017-10-05?14:56??修改Windows本地或系統(tǒng)時間(C#)\PrivilegeAPI.cs
?????文件????????5154??2017-10-04?16:43??修改Windows本地或系統(tǒng)時間(C#)\PrivilegeUtil.cs
?????文件????????1295??2017-10-04?16:24??修改Windows本地或系統(tǒng)時間(C#)\TimeAPI.cs
?????文件????????4963??2017-10-04?16:50??修改Windows本地或系統(tǒng)時間(C#)\TimeUtil.cs
?????目錄???????????0??2017-10-04?16:45??修改Windows本地或系統(tǒng)時間(C#)\
評論
共有 條評論