.net - Detecting the time when the program was installed -


this question has answer here:

can somehow detect time when program installed using .net or win32 api or other way?

this date of installation, i'm not sure of can time

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"));         }     } } 

you can use these fields

registry entries

for more info refer this answer.

you can time using windows installer api! function used msigetproductinfo , property name installproperty_installdate wmi heavyweight.

here more info property taken here

installproperty_installdate: the last time product received service. value of property replaced each time patch applied or removed product or /v command-line option used repair product. if product has received no repairs or patches property contains time product installed on computer.

example:

[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); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -