本文介绍了从注册表项中检索LastWrite时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试从存储USB安装的设备信息的注册表项中检索LastWrite时间,而在转换为DateTime时遇到问题.

我正在使用 RegQueryInfoKey [ ^ ] API和我收回DateTime对象的代码是:

Hi,

I am trying to retrieve the LastWrite time from the Registry key that stores USB mounted device information and I''m having problems with the conversion to DateTime.

I am using the RegQueryInfoKey[^] API and my code to retireve a DateTime object is:

 // override RegQueryInfoKey. lpftLastWriteTime represented by int array
queryInfoKey = RegQueryInfoKey(hSubKey, null, null, IntPtr.Zero,
                ref lpcSubKeys, null, null, ref lpcValues, null, null, null, lpftLastWriteTime);
// subtract the high datetime form the low datetime. low datetime is negative
long lastWriteTime = (((long)lpftLastWriteTime[1]) << 32) + (long)lpftLastWriteTime[0];

// convert long to DateTime object
DateTime lastWrite = DateTime.FromFileTime(lastWriteTime);



但是,此代码在每种情况下都不会返回正确的LastWrite时间.

有人可以对此有所了解吗?

谢谢


Shockmeister.



However, this code does not return the correct LastWrite time in every case.

Can someone shed a bit of light on this?

Thanks


Shockmeister.

推荐答案


这篇关于从注册表项中检索LastWrite时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 18:03