startup_information.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #include "base/macros.h"
  11. namespace base {
  12. namespace win {
  13. // Manages the lifetime of additional attributes in STARTUPINFOEX.
  14. class BASE_EXPORT StartupInformation {
  15. public:
  16. StartupInformation();
  17. ~StartupInformation();
  18. // Initialize the attribute list for the specified number of entries.
  19. bool InitializeProcThreadAttributeList(DWORD attribute_count);
  20. // Sets one entry in the initialized attribute list.
  21. // |value| needs to live at least as long as the StartupInformation object
  22. // this is called on.
  23. bool UpdateProcThreadAttribute(DWORD_PTR attribute, void* value, size_t size);
  24. LPSTARTUPINFOW startup_info() { return &startup_info_.StartupInfo; }
  25. LPSTARTUPINFOW startup_info() const {
  26. return const_cast<const LPSTARTUPINFOW>(&startup_info_.StartupInfo);
  27. }
  28. bool has_extended_startup_info() const {
  29. return !!startup_info_.lpAttributeList;
  30. }
  31. private:
  32. std::unique_ptr<char[]> attribute_list_;
  33. STARTUPINFOEXW startup_info_;
  34. DISALLOW_COPY_AND_ASSIGN(StartupInformation);
  35. };
  36. } // namespace win
  37. } // namespace base
  38. #endif // BASE_WIN_STARTUP_INFORMATION_H_