startup_information.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_WIN_STARTUP_INFORMATION_H_
  5. #define BASE_WIN_STARTUP_INFORMATION_H_
  6. #include <windows.h>
  7. #include <stddef.h>
  8. #include <memory>
  9. #include "base/base_export.h"
  10. namespace base {
  11. namespace win {
  12. // Manages the lifetime of additional attributes in STARTUPINFOEX.
  13. class BASE_EXPORT StartupInformation {
  14. public:
  15. StartupInformation();
  16. StartupInformation(const StartupInformation&) = delete;
  17. StartupInformation& operator=(const StartupInformation&) = delete;
  18. ~StartupInformation();
  19. // Initialize the attribute list for the specified number of entries.
  20. bool InitializeProcThreadAttributeList(DWORD attribute_count);
  21. // Sets one entry in the initialized attribute list.
  22. // |value| needs to live at least as long as the StartupInformation object
  23. // this is called on.
  24. bool UpdateProcThreadAttribute(DWORD_PTR attribute, void* value, size_t size);
  25. LPSTARTUPINFOW startup_info() { return &startup_info_.StartupInfo; }
  26. LPSTARTUPINFOW startup_info() const {
  27. return const_cast<const LPSTARTUPINFOW>(&startup_info_.StartupInfo);
  28. }
  29. bool has_extended_startup_info() const {
  30. return !!startup_info_.lpAttributeList;
  31. }
  32. private:
  33. std::unique_ptr<char[]> attribute_list_;
  34. STARTUPINFOEXW startup_info_;
  35. };
  36. } // namespace win
  37. } // namespace base
  38. #endif // BASE_WIN_STARTUP_INFORMATION_H_