Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共4 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]能否调整电脑系统的时间

1楼
fczhaobo 发表于:2024/12/10 18:37:00
个别客户端的电脑系统日期和时间不准,能否进行调整,如何处理?
2楼
有点蓝 发表于:2024/12/10 19:42:00
https://www.baidu.com/s?wd=vb.net%20%E6%9B%B4%E6%94%B9%E7%B3%BB%E7%BB%9F%E6%97%B6%E9%97%B4
3楼
fczhaobo 发表于:2024/12/10 20:02:00
蓝老师好,实在转不进来,请详解,谢谢
4楼
有点蓝 发表于:2024/12/10 20:12:00
全局代码

Public Class Form1
    < DllImport("kernel32.dll", SetLastError:=True) > 
    Private Shared Function SetSystemTime(ByRef systime As SYSTEMTIME) As Boolean
    End Function
 
    < StructLayout(LayoutKind.Sequential) > 
    Public Structure SYSTEMTIME
        Public year As Short
        Public month As Short
        Public dayOfWeek As Short
        Public day As Short
        Public hour As Short
        Public minute As Short
        Public second As Short
        Public milliseconds As Short
    End Structure
 
    ' 更改系统时间的函数
    Public Sub ChangeSystemTime(newDateTime As DateTime)
        Dim sysTime As New SYSTEMTIME()
        sysTime.year = CType(newDateTime.Year, Short)
        sysTime.month = CType(newDateTime.Month, Short)
        sysTime.day = CType(newDateTime.Day, Short)
        sysTime.hour = CType(newDateTime.Hour, Short)
        sysTime.minute = CType(newDateTime.Minute, Short)
        sysTime.second = CType(newDateTime.Second, Short)
        sysTime.milliseconds = CType(newDateTime.Millisecond, Short)
 
        If SetSystemTime(sysTime) Then
            ' 成功更改时间
            MessageBox.Show("系统时间已更改。")
        Else
            ' 更改失败,可以通过Marshal.GetLastWin32Error()获取错误代码
            MessageBox.Show("更改系统时间失败,错误代码:" & Marshal.GetLastWin32Error().ToString())
        End If
    End Sub
 

End Class

调用
Dim a As New Form1()
a.ChangeSystemTime(New Date(2024, 12, 9, 12, 0, 0))
共4 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02734 s, 2 queries.