Usuário com melhor resposta
Windows Form

Pergunta
-
Respostas
Todas as Respostas
-
Sérgio:
Não entendi muito bem tua pergunta, mas acho que voce quer que um aplicativo seja iniciado junto ao inicializar o windows certo?
Porque não utiliza o Agendador de Tarefas do windows? (menu iniciar, acessorios, Ferramentas de sistema, tarefas agendadas)
-
-
-
-
Olá!
Fiz um programa em Windows Forms que fará uma sincronização entre 2 bases de tempos em tempos. Tentei criar um Windows Service para apenas startá-lo (utilizando System.Diagnostics.Process), mas não deu muito certo. O Windows Service diz que não há nada para ser feito e nem inicia o serviço.
Por que será que ocorre isso? Será que é porque ele faz a chamada a um programa em WindowsForms?
-
Um exemplo, onde você escolhe através de uma CheckBox se deseja que o programa seja iniciado junto com o Windows!!
// The path to the key where Windows looks for startup applications
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); public frmStartup(){
InitializeComponent();
// Check to see the current state (running at startup or not) if (rkApp.GetValue("MyApp") == null){
// The value doesn't exist, the application is not set to run at startupchkRun.Checked =
false;}
else{
// The value exists, the application is set to run at startupchkRun.Checked =
true;}
}
private void btnOk_Click(object sender, EventArgs e){
if (chkRun.Checked){
// Add the value in the registry so that the application runs at startuprkApp.SetValue(
"MyApp", Application.ExecutablePath.ToString());}
else{
// Remove the value from the registry so that the application doesn't startrkApp.DeleteValue(
"MyApp", false);}
}