Click here to Skip to main content
16,005,437 members
Home / Discussions / C#
   

C#

 
QuestionKeeping context menu open even after clicking? Pin
Carl Mercier28-Oct-04 9:29
Carl Mercier28-Oct-04 9:29 
AnswerRe: Keeping context menu open even after clicking? Pin
Heath Stewart28-Oct-04 15:58
protectorHeath Stewart28-Oct-04 15:58 
GeneralRe: Keeping context menu open even after clicking? Pin
Carl Mercier29-Oct-04 3:50
Carl Mercier29-Oct-04 3:50 
GeneralRe: Keeping context menu open even after clicking? Pin
LongRange.Shooter29-Oct-04 6:50
LongRange.Shooter29-Oct-04 6:50 
AnswerRe: Keeping context menu open even after clicking? Pin
perlmunger29-Oct-04 9:09
perlmunger29-Oct-04 9:09 
Generalabout device instance enumeration Pin
momer28-Oct-04 9:07
momer28-Oct-04 9:07 
GeneralRe: about device instance enumeration Pin
Heath Stewart28-Oct-04 15:53
protectorHeath Stewart28-Oct-04 15:53 
GeneralRegistry problem..! Pin
QzRz28-Oct-04 8:03
QzRz28-Oct-04 8:03 
Hi...

I want my Application to run when windows start..!
I didn't know how to do it, so i searched the registry on my computer and found the key i think was the right ("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")

I tried to do this...

string path = Environment.CurrentDirectory + "\\MyApp.exe";
RegistryKey App = Registry.LocalMachine;
RegistryKey App = App.OpenSubKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\");
App.SetValue("MyApp", path);

But that did not work.... it throws a "'System.NullReferenceException' -
Additional information: Object reference not set to an instance of an object."


Then I tried this....

string path = Environment.CurrentDirectory + "\\MyApp.exe";
Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Run").SetValue("MyApp", path);

But it also thorws an error -> "'System.UnauthorizedAccessException' occurred in mscorlib.dll - Additional information: Cannot write to the registry key."

I have no idea what to do then! Confused | :confused:
Can anyone help me how to write to the registry or tell me a way so my application will run when windows start?

Thanks...!


QzRz
GeneralRe: Registry problem..! Pin
Christian Graus28-Oct-04 9:39
protectorChristian Graus28-Oct-04 9:39 
GeneralRe: Registry problem..! Pin
QzRz28-Oct-04 9:45
QzRz28-Oct-04 9:45 
GeneralRe: Registry problem..! Pin
Christian Graus28-Oct-04 9:48
protectorChristian Graus28-Oct-04 9:48 
GeneralRe: Registry problem..! Pin
Alex Korchemniy28-Oct-04 10:04
Alex Korchemniy28-Oct-04 10:04 
GeneralRe: Registry problem..! Pin
Dave Kreskowiak28-Oct-04 16:49
mveDave Kreskowiak28-Oct-04 16:49 
GeneralRe: Registry problem..! Pin
QzRz29-Oct-04 6:19
QzRz29-Oct-04 6:19 
GeneralRe: Registry problem..! Pin
Dave Kreskowiak29-Oct-04 11:34
mveDave Kreskowiak29-Oct-04 11:34 
GeneralRe: Registry problem..! Pin
QzRz29-Oct-04 11:46
QzRz29-Oct-04 11:46 
GeneralRe: Registry problem..! Pin
Dave Kreskowiak29-Oct-04 18:49
mveDave Kreskowiak29-Oct-04 18:49 
GeneralRe: Registry problem..! Pin
QzRz29-Oct-04 23:14
QzRz29-Oct-04 23:14 
Generalresponding to javascript in html Pin
JeromeKJerome28-Oct-04 8:02
JeromeKJerome28-Oct-04 8:02 
GeneralRe: responding to javascript in html Pin
Heath Stewart28-Oct-04 15:48
protectorHeath Stewart28-Oct-04 15:48 
GeneralRe: responding to javascript in html Pin
JeromeKJerome28-Oct-04 16:17
JeromeKJerome28-Oct-04 16:17 
GeneralRe: responding to javascript in html Pin
Heath Stewart29-Oct-04 5:28
protectorHeath Stewart29-Oct-04 5:28 
GeneralRe: responding to javascript in html Pin
JeromeKJerome29-Oct-04 8:08
JeromeKJerome29-Oct-04 8:08 
GeneralRe: responding to javascript in html Pin
JeromeKJerome29-Oct-04 9:27
JeromeKJerome29-Oct-04 9:27 
GeneralRe: responding to javascript in html Pin
JeromeKJerome29-Oct-04 13:41
JeromeKJerome29-Oct-04 13:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.