2013-04-05 47 views

回答

5

Windows的istallation时间这将让安装之日起,我不知道,你可以得到时间

string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; 
using(Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key)) 
{ 
    foreach(string subkey_name in key.GetSubKeyNames()) 
    { 
     using(RegistryKey subkey = key.OpenSubKey(subkey_name)) 
     { 
      Console.WriteLine(subkey.GetValue("DisplayName")); 
      Console.WriteLine(subkey.GetValue("InstallDate")); 
     } 
    } 
} 

,您可以使用所有这些领域

registry entries

更多信息请参考this答案。

您可以通过使用Windows Installer API获得时间! 要使用的功能是MsiGetProductInfo和属性名称是INSTALLPROPERTY_INSTALLDATE但WMI重量级。

这里是该物业由here

INSTALLPROPERTY_INSTALLDATE采取更多的信息:上一次该产品获得的服务。每次应用产品补丁或从产品中删除补丁时都会替换此属性的值,或者使用/ v命令行选项修复产品。如果产品未收到修理或修补程序,则此属性包含此产品在此计算机上的安装时间。

实施例:

[DllImport("msi.dll", CharSet=CharSet.Unicode)] 
static extern Int32 MsiGetProductInfo(string product, string property, [Out] StringBuilder valueBuf, ref Int32 len); 

Int32 len = 512; 
System.Text.StringBuilder builder = new System.Text.StringBuilder(len); 
MsiGetProductInfo("{4B3334CE-06D9-4446-BBC5-EB4C9D75BFF6}", "INSTALLPROPERTY_INSTALLDATE", builder , ref len); 
1

你必须在注册表中找到它。

这就是为什么它不是约.NETWinAPI

例如:

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate 

显示你在几秒钟内,因为01.01.1970

相关问题