我对这个问题感到困惑,我很难解释,但试试这个......
我连续运行一些安装程序,然后启动一个单独的进程来运行配置程序。
通过控制台,exe和msi文件,安装运行简洁明了。
start = new ProcessStartInfo();
start.WindowStyle = ProcessWindowStyle.Hidden;
start.CreateNoWindow = true;
start.Arguments = s.args;
start.FileName = tempDir + "/" + s.executable;
start.CreateNoWindow = true;
Process.Start(start).WaitForExit();
配置程序设置一些注册表值并读取安装设置的一些注册表值。我遇到的程序是我必须运行两次配置才能读取值......
if (winVer == 32)
{
//Console.WriteLine("Enter 32 bit");
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\KEY\Settings");
workingDir = key.GetValue("WorkingDir").ToString();
//Console.WriteLine(key);
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\KEY");
installPath = key.GetValue("InstallPath").ToString();
//Console.WriteLine(key);
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\KEY\Runtime\
sdkPath = key.GetValue("Path").ToString();
//Console.WriteLine(key);
}
第一次执行此函数时,它返回所有注册表项的空值(有效的错误处理只是没有找到) 但是,如果我imediatly退出控制台应用程序并重新生成它,上面的键都可以完美阅读。
读取注册表是否存在某种延迟,从密钥的泄漏到可以读取的时间。或者在注册表之后我应该强制进行某种刷新吗?
如何超越这一点的任何信息,但更重要的是为什么会发生这种情况将是有益的
在Windows 7中首次启动程序之前,注册表中不存在注册表项, 我的程序试图抓住键然后启动最终程序,但我需要切换它。
让我启动程序......我正在用
启动这个过程 ProcessStartInfo start = null;
start = new ProcessStartInfo();
start.WindowStyle = ProcessWindowStyle.Hidden;
start.CreateNoWindow = true;
start.FileName = proc;
Process.Start(start).WaitForInputIdle();
然而,这会产生更多问题,因为该过程是2步,它加载主程序然后将文件加载到其中(此代码适用于此)但导致主程序进入 inputIdle 循环的问题在文件加载到程序之前,导致整个应用程序继续让我回到找不到注册表项