_1234 发表于 2006-7-5 21:26

【原创】显示系统安装时间的小程序

刚才看到有人在问系统安装的时间怎么看的帖子,其实有两个办法:
一是用systeminfo命令,二是可以直接到注册表里面去看
HKLM\Software\Microsoft\Windows NT\CurrentVersion下的InstallDate
键值。systeminfo也是读的这个值吧。

这个值表示的是一个time stamp,可以用C的库函数localtime转换
成当地时间。刚才比较无聊,写了一个小程序来做这件事。

我的系统已经装了有两年了。:D

Qsting 发表于 2006-7-5 21:40

看看我的 ^v^

pingfeily 发表于 2006-7-5 22:21

又学了点知识

sunbest 发表于 2006-7-5 23:47

真厉害啊

truewater 发表于 2006-11-13 11:31

楼主能不能把源程序公布一下,一直在学c语言,想学习学习。

lkj1025 发表于 2006-11-13 11:33

呵呵……。最简单的C程序了,随便找本书对着就算菜鸟也能编

_1234 发表于 2006-11-13 11:39

源代码:(汇编)

;
; System Install date/time
;
format PE GUI 5.0
entry start

include 'win32ax.inc'

ERROR_SUCCESS=0
KEY_QUERY_VALUE=0x0001

section '.SIT' code data readable writable executable

start:
      invokeRegOpenKeyEx,HKEY_LOCAL_MACHINE,\
                'SOFTWARE\Microsoft\Windows NT\CurrentVersion',\
                0,KEY_QUERY_VALUE,key_handle
      cmp   eax,ERROR_SUCCESS
      jne   error_open_key

      invokeRegQueryValueEx,dword,\
                'InstallDate',NULL,NULL,install_time,byte_count
      cmp   eax,ERROR_SUCCESS
      jne   error_query_value

      invokeRegCloseKey,dword

      cinvoke localtime,install_time
      cinvoke asctime,eax
      cinvoke wsprintf,buffer,'%s',eax

      invokeMessageBox,NULL,buffer,'System Install Time',\
                MB_OK+MB_ICONINFORMATION
      ret

error_open_key:
      invokeMessageBox,NULL,\
                'Can not open key for querying value',\
                'Error',MB_ICONERROR+MB_OK
      ret
error_query_value:
      invokeRegCloseKey,dword
      invokeMessageBox,NULL,\
                'Can not query install time date value',\
                'Error',MB_ICONERROR+MB_OK
      ret

;--------------------------------------
key_handle      dd ?
install_time    dd ?
byte_count      dd 4
buffer          rb 64

;--------------------------------------
section '.RES' resource data readable

directory RT_VERSION,versions,\
          RT_MANIFEST,manifests

resource manifests,\
         1,LANG_NEUTRAL,manifest

resdata manifest
include 'winxpvs.res'
endres

resource versions,\
         1,LANG_NEUTRAL,version

versioninfo version,VOS__WINDOWS32,VFT_APP,\
            VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0,\
            'CompanyName','cwu@live.com',\
            'FileDescription','Query System Install Time',\
            'LegalCopyright',<'Copyright ',0A9h,' 2006 Chris Wu'>,\
            'FileVersion','1.0.0.0',\
            'ProductVersion','1.0.0.0',\
            'OriginalFilename','instime.exe'

data import

      library advapi32,'advapi32.dll',\
                msvcrt,'msvcrt.dll',\
                user32,'user32.dll'

      importadvapi32,\
                RegCloseKey,'RegCloseKey',\
                RegOpenKeyEx,'RegOpenKeyExA',\
                RegQueryValueEx,'RegQueryValueExA'

      importmsvcrt,\
                localtime,'localtime',\
                asctime,'asctime'

      importuser32,\
                wsprintf,'wsprintfA',\
                MessageBox,'MessageBoxA'

end data                                    

myjoys 发表于 2006-11-13 11:41

不错的实用的小东西

beyondest 发表于 2006-11-13 13:21

谢谢 收下了

sosoul 发表于 2009-7-10 16:37

谢谢分享!
希望windows 2000下面可用

sy100 发表于 2009-7-10 21:37

好,我也下个试试,谢谢。。。

dtf 发表于 2009-7-10 23:56

嘿嘿,在CMD中,一个SYSTEMINFO命令就可以看得到了。:D
页: [1]
查看完整版本: 【原创】显示系统安装时间的小程序