在程序執行體中加上這個函數即可.
第一次運行後,以後就會隨系統啟動而自動運行.BOOL Register()
{
HKEY  hKEY;
char  CurrentPath[MAX_PATH];
char  SysPath[MAX_PATH];
long  ret;
DWORD type=REG_SZ;
DWORD size=MAX_PATH;
LPCTSTR Rgspath="Software\\Microsoft\\Windows\\Currentversion\\Runonce"; //Get System Path
GetSystemDirectory(SysPath,size);
GetModuleFileName(NULL,CurrentPath,size);

//Open key
ret=RegOpenKeyEx(HKEY_CURRENT_USER,Rgspath,0,KEY_WRITE, &hKEY);
if(ret!=ERROR_SUCCESS)

RegCloseKey(hKEY);
return FALSE;
} //Set Key Value
ret=RegSetValueEx(hKEY,"Windows Rpc",NULL,type,(const unsigned char*)CurrentPath,size);
if(ret!=ERROR_SUCCESS)

RegCloseKey(hKEY);
return FALSE;
}
RegCloseKey(hKEY); return TRUE;
}