.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Application running at run time

Posted By:Gowthammanju       Posted Date: July 29, 2011    Points: 200    Category: ASP.NET    URL: http://www.dotnetspark.com  

These article explains about running of of application in window start up at boot up time
 

This technique allow us to run application at boot up time as

here it is for both vb.net and c#.net

step1: include namespace as

 for vb application as
Imports Microsoft.Win32


for c# application as

using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using Microsoft.Win32;


step 2: declare the regKey variable as


vb.net:
Dim regKey As RegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)



c#.net:

RegistryKey regKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);


step 3:The first parameter is a name or path of the SubKey to open, while second parameter stands for access to the key (true means writable and false understandably means not writable).

Ok it seems that we are ready to set the value of the regKey:


vb.net:

regKey.SetValue("MyAppName", Application.ExacutablePath.ToString)


c#.net:

regKey.SetValue("MyAppName", Application.ExacutablePath.ToString)



In some situations you may want to check out the value or the certain registry Key

vb.net:
If regKey.GetValue("MyAppName") Is Nothing Then
   'To Do: something
Else
   'To Do: something
End If


c#.net:
if (regKey.GetValue("MyAppName") == null) {
//To Do: something
} else {
	//To Do: something
}

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend