to jennyvenus() 谢谢你的帮助可以给个例子吗?手上没有api手册! 怎样使用这两个函数!我对这放面还很菜!最好有个事例!
参考这个看看 Option ExplicitPrivate Declare Sub GetSystemTime _ Lib "kernel32" (lpSystemTime As SYSTEMTIME) Private Declare Function SetSystemTime _ Lib "kernel32" (lpSystemTime As SYSTEMTIME) As LongPrivate Type SYSTEMTIME wYear As Integer wMonth As Integer wDayOfWeek As Integer wDay As Integer wHour As Integer wMinute As Integer wSecond As Integer wMilliseconds As Integer End TypeDim UTC As SYSTEMTIME Private Sub Set_Time_Click() Dim lret As Long ' call code here to fill UTC.member with ' the correct numerical data obtained by ' processing the string from a UTC server 'lret = SetSystemTime(UTC) '类似End SubPrivate Sub Command1_Click() GetSystemTime UTC Debug.Print UTC.wYear Debug.Print UTC.wMonth Debug.Print UTC.wDayOfWeek Debug.Print UTC.wDay Debug.Print UTC.wHour Debug.Print UTC.wMinute Debug.Print UTC.wSecond Debug.Print UTC.wMilliseconds End Sub
怎么搞的哦, cmos时间是当地时间,所以用 he GetLocalTime function retrieves the current local date and time. VOID GetLocalTime( LPSYSTEMTIME lpSystemTime // address of system time structure ); 社子用 SetLocalTime. getsystemtime是取的格林时间,又时差的,和你的区域设置有关的,不同的区域,时差不一样。 而反应出来的是在getLocalTime
windows的时间就是cmos时间 Private Declare Sub GetSystemTime _ Lib "kernel32" (lpSystemTime As SYSTEMTIME) Private Declare Function SetSystemTime _ Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long 就行
谢谢你的帮助可以给个例子吗?手上没有api手册!
怎样使用这两个函数!我对这放面还很菜!最好有个事例!
Option ExplicitPrivate Declare Sub GetSystemTime _
Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Declare Function SetSystemTime _
Lib "kernel32" (lpSystemTime As SYSTEMTIME) As LongPrivate Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End TypeDim UTC As SYSTEMTIME
Private Sub Set_Time_Click() Dim lret As Long ' call code here to fill UTC.member with
' the correct numerical data obtained by
' processing the string from a UTC server 'lret = SetSystemTime(UTC)
'类似End SubPrivate Sub Command1_Click()
GetSystemTime UTC
Debug.Print UTC.wYear
Debug.Print UTC.wMonth
Debug.Print UTC.wDayOfWeek
Debug.Print UTC.wDay
Debug.Print UTC.wHour
Debug.Print UTC.wMinute
Debug.Print UTC.wSecond
Debug.Print UTC.wMilliseconds
End Sub
我要的是cmos的时钟。还是两者一样?
http://www.csdn.net/Develop/Read_Article.asp?Id=17296
cmos时间是当地时间,所以用
he GetLocalTime function retrieves the current local date and time.
VOID GetLocalTime(
LPSYSTEMTIME lpSystemTime // address of system time structure
);
社子用
SetLocalTime.
getsystemtime是取的格林时间,又时差的,和你的区域设置有关的,不同的区域,时差不一样。
而反应出来的是在getLocalTime
Private Declare Sub GetSystemTime _
Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Declare Function SetSystemTime _
Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
就行
但我要的是相cmos里写时间!不是改系统时间。
我知道改了系统时间,从起后cmos的时间会被系统改变。
但那是操作系统做到的,我想自己做到这样的功能!
只不过,在去windows的时间的时候,要用GetLocalTime
windows还不是读coms的时间,你改变了windows时间,
coms自然也就改变的拉最简单的,你自己试试不就清楚了吗
主板上用硬件产生时钟脉冲,由电池供电
开机时,BIOS 调入操作系统
操作系统的时间来自主板
你只用更改操作系统的时间就可以了
方法如上