CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2005
    Posts
    7

    Wink Start when windows starts

    i have a check box but I dont know what to code to make my application start when my windows starts..thank you
    Come a little closer...
    I'll be good to you...

  2. #2
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    Re: Start when windows starts

    You've got several choices:

    1. Add you executable (or a shortcut to your executable) to the Start menus 'Startup' folder.

    2. Add the path of your executable to the registry under:
    Code:
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
     - or -
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
    3. If you want it to run only once (on the next startup) add the path of your executable to :
    Code:
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
     - or -
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
    - petter

  3. #3
    Join Date
    Apr 2001
    Location
    San Diego CA
    Posts
    378

    Re: Start when windows starts

    Put a link to your application in the Run of windows in registry or put a link to your applicaton executeable in the startup folder.

    Registry:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

    Startup:
    C:\Documents and Settings\<User>\Start Menu\Programs\Startup
    þ|êâšë rä†è rëþ|ïëš †hª† hë|þëd

  4. #4
    Join Date
    Sep 2005
    Posts
    7

    Question Re: Start when windows starts

    thank you but what should i code after user clicks the checkbox "check to start application when your windows stars" ????
    Come a little closer...
    I'll be good to you...

  5. #5
    Join Date
    Mar 2005
    Location
    Romania,Cluj-Napoca
    Posts
    1,073

    Re: Start when windows starts

    Quote Originally Posted by iodugioj
    thank you but what should i code after user clicks the checkbox "check to start application when your windows stars" ????
    add the BN_CLICKED message handler
    When your check box is clicked:
    Code:
    if(YourRadioButonControlMember.GetCheck()==BST_CHECKED){
    //open the registry
    if(::RegOpenKeyEx(HKEY_CURRENT_USER,
                      "Software\\Microsoft\\Windows\\CurrentVersion\\Run",
                      0,
                      KEY_SET_VALUE,
                      &hKey) == ERROR_SUCCESS)
    {
      char string[255];
     GetCurrentDirectory(255,string);
     strcat(string,"\\YourAppExe.exe"); //type your app *.exe
      // Set value
      if(::RegSetValueEx(hKey,
                         "YourAppName", //your app name
                         0,
                         REG_SZ,
                         reinterpret_cast<BYTE *>(&string),
    					 strlen(string)) == ERROR_SUCCESS)
      
        // Close key
        ::RegCloseKey(hKey);
    else
    AfxMessageBox("Not write in registry!");
        
      
    
    }
    else
    MessageBox("Not open the registry!");
    }
    Last edited by g_gili; September 6th, 2005 at 06:10 PM.
    Please use code tags [code] [/code]

    We would change the world, but God won't give us the sourcecode..
    Undocumented futures are fun and useful....
    ___
    ______
    Gili

  6. #6
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: Start when windows starts

    Quote Originally Posted by iodugioj
    thank you but what should i code after user clicks the checkbox "check to start application when your windows stars" ????
    Depends on your app design.
    In normal cases, if this is a part of a dialog box, the standard behavior is to apply this setting when you hit OK.
    In case of a property page, the standard behavior is to apply this when you hit OK or apply.

    In either case, what you could do is to trap BN_CLICKED and update a temprary variable. In the OK handler depending on the variable setting, either set the startup settings or clear it.
    If you hit cancel, you don't do anything.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured