如果只想改动cmos时间,可以调用api,setlocaltime等,cmos时间同时改动了

解决方案 »

  1.   

    to jennyvenus()
    谢谢你的帮助可以给个例子吗?手上没有api手册!
    怎样使用这两个函数!我对这放面还很菜!最好有个事例!
      

  2.   

    参考这个看看
    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
      

  3.   

    请问getsystemtime所取的不是系统时钟吗?
    我要的是cmos的时钟。还是两者一样?
      

  4.   

    这个是很近似的,至于读取真正的cmos时间,让我想想。
      

  5.   

    http://www.16167.com/bbs/showthread.php?threadid=5005
    http://www.csdn.net/Develop/Read_Article.asp?Id=17296
      

  6.   

    怎么搞的哦,
    cmos时间是当地时间,所以用
    he GetLocalTime function retrieves the current local date and time. 
    VOID GetLocalTime(
        LPSYSTEMTIME lpSystemTime  // address of system time structure  
       );
    社子用
    SetLocalTime.
    getsystemtime是取的格林时间,又时差的,和你的区域设置有关的,不同的区域,时差不一样。
    而反应出来的是在getLocalTime
      

  7.   

    我觉得windows取的时间就是来源于cmos,更改windows的系统时间就差不多是更改了cmos的时间啊。
      

  8.   

    windows的时间就是cmos时间
    Private Declare Sub GetSystemTime _
       Lib "kernel32" (lpSystemTime As SYSTEMTIME)
    Private Declare Function SetSystemTime _
       Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
    就行
      

  9.   

    debug.print timetime=12:00debug.print time改变了windows 的时间就改变了cmos的时间
      

  10.   

    CMOS中的时间应该就是Windows中的时间。记得以前CIH病毒流行的时候不是经常通过Windows提前把时间改成27号的吗?
      

  11.   

    谢谢大家的帮忙!
    但我要的是相cmos里写时间!不是改系统时间。
    我知道改了系统时间,从起后cmos的时间会被系统改变。
    但那是操作系统做到的,我想自己做到这样的功能!
      

  12.   

    当然cmos时间和windows的时间是对应的,你随便改一个,都会影响另一个,
    只不过,在去windows的时间的时候,要用GetLocalTime
      

  13.   

    同意,搞这么多干吗,
    windows还不是读coms的时间,你改变了windows时间,
    coms自然也就改变的拉最简单的,你自己试试不就清楚了吗
      

  14.   

    coms 只是存储用的和内存差不多,
    主板上用硬件产生时钟脉冲,由电池供电
    开机时,BIOS 调入操作系统
    操作系统的时间来自主板
    你只用更改操作系统的时间就可以了
    方法如上