Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/141.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ c++;跨平台后台任务_C++_Linux_C++11_Windows Services_Cross Platform - Fatal编程技术网

C++ c++;跨平台后台任务

C++ c++;跨平台后台任务,c++,linux,c++11,windows-services,cross-platform,C++,Linux,C++11,Windows Services,Cross Platform,我试图弄清楚如何开发一个跨平台的程序,该程序将在后台运行,并在系统启动后运行 我只想介绍windows和Linux。我知道没有线程,只有进程。 所以在Linux中,我需要在Windows中创建守护程序或服务 我知道它们是如何以逻辑的方式工作的,但我不知道如何编写 我会感激能得到的一切帮助。 谢谢 您只需在系统启动后运行程序即可。它与线程和其他东西无关 将特定于操作系统的内容包装到 #if defined _WIN32 #include <windows.h> int

我试图弄清楚如何开发一个跨平台的程序,该程序将在后台运行,并在系统启动后运行

我只想介绍windows和Linux。我知道没有线程,只有进程。 所以在Linux中,我需要在Windows中创建守护程序或服务

我知道它们是如何以逻辑的方式工作的,但我不知道如何编写

我会感激能得到的一切帮助。
谢谢

您只需在系统启动后运行程序即可。它与线程和其他东西无关

将特定于操作系统的内容包装到

#if defined _WIN32
    #include <windows.h>
    int ret = ShellExecute(hwnd, "runas", "see link below for windows", NULL, "c:\\windows\\system", SW_SHOWNORMAL );
#elif defined __linux__
     int ret = system("see link for linux");
#else
     #error Err
#endif
#如果已定义"WIN32
#包括
int ret=ShellExecute(hwnd,“runas”,“请参阅下面的windows链接”,NULL,“c:\\windows\\system”,SW\u SHOWNORMAL);
#elif已定义uu linux__
int ret=system(“参见linux的链接”);
#否则
#错误
#恩迪夫
链接

链接-对于linux案例,您需要调用几个命令来创建启动脚本并将它们添加到chkconfig

您是否尝试询问Google?总结Linux的步骤。我相信Windows也有类似的答案。