你要做一个自动更新程序是吗!
看看这个过程 private void CheckUpdates()
{
MainProject.status_ActionNotice.Text = "正在检测是否需要更新...";
btnLogin.Enabled = false; if (IsNeedUpdated())
{
try
{
Process.Start("AutoUpdate.exe");
}
catch (Exception ex)
{
MessageBox.Show("升级程序错误:" + ex.Message, ERROR_TITLE);
}
Process.GetCurrentProcess().Kill(); } MainProject.status_ActionNotice.Text = "检测完成,不需要更新.";
btnLogin.Enabled = true;
} private bool IsNeedUpdated()
{
string localXmlFile = Application.StartupPath + "\\Update.xml";
string serverXmlFile = string.Empty; XmlFiles updaterXmlFiles = null; try
{
//从本地读取更新配置文件信息
updaterXmlFiles = new XmlFiles(localXmlFile);
}
catch
{
MessageBox.Show("配置文件出错!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
//获取服务器地址
string updateUrl = updaterXmlFiles.GetNodeValue("//Url"); AppUpdater appUpdater = new AppUpdater();
appUpdater.UpdaterUrl = updateUrl + "/UpdateList.xml"; //与服务器连接,下载更新配置文件
string tempUpdatePath = string.Empty;
try
{
tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";
appUpdater.DownAutoUpdateFile(tempUpdatePath);
}
catch
{
MessageBox.Show("与服务器连接失败,操作超时!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return false; } serverXmlFile = tempUpdatePath + "\\Update.xml";
if (!File.Exists(serverXmlFile))
{
return false;
} int availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile);
return (availableUpdate > 0);
}
希望给你点启示
看看这个过程 private void CheckUpdates()
{
MainProject.status_ActionNotice.Text = "正在检测是否需要更新...";
btnLogin.Enabled = false; if (IsNeedUpdated())
{
try
{
Process.Start("AutoUpdate.exe");
}
catch (Exception ex)
{
MessageBox.Show("升级程序错误:" + ex.Message, ERROR_TITLE);
}
Process.GetCurrentProcess().Kill(); } MainProject.status_ActionNotice.Text = "检测完成,不需要更新.";
btnLogin.Enabled = true;
} private bool IsNeedUpdated()
{
string localXmlFile = Application.StartupPath + "\\Update.xml";
string serverXmlFile = string.Empty; XmlFiles updaterXmlFiles = null; try
{
//从本地读取更新配置文件信息
updaterXmlFiles = new XmlFiles(localXmlFile);
}
catch
{
MessageBox.Show("配置文件出错!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
//获取服务器地址
string updateUrl = updaterXmlFiles.GetNodeValue("//Url"); AppUpdater appUpdater = new AppUpdater();
appUpdater.UpdaterUrl = updateUrl + "/UpdateList.xml"; //与服务器连接,下载更新配置文件
string tempUpdatePath = string.Empty;
try
{
tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";
appUpdater.DownAutoUpdateFile(tempUpdatePath);
}
catch
{
MessageBox.Show("与服务器连接失败,操作超时!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return false; } serverXmlFile = tempUpdatePath + "\\Update.xml";
if (!File.Exists(serverXmlFile))
{
return false;
} int availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile);
return (availableUpdate > 0);
}
希望给你点启示
用VS2008或以上吧,创建配置服务特简单,点两下写业务就行了。再看一下制作windows服务的安装包就结了。
我程序写好了,但怎么在登录的时候挂起来我程序
要交互则(难度不小,托管代码可能不可以):
XP: 改写GINA
Vista/Win7:写Credential Provider
我系统是 win7的 有没有办法在winlogon界面启动程序吗,我看好多东西看的我迷糊!