Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RegistryKey last write time

Tags:

c#

.net

Using Microsoft.Win32.RegistryKey (or any related classes), how can I query the last write time of a registry key?

like image 880
Josh Avatar asked Dec 31 '25 13:12

Josh


1 Answers

You will need to use P/Invoke to make a call to the Win32 API:

MSDN: RegQueryInfoKey function

Signature from pinvoke.net:

[DllImport("advapi32.dll", EntryPoint="RegQueryInfoKey", CallingConvention=CallingConvention.Winapi, SetLastError=true)]
extern private static int RegQueryInfoKey(
    UIntPtr hkey,
    out StringBuilder lpClass,
    ref uint lpcbClass,
    IntPtr lpReserved,
    out uint lpcSubKeys,
    out uint lpcbMaxSubKeyLen,
    out uint lpcbMaxClassLen,
    out uint lpcValues,
    out uint lpcbMaxValueNameLen,
    out uint lpcbMaxValueLen,
    out uint lpcbSecurityDescriptor,
    IntPtr lpftLastWriteTime);
like image 166
Jason Watkins Avatar answered Jan 02 '26 03:01

Jason Watkins