刚刚随便逛逛了下,看见了这个问题。现在一般是3种。1是弄一个快捷方式到计算机“开始”所有程序中的“启动”项。2是做出一个windows服务程序。3是操作注册表。我个人认为操作注册表要好点。很多应用程序应该都是操作注册表。对于像杀毒软件等必须随系统启动的是做出window服务。这里列个简单点的启动代码。有的网友的代码很多很完善。出学没有必要。我做了实例。贴代码如下(c++/cli)版:

void runstart()
    {  
   
     String ^strm=Application::ExecutablePath;
     if (!File::Exists(strm))
     {
      return;
     }
    
     String ^strnewName = strm->Substring(strm->LastIndexOf("\\") + 1);
     RegistryKey ^k=Registry::LocalMachine;
     RegistryKey ^RKey=k->OpenSubKey(L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
    if (RKey==nullptr)
      RKey = k->CreateSubKey(L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
    RKey->SetValue(strnewName,strm);
    m=m+1;
    if(m==1)
     MessageBox::Show("程序设置完成,重新启动计算机后即可生效!","提示", MessageBoxButtons::OK, MessageBoxIcon::Information);

在构造函数或者load事件中调用即可。

相关文章:

  • 2021-09-25
  • 2021-10-10
  • 2021-11-30
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-23
  • 2021-12-14
  • 2021-11-23
  • 2022-01-23
  • 2021-10-16
  • 2022-01-18
相关资源
相似解决方案