Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
AnswerRe: Windows Form Icons Pin
kenexcelon7-Dec-08 14:56
kenexcelon7-Dec-08 14:56 
GeneralRe: Windows Form Icons Pin
Luc Pattyn7-Dec-08 15:16
sitebuilderLuc Pattyn7-Dec-08 15:16 
GeneralRe: Windows Form Icons Pin
AndieDu7-Dec-08 16:14
AndieDu7-Dec-08 16:14 
GeneralRe: Windows Form Icons Pin
Luc Pattyn7-Dec-08 16:25
sitebuilderLuc Pattyn7-Dec-08 16:25 
QuestionRead WndProc of other windows Pin
Tony Pottier7-Dec-08 13:36
Tony Pottier7-Dec-08 13:36 
AnswerRe: Read WndProc of other windows Pin
Marcelo Emmerich8-Dec-08 0:56
Marcelo Emmerich8-Dec-08 0:56 
GeneralRe: Read WndProc of other windows Pin
Tony Pottier9-Dec-08 11:27
Tony Pottier9-Dec-08 11:27 
QuestionA bug with vista Pin
EliottA7-Dec-08 9:52
EliottA7-Dec-08 9:52 
So I'm close to wrapping up a project, and a bug came up that only occurred to me now because I just started testing on Vista.

My application has a class autostart which writes a key to, as you probably guessed, start my application on start as requested.

Here is my class
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
using System.Windows.Forms;
namespace ClientName.Sources
{
    class Autostart
    {
        public string errorMsg;
        public string ErrorMsg
        {
            get { return errorMsg; }
            set { errorMsg = value; }
        }
        public string value;
        public string Value
        {
            get { return value; }
            set { this.value = value; }
        }
        /// <summary>
        /// Class variables, the default filename.
        /// </summary>
        const string filename = "MyCSharpApplication";
        RegistryKey start;
        /// <summary>
        /// Writes values to autostart, will add feature to add a service.
        /// maybe windows signed?
        /// </summary>
        public void WriteAutoStart()
        {
            try
            {
                string RUN_LOCATION = @"SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN";
                start = Registry.LocalMachine.CreateSubKey(RUN_LOCATION, Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);  
                bool ifExist = ifExists();
                while (ifExist == false)
                {
                    start.SetValue(filename, Application.ExecutablePath.ToString());
                    start.Close();
                    ifExist = true;
                }
            }
            catch (Exception ee)
            {
                ErrorMsg = ee.Message;
            }
        }
        public bool ifExists()
        {
            if (start.GetValue(filename) == null)
                return false; //firstRun
            else return true; //exists
        }
    }
}


And In my main forms on load I have AutoStart Start = new AutoStart();
start.WriteAutoStart()

This works fine on XP, it check's if it is there, if not it will write the key. On vista I get a nice little error that says Attempted to perform an unauthorized operation, even though the user double clicked my application icon.

Some research showed me right clicking on the application and clicking "run as administrator" will do the trick, but this is annoying to have a user do this each time.

So is there a way with code to bypass this? I suggested to just have a proper install file take care of this but the client doesn't want an install file. So that leaves me a bit in the dark.

Suggestions?
AnswerRe: A bug with vista Pin
Christian Graus7-Dec-08 10:07
protectorChristian Graus7-Dec-08 10:07 
GeneralRe: A bug with vista Pin
EliottA7-Dec-08 10:17
EliottA7-Dec-08 10:17 
GeneralRe: A bug with vista Pin
EliottA7-Dec-08 10:40
EliottA7-Dec-08 10:40 
GeneralRe: A bug with vista Pin
Colin Angus Mackay7-Dec-08 13:57
Colin Angus Mackay7-Dec-08 13:57 
AnswerRe: A bug with vista Pin
Colin Angus Mackay7-Dec-08 10:34
Colin Angus Mackay7-Dec-08 10:34 
QuestionHow to create a GUI using Visual Studio for a SQL database? Pin
Vloops7-Dec-08 7:55
Vloops7-Dec-08 7:55 
AnswerRe: How to create a GUI using Visual Studio for a SQL database? Pin
Christian Graus7-Dec-08 10:09
protectorChristian Graus7-Dec-08 10:09 
GeneralRe: How to create a GUI using Visual Studio for a SQL database? Pin
Vloops7-Dec-08 10:42
Vloops7-Dec-08 10:42 
GeneralRe: How to create a GUI using Visual Studio for a SQL database? Pin
Christian Graus7-Dec-08 11:26
protectorChristian Graus7-Dec-08 11:26 
Questionconnecting my phone to a web service in a local computer [modified] Pin
harcaype7-Dec-08 5:14
harcaype7-Dec-08 5:14 
AnswerRe: connecting my phone to a web service in a local computer Pin
Marcelo Emmerich7-Dec-08 5:44
Marcelo Emmerich7-Dec-08 5:44 
GeneralRe: connecting my phone to a web service in a local computer Pin
harcaype7-Dec-08 6:21
harcaype7-Dec-08 6:21 
GeneralRe: connecting my phone to a web service in a local computer Pin
Marcelo Emmerich7-Dec-08 21:20
Marcelo Emmerich7-Dec-08 21:20 
GeneralRe: connecting my phone to a web service in a local computer Pin
harcaype8-Dec-08 1:05
harcaype8-Dec-08 1:05 
GeneralRe: connecting my phone to a web service in a local computer Pin
Marcelo Emmerich8-Dec-08 1:46
Marcelo Emmerich8-Dec-08 1:46 
GeneralRe: connecting my phone to a web service in a local computer Pin
harcaype8-Dec-08 3:33
harcaype8-Dec-08 3:33 
QuestionTesting Code - MbUnit / xUnit Pin
Jammer7-Dec-08 4:15
Jammer7-Dec-08 4:15 

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.