如何把自己写的程序设置为开机自启动,用代码怎么实现,大家帮忙哦!

解决方案 »

  1.   

    如果是写服务的话,可以安装的时候选择自动启动,如果是MFC的话,也很简单直接用Windows的启动就可以了
      

  2.   

    写注册表启动项
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
      

  3.   


    #define STR_REGISTRYROOT      "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run "    if (RegCreateKey(HKEY_LOCAL_MACHINE, STR_REGISTRYROOT, &hk))
    AfxMessageBox(STR_COULDNOTCREATE,MB_OK,0);     // Set the name of the message file.     const char* s1;//your destination application path string    if (RegSetValueEx(hk,             // subkey handle 
                STR_REGISTRYONE,          // value name 
                0,                        // must be zero 
                REG_EXPAND_SZ,            // value type 
                (LPBYTE) s1,           // pointer to value data 
                strlen(s1) + 1))       // length of value data