Results 1 to 5 of 5

Thread: Loading at startup

  1. #1
    Guest

    Post

    I have a checkbox on my options dialog that says "Load at start-up", through code, how would i make it so my program would load at the start up of the computer?

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Put it in the Registry:
    Code:
    HKEY hRegistryKey;
    char *sBuffer;
    sBuffer = "C:\\pathofyourexe";
    RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\Currentversion\\run", 0, NULL, 0, KEY_WRITE, NULL, &hRegistryKey, NULL);
    RegSetValueEx(hRegistryKey, "PSL", 0, REG_SZ, (LPBYTE)sBuffer, strlen(sBuffer)+1);
    I am become death, the destroyer of worlds.
    mail:vlatkovr@hotmail.com

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Guest
    I know nothing about the registry, so is that the exact code to make the app start at the start up of the comp? And if it is, could you post the code to make it not start up at the start up of the comp, thanks.

  4. #4
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    To set the value from the registry use:
    Code:
    HKEY hRegistryKey;
    char *sBuffer;
    sBuffer = "C:\\pathofyourexe";
    RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\Currentversion\\run", 0, NULL, 0, KEY_WRITE, NULL, &hRegistryKey, NULL);
    //To set The value(load it on start up)
    RegSetValueEx(hRegistryKey, "SomeName", 0, REG_SZ, (LPBYTE)sBuffer, strlen(sBuffer)+1);
    To delete the value from the registry use:
    Code:
    //To delete the value(not load it at start up)
    RegDeleteValue(	hRegistryKey,"SomeName");
    I am become death, the destroyer of worlds.
    mail:vlatkovr@hotmail.com

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  5. #5
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    You can get the location of your exe in other ways:
    Code:
    char exepath[xx] = "\\nameofyourfile.exe";
    TCHAR buff[256];
    GetCurrentDirectory(256,buff);
    strcat(buff,pateka);
    //buff contains the path of your exe
    I am become death, the destroyer of worlds.
    mail:vlatkovr@hotmail.com

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

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