bAutoExec : 등록할건지 해제할건지
lpValueName : 등록이름
lpExeFileName : 시작프로그램으로 등록할 파일의 전체경로

bool CUtility::SetRegistStartUp(bool bAutoExec, LPTSTR lpValueName, LPTSTR lpExeFileName)
 {
  HKEY hKey;
  LONG lResult;
  if(bAutoExec)
  {
   if(lpValueName == NULL || lpExeFileName == NULL)
    return false;

   if(RegOpenKeyEx(
    HKEY_LOCAL_MACHINE,
    "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
    0L,
    KEY_WRITE,
    &hKey
    ) != ERROR_SUCCESS)
    return false;

   lResult = RegSetValueEx(
    hKey,
     lpValueName,
     0,
     REG_SZ,
     (BYTE*)lpExeFileName,
     lstrlen(lpExeFileName));

   RegCloseKey(hKey);

   if(lResult != ERROR_SUCCESS)
    return false;
  }
  else
  {
   if(RegOpenKeyEx(
    HKEY_LOCAL_MACHINE,
    "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
    0L,
    KEY_ALL_ACCESS,
    &hKey) != ERROR_SUCCESS)
    return false;

   lResult = RegDeleteValue(hKey, lpValueName);
   RegCloseKey(hKey);

   if(lResult != ERROR_SUCCESS)
    return false;
  }

  return true;
 }

Posted by 명혀니
,