6 c# count scheduled-tasks execution
如何在不保留文件和计数的情况下获得程序先前在C#中运行的次数.如果不可能,可以从预定任务管理器获取吗?
致C. Ross:如何在注册表设置中完成?原谅我...什么是注册表设置?
Che*_*eso 13
我在注册表设置中执行此操作.
static string AppRegyPath = "Software\\Cheeso\\ApplicationName";
static string rvn_Runs = "Runs";
private Microsoft.Win32.RegistryKey _appCuKey;
public Microsoft.Win32.RegistryKey AppCuKey
{
get
{
if (_appCuKey == null)
{
_appCuKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(AppRegyPath, true);
if (_appCuKey == null)
_appCuKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(AppRegyPath);
}
return _appCuKey;
}
set { _appCuKey = null; }
}
public int UpdateRunCount()
{
int x = (Int32)AppCuKey.GetValue(rvn_Runs, 0);
x++;
AppCuKey.SetValue(rvn_Runs, x);
return x;
}
Run Code Online (Sandbox Code Playgroud)
如果它是一个WinForms应用程序,您可以挂钩Form的OnClosing事件来运行UpdateCount.
| 归档时间: |
|
| 查看次数: |
5661 次 |
| 最近记录: |