Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. API function

API function

Scheduled Pinned Locked Moved C / C++ / MFC
jsonquestion
19 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hi all, I wanna create a program that startup each time the pc started..which api i can used? :rolleyes:

    D T P 3 Replies Last reply
    0
    • A Anonymous

      Hi all, I wanna create a program that startup each time the pc started..which api i can used? :rolleyes:

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      See MSDN articles Q179365 and Q137367.


      "One must learn from the bite of the fire to leave it alone." - Native American Proverb

      1 Reply Last reply
      0
      • A Anonymous

        Hi all, I wanna create a program that startup each time the pc started..which api i can used? :rolleyes:

        T Offline
        T Offline
        Tim Zorn
        wrote on last edited by
        #3

        to have programs start when the computer starts up u need to edit the registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run or HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

        RaviBeeR 1 Reply Last reply
        0
        • T Tim Zorn

          to have programs start when the computer starts up u need to edit the registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run or HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

          RaviBeeR Offline
          RaviBeeR Offline
          RaviBee
          wrote on last edited by
          #4

          I thought these entries required the user to first login. I think one would have to go the service route (on supported Win OSs) in order to have an application start on boot up. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

          D 1 Reply Last reply
          0
          • RaviBeeR RaviBee

            I thought these entries required the user to first login. I think one would have to go the service route (on supported Win OSs) in order to have an application start on boot up. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Ravi Bhavnani wrote: I thought these entries required the user to first login. HKEY_CURRENT_USER would but HKEY_LOCAL_MACHINE exists even when no one is logged in. Ravi Bhavnani wrote: I think one would have to go the service route (on supported Win OSs) in order to have an application start on boot up. Not necessarily.


            "One must learn from the bite of the fire to leave it alone." - Native American Proverb

            RaviBeeR 1 Reply Last reply
            0
            • D David Crow

              Ravi Bhavnani wrote: I thought these entries required the user to first login. HKEY_CURRENT_USER would but HKEY_LOCAL_MACHINE exists even when no one is logged in. Ravi Bhavnani wrote: I think one would have to go the service route (on supported Win OSs) in order to have an application start on boot up. Not necessarily.


              "One must learn from the bite of the fire to leave it alone." - Native American Proverb

              RaviBeeR Offline
              RaviBeeR Offline
              RaviBee
              wrote on last edited by
              #6

              DavidCrow wrote: HKEY_LOCAL_MACHINE exists even when no one is logged in. True. But if I'm not mistaken, a "Run" entry in the HKEY_LOCAL_MACHINE subtree causes the application to start after any user logs in, as opposed to a corresponding entry for a specific user in the HKEY_USERS subtree which causes the app to only start when that user logs in. Regardless, the user has to first login. <aside> I believe this mechanism is used by installers that ask "Do you want to install this program for all users or just yourself?". </aside> /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

              D P 2 Replies Last reply
              0
              • RaviBeeR RaviBee

                DavidCrow wrote: HKEY_LOCAL_MACHINE exists even when no one is logged in. True. But if I'm not mistaken, a "Run" entry in the HKEY_LOCAL_MACHINE subtree causes the application to start after any user logs in, as opposed to a corresponding entry for a specific user in the HKEY_USERS subtree which causes the app to only start when that user logs in. Regardless, the user has to first login. <aside> I believe this mechanism is used by installers that ask "Do you want to install this program for all users or just yourself?". </aside> /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                Ravi Bhavnani wrote: But if I'm not mistaken, a "Run" entry in the HKEY_LOCAL_MACHINE subtree causes the application to start after any user logs in...Regardless, the user has to first login. Not so. I just verified this and without logging in to the machine, the applications in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run are indeed started. [edit] The jury is still out on this one. I'll keep looking... [/edit]


                "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                RaviBeeR 2 Replies Last reply
                0
                • D David Crow

                  Ravi Bhavnani wrote: But if I'm not mistaken, a "Run" entry in the HKEY_LOCAL_MACHINE subtree causes the application to start after any user logs in...Regardless, the user has to first login. Not so. I just verified this and without logging in to the machine, the applications in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run are indeed started. [edit] The jury is still out on this one. I'll keep looking... [/edit]


                  "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                  RaviBeeR Offline
                  RaviBeeR Offline
                  RaviBee
                  wrote on last edited by
                  #8

                  DavidCrow wrote: without logging in to the machine, the applications in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run are indeed started. That's amazing.  It seems to work exactly as I described on my Win XP Home SP1 box.  I confirmed this by adding a HKEY_LOCAL_MACHINE\... entry to this test app:

                  #include "stdafx.h"
                  #include "time.h"

                  int main(int argc, char* argv[])
                  {
                  time_t tmNow;
                  time (&tmNow);
                  char szFilespec [255];
                  sprintf (szFilespec, "C:\\%d.txt", tmNow);

                  FILE* fp = fopen (szFilespec, "w");
                  fclose (fp);
                  return 0;
                  }

                  and rebooting and logging in a few seconds later. As I expected, there was only one file (C:\1124224887.txt) created. This matches Microsoft's documentation[^] of these keys. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                  D 1 Reply Last reply
                  0
                  • D David Crow

                    Ravi Bhavnani wrote: But if I'm not mistaken, a "Run" entry in the HKEY_LOCAL_MACHINE subtree causes the application to start after any user logs in...Regardless, the user has to first login. Not so. I just verified this and without logging in to the machine, the applications in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run are indeed started. [edit] The jury is still out on this one. I'll keep looking... [/edit]


                    "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                    RaviBeeR Offline
                    RaviBeeR Offline
                    RaviBee
                    wrote on last edited by
                    #9

                    Did you mean RunServices instead of Run? /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                    D 1 Reply Last reply
                    0
                    • RaviBeeR RaviBee

                      DavidCrow wrote: without logging in to the machine, the applications in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run are indeed started. That's amazing.  It seems to work exactly as I described on my Win XP Home SP1 box.  I confirmed this by adding a HKEY_LOCAL_MACHINE\... entry to this test app:

                      #include "stdafx.h"
                      #include "time.h"

                      int main(int argc, char* argv[])
                      {
                      time_t tmNow;
                      time (&tmNow);
                      char szFilespec [255];
                      sprintf (szFilespec, "C:\\%d.txt", tmNow);

                      FILE* fp = fopen (szFilespec, "w");
                      fclose (fp);
                      return 0;
                      }

                      and rebooting and logging in a few seconds later. As I expected, there was only one file (C:\1124224887.txt) created. This matches Microsoft's documentation[^] of these keys. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #10

                      Ravi Bhavnani wrote: ...and rebooting and logging in a few seconds later. But the question is does your test application run if you don't log in?


                      "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                      RaviBeeR 1 Reply Last reply
                      0
                      • RaviBeeR RaviBee

                        Did you mean RunServices instead of Run? /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #11

                        Ravi Bhavnani wrote: Did you mean RunServices instead of Run? No.


                        "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                        1 Reply Last reply
                        0
                        • D David Crow

                          Ravi Bhavnani wrote: ...and rebooting and logging in a few seconds later. But the question is does your test application run if you don't log in?


                          "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                          RaviBeeR Offline
                          RaviBeeR Offline
                          RaviBee
                          wrote on last edited by
                          #12

                          DavidCrow wrote: does your test application run if you don't log in? No, because if it did, there would have been 2 files created - once when the system rebooted and once after I logged in. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                          T 1 Reply Last reply
                          0
                          • RaviBeeR RaviBee

                            DavidCrow wrote: HKEY_LOCAL_MACHINE exists even when no one is logged in. True. But if I'm not mistaken, a "Run" entry in the HKEY_LOCAL_MACHINE subtree causes the application to start after any user logs in, as opposed to a corresponding entry for a specific user in the HKEY_USERS subtree which causes the app to only start when that user logs in. Regardless, the user has to first login. <aside> I believe this mechanism is used by installers that ask "Do you want to install this program for all users or just yourself?". </aside> /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                            P Offline
                            P Offline
                            pablo_mag
                            wrote on last edited by
                            #13

                            Ravi Bhavnani wrote: But if I'm not mistaken, a "Run" entry in the HKEY_LOCAL_MACHINE subtree causes the application to start after any user logs in, as opposed to a corresponding entry for a specific user in the HKEY_USERS subtree which causes the app to only start when that user logs in. Regardless, the user has to first login. That's the way I've taken it to work, I always have to log in of HKLM\...\Run to take effect. One thing I suggest doing though, is use Winlogon Notification Packages (assuming you're programming for an NT-based version of windows), you can listen to startup/shutdown/login/logoff and other events. Check: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/winlogon\_notification\_packages.asp HTH

                            RaviBeeR 1 Reply Last reply
                            0
                            • P pablo_mag

                              Ravi Bhavnani wrote: But if I'm not mistaken, a "Run" entry in the HKEY_LOCAL_MACHINE subtree causes the application to start after any user logs in, as opposed to a corresponding entry for a specific user in the HKEY_USERS subtree which causes the app to only start when that user logs in. Regardless, the user has to first login. That's the way I've taken it to work, I always have to log in of HKLM\...\Run to take effect. One thing I suggest doing though, is use Winlogon Notification Packages (assuming you're programming for an NT-based version of windows), you can listen to startup/shutdown/login/logoff and other events. Check: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/winlogon\_notification\_packages.asp HTH

                              RaviBeeR Offline
                              RaviBeeR Offline
                              RaviBee
                              wrote on last edited by
                              #14

                              Thanks for the info, but you may want to post a reply to the original author of the thread. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                              P 1 Reply Last reply
                              0
                              • RaviBeeR RaviBee

                                Thanks for the info, but you may want to post a reply to the original author of the thread. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                                P Offline
                                P Offline
                                pablo_mag
                                wrote on last edited by
                                #15

                                Good point! :doh:

                                1 Reply Last reply
                                0
                                • A Anonymous

                                  Hi all, I wanna create a program that startup each time the pc started..which api i can used? :rolleyes:

                                  P Offline
                                  P Offline
                                  pablo_mag
                                  wrote on last edited by
                                  #16

                                  One thing I suggest doing, is use Winlogon Notification Packages (assuming you're programming for an NT-based version of windows), you can listen to startup/shutdown/login/logoff and other events. Check: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/winlogon\_notification\_packages.asp HTH

                                  1 Reply Last reply
                                  0
                                  • RaviBeeR RaviBee

                                    DavidCrow wrote: does your test application run if you don't log in? No, because if it did, there would have been 2 files created - once when the system rebooted and once after I logged in. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                                    T Offline
                                    T Offline
                                    Tim Zorn
                                    wrote on last edited by
                                    #17

                                    why would there have to be two? if its started on startup it wouldnt create another process of itself for the user logging in. would it?

                                    RaviBeeR 1 Reply Last reply
                                    0
                                    • T Tim Zorn

                                      why would there have to be two? if its started on startup it wouldnt create another process of itself for the user logging in. would it?

                                      RaviBeeR Offline
                                      RaviBeeR Offline
                                      RaviBee
                                      wrote on last edited by
                                      #18

                                      I booted the system at 2:30pm and logged in at 2:35pm. The file was timestamped 2:35pm. My point was, if the application ran on boot up, there would have been 2 files - one timestamped 2:30pm and the other 2:35pm. I also confirmed that the file is created every time I login. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                                      T 1 Reply Last reply
                                      0
                                      • RaviBeeR RaviBee

                                        I booted the system at 2:30pm and logged in at 2:35pm. The file was timestamped 2:35pm. My point was, if the application ran on boot up, there would have been 2 files - one timestamped 2:30pm and the other 2:35pm. I also confirmed that the file is created every time I login. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                                        T Offline
                                        T Offline
                                        Tim Zorn
                                        wrote on last edited by
                                        #19

                                        cool

                                        1 Reply Last reply
                                        0
                                        Reply
                                        • Reply as topic
                                        Log in to reply
                                        • Oldest to Newest
                                        • Newest to Oldest
                                        • Most Votes


                                        • Login

                                        • Don't have an account? Register

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • World
                                        • Users
                                        • Groups