void CreateServiceCommand::updateServiceDescription() {
  //Another possbile approach is to call ChangeServiceConfig2 
  //that is only supported from WinXP/2003
  LOG.LogDebug(L"Updating service description");

  CString path = CreateFormatted(L"SYSTEM\\CurrentControlSet\\Services\\%s", mySettings->getServiceName());
  CRegKey reg(HKEY_LOCAL_MACHINE);
  if (ERROR_SUCCESS != reg.Open(reg, path, KEY_WRITE)) {
    LOG.LogWarnFormat(L"Failed to open registry key %s", path);
    return;
  }

  CString key = L"Description";
  if (ERROR_SUCCESS != reg.SetStringValue(key, mySettings->getServiceDescription())) {
    LOG.LogWarnFormat(L"Failed to set %s for %s", key, path);
    return;
  }

  reg.Flush();
  LOG.LogDebug(L"Service description is updated");
}
示例#2
0
int LSAUserCommand::executeCommand(LSA_HANDLE handle) {    
  CString accountName = CreateFormatted(L"%s", mySettings->getUserName());

  const DWORD sz = 2044;
  PSID sid = (PSID)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sz + 1);  
  TCHAR foundDomain[sz+1];
  DWORD psz = sz;
  DWORD pdz = sz;
  SID_NAME_USE use = SidTypeUser;

  LOG.LogDebug(L"Call LookupAccountName");
  if (0 == LookupAccountName(NULL, accountName, sid, &psz, foundDomain, &pdz, &use)) {
    LOG.LogErrorFormat(L"Failed to LookupAccountName. %s", LOG.GetLastError());
    return 1;
  }

  foundDomain[pdz] = L'\0';
  LOG.LogDebugFormat(L"LSA Policy opened: Domain %s", foundDomain);
  return executeCommand(handle, sid);
}