创建注册表文件 [英] Create registry file
本文介绍了创建注册表文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在C Sharp Windows应用程序中创建注册表文件.在此文件中,我想存储上次执行日期& amp;在下次执行时读取此日期,以比较注册表&的最后执行日期.当前系统日期.如果可以隐藏此注册表文件.
How can I create a registry file in C Sharp Windows Application. In this file I want to store last execution date & read this date when next execution for compare the last execution date from registry & current System date. If is it possible to hide this registry file.
推荐答案
尝试以下代码:)
try this Code :)
DateTime GetLastExecutionDate()
{
RegistryKey rkey = Registry.CurrentUser;
RegistryKey rkey1 = rkey.OpenSubKey("software", true);
RegistryKey rkey2 = rkey1.CreateSubKey("tes");
DateTime lastDate = DateTime.Parse(rkey2.GetValue("LastDate").ToString());
return lastDate;
}
void AddLastExecutionDate()
{
RegistryKey rkey = Registry.CurrentUser;
RegistryKey rkey1 = rkey.OpenSubKey("software", true);
RegistryKey rkey2 = rkey1.CreateSubKey("tes");
rkey2.SetValue("LastDate", DateTime.Now.ToShortDateString());
}
此链接将有助于注册表操作
使用C#从注册表中读取,写入和删除 [
this link will help for registry operations
Read, write and delete from registry with C#[^]
这篇关于创建注册表文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文