Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1580 lines
33 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. //
  3. // Wrappers of Win APIs
  4. //
  5. // 8-14-97 sburns
  6. #ifndef WIN_HPP_INCLUDED
  7. #define WIN_HPP_INCLUDED
  8. // Wrappers of Win32 APIs, doing such nice things as taking Strings
  9. // as parameters, asserting parameters and return values, assuming
  10. // certain parameters such as resource instance handles, and other
  11. // stuff.
  12. //
  13. // Each function name is identical to the API function it wraps.
  14. namespace Burnslib
  15. {
  16. namespace Win
  17. {
  18. // Win::Error is a subclass of ::Error that automatically maps
  19. // error codes to message strings, pulling the strings string from
  20. // various windows system resources.
  21. class Error : public ::Error
  22. {
  23. public:
  24. // Constructs a new instance.
  25. //
  26. // hr - The HRESULT to keep track of.
  27. //
  28. // summaryResID - ID of the string resource that corresponds to
  29. // the summary text to be returned by GetSummary().
  30. Error(HRESULT hr, int summaryResID);
  31. virtual
  32. ~Error()
  33. {
  34. }
  35. // Overrides the default windows message text.
  36. //
  37. // hr - The HRESULT to keep track of.
  38. //
  39. // message - The error message that will be returned by calls to
  40. // GetMessage.
  41. //
  42. // summary - the string that will be returned by calls to GetSummary
  43. Error(HRESULT hr, const String& message, const String& summary);
  44. HRESULT
  45. GetHresult() const;
  46. // Returns the HelpContext that will point the user to
  47. // assistance in deciphering the error message and details. For
  48. // this implementation, this is just the HRESULT parameter
  49. // passed to the ctor.
  50. virtual
  51. HelpContext
  52. GetHelpContext() const;
  53. // Returns the human readable error message from the system
  54. // error message string table(s).
  55. virtual
  56. String
  57. GetMessage() const;
  58. // returns a 1-line summary: The essence of the error, suitable
  59. // for use as the title of a reporting dialog, for instance.
  60. virtual
  61. String
  62. GetSummary() const;
  63. const Error& operator=(const Error& rhs);
  64. private:
  65. HRESULT hr;
  66. mutable String message;
  67. mutable String summary;
  68. int summaryResId;
  69. };
  70. // A CursorSetting is a convenient trick to change the cursor only
  71. // for the lifetime of a single code block. When an instance is
  72. // constructed, the cursor is changed. When it is destroyed, the
  73. // old cursor is restored.
  74. //
  75. // Example:
  76. //
  77. // { // open block scope
  78. // Win::CursorSetting scope(IDC_WAIT);
  79. // // the cursor is now IDC_WAIT
  80. //
  81. // // do something time consuming
  82. // } // close block scope
  83. // // scope destroyed; the cursor is restored to what it was before
  84. // NOTE: not threadsafe: do not use the same CursorSetting object from
  85. // multiple threads.
  86. class CursorSetting
  87. {
  88. public:
  89. // Construct a new instance with the named cursor resource.
  90. explicit
  91. CursorSetting(const String& newCursorName);
  92. // MAKEINTRESOURCE version
  93. explicit
  94. CursorSetting(
  95. const TCHAR* newCursorName,
  96. bool isSystemCursor = true);
  97. // Construct a new instance from a valid HCURSOR.
  98. explicit
  99. CursorSetting(HCURSOR newCursor);
  100. ~CursorSetting();
  101. private:
  102. HCURSOR oldCursor;
  103. void init(
  104. const TCHAR* cursorName,
  105. bool isSystemCursor = true);
  106. // these are not defined
  107. CursorSetting(const CursorSetting&);
  108. const CursorSetting& operator=(const CursorSetting&);
  109. };
  110. class WaitCursor : public CursorSetting
  111. {
  112. public:
  113. WaitCursor()
  114. :
  115. CursorSetting(IDC_WAIT)
  116. {
  117. }
  118. private:
  119. // these are not defined
  120. WaitCursor(const WaitCursor&);
  121. const WaitCursor& operator=(const WaitCursor&);
  122. };
  123. HRESULT
  124. AdjustTokenPrivileges(
  125. HANDLE tokenHandle,
  126. bool disableAllPrivileges,
  127. TOKEN_PRIVILEGES newState[],
  128. DWORD bufferLength,
  129. TOKEN_PRIVILEGES* previousState,
  130. DWORD* returnLength);
  131. HRESULT
  132. AllocateAndInitializeSid(
  133. SID_IDENTIFIER_AUTHORITY& authority,
  134. BYTE subAuthorityCount,
  135. DWORD subAuthority0,
  136. DWORD subAuthority1,
  137. DWORD subAuthority2,
  138. DWORD subAuthority3,
  139. DWORD subAuthority4,
  140. DWORD subAuthority5,
  141. DWORD subAuthority6,
  142. DWORD subAuthority7,
  143. PSID& sid);
  144. #undef Animate_Open
  145. void
  146. Animate_Open(HWND animation, const TCHAR* animationNameOrRes);
  147. #undef Animate_Stop
  148. void
  149. Animate_Stop(HWND animation);
  150. HRESULT
  151. AppendMenu(
  152. HMENU menu,
  153. UINT flags,
  154. UINT_PTR idNewItem,
  155. PCTSTR newItem);
  156. #undef Button_SetCheck
  157. void
  158. Button_SetCheck(HWND button, int checkState);
  159. #undef Button_GetCheck
  160. bool
  161. Button_GetCheck(HWND button);
  162. #undef Button_SetStyle
  163. void
  164. Button_SetStyle(HWND button, int style, bool redraw);
  165. void
  166. CheckDlgButton(HWND parentDialog, int buttonID, UINT buttonState);
  167. void
  168. CheckRadioButton(
  169. HWND parentDialog,
  170. int firstButtonInGroupID,
  171. int lastButtonInGroupID,
  172. int buttonInGroupToCheckID);
  173. // sets the handle to INVALID_HANDLE_VALUE
  174. void
  175. CloseHandle(HANDLE& handle);
  176. void
  177. CloseServiceHandle(SC_HANDLE handle);
  178. #undef ComboBox_AddString
  179. int
  180. ComboBox_AddString(HWND combo, const String& s);
  181. // Adds all of the strings in the range defined by the provided iterators
  182. // to the combo box control, and returns the 0-based index of the last
  183. // string added. Returns CB_ERR if an error occurred, or CB_ERRSPACE if
  184. // insufficient space is available to add the string.
  185. //
  186. // Each element is added in the sequence provided by the iterators. If an
  187. // error is encountered, the iteration stops, and the error value is
  188. // returned. In other words, remaining elements in the iteration are
  189. // skipped.
  190. //
  191. // Each element must be a String, or a type convertible to String (PWSTR,
  192. // etc.)
  193. //
  194. // combo - a HWND for a combo box.
  195. //
  196. // first - a forward iterator set to the first element in the sequence to
  197. // be added to the combo box.
  198. //
  199. // last - a forward iterator set to just beyond the last element of the
  200. // sequence.
  201. //
  202. // Example:
  203. //
  204. // StringList fooStrings;
  205. // fooStrings.push_back(L"hello");
  206. // fooStrings.push_back(L"world");
  207. //
  208. // int err =
  209. // Win::ComboBox_AddStrings(
  210. // combo,
  211. // fooStrings.begin(),
  212. // fooStrings.end());
  213. template<class ForwardIterator>
  214. int
  215. ComboBox_AddStrings(
  216. HWND combo,
  217. ForwardIterator first,
  218. ForwardIterator last)
  219. {
  220. ASSERT(Win::IsWindow(combo));
  221. int err = CB_ERR;
  222. for (
  223. // copy the iterators so as not to modify the actual parameters
  224. ForwardIterator f = first, l = last;
  225. f != l;
  226. ++f)
  227. {
  228. err = Win::ComboBox_AddString(combo, *f);
  229. if (err == CB_ERR || err == CB_ERRSPACE)
  230. {
  231. break;
  232. }
  233. }
  234. return err;
  235. }
  236. #undef ComboBox_GetCurSel
  237. int
  238. ComboBox_GetCurSel(HWND combo);
  239. // Retrieves the text of the selected item in the list box of the combo
  240. // or empty if no item is selected.
  241. String
  242. ComboBox_GetCurText(HWND combo);
  243. #undef ComboBox_GetLBText
  244. String
  245. ComboBox_GetLBText(HWND combo, int index);
  246. #undef ComboBox_GetLBTextLen
  247. int
  248. ComboBox_GetLBTextLen(HWND combo, int index);
  249. #undef ComboBox_SelectString
  250. int
  251. ComboBox_SelectString(HWND combo, const String& str);
  252. #undef ComboBox_SetCurSel
  253. void
  254. ComboBox_SetCurSel(HWND combo, int index);
  255. int
  256. CompareString(
  257. LCID locale,
  258. DWORD flags,
  259. const String& string1,
  260. const String& string2);
  261. HRESULT
  262. ConnectNamedPipe(
  263. HANDLE pipe,
  264. OVERLAPPED* overlapped);
  265. HRESULT
  266. ConvertSidToStringSid(PSID sid, String& result);
  267. HRESULT
  268. CopyFileEx(
  269. const String& existingFileName,
  270. const String& newFileName,
  271. LPPROGRESS_ROUTINE progressRoutine,
  272. void* progressParam,
  273. BOOL* cancelFlag,
  274. DWORD flags);
  275. HRESULT
  276. CopySid(DWORD destLength, PSID dest, PSID source);
  277. HRESULT
  278. CreateDialogParam(
  279. HINSTANCE hInstance,
  280. const TCHAR* templateName,
  281. HWND owner,
  282. DLGPROC dialogProc,
  283. LPARAM param,
  284. HWND& result);
  285. HRESULT
  286. CreateDirectory(const String& path);
  287. HRESULT
  288. CreateEvent(
  289. SECURITY_ATTRIBUTES* securityAttributes,
  290. bool manualReset,
  291. bool initiallySignaled,
  292. HANDLE& result);
  293. HRESULT
  294. CreateEvent(
  295. SECURITY_ATTRIBUTES* securityAttributes,
  296. bool manualReset,
  297. bool initiallySignaled,
  298. const String& name,
  299. HANDLE& result);
  300. HRESULT
  301. CreateFile(
  302. const String& fileName,
  303. DWORD desiredAccess,
  304. DWORD shareMode,
  305. SECURITY_ATTRIBUTES* securityAttributes,
  306. DWORD creationDistribution,
  307. DWORD flagsAndAttributes,
  308. HANDLE hTemplateFile,
  309. HANDLE& result);
  310. HRESULT
  311. CreateFontIndirect(
  312. const LOGFONT& logFont,
  313. HFONT& result);
  314. HRESULT
  315. CreateMailslot(
  316. const String& name,
  317. DWORD maxMessageSize,
  318. DWORD readTimeout,
  319. SECURITY_ATTRIBUTES* attributes,
  320. HANDLE& result);
  321. HRESULT
  322. CreateMutex(
  323. SECURITY_ATTRIBUTES* attributes,
  324. bool isInitialOwner,
  325. const String& name,
  326. HANDLE& result);
  327. HRESULT
  328. CreateNamedPipe(
  329. const String& name,
  330. DWORD openMode,
  331. DWORD pipeMode,
  332. DWORD maxInstances,
  333. DWORD outBufferSizeInBytes,
  334. DWORD inBufferSizeInBytes,
  335. DWORD defaultTimeout,
  336. SECURITY_ATTRIBUTES* sa,
  337. HANDLE& result);
  338. HRESULT
  339. CreatePopupMenu(HMENU& result);
  340. #undef CreateProcess
  341. HRESULT
  342. CreateProcess(
  343. String& commandLine,
  344. SECURITY_ATTRIBUTES* processAttributes,
  345. SECURITY_ATTRIBUTES* threadAttributes,
  346. bool inheritHandles,
  347. DWORD creationFlags,
  348. void* environment,
  349. const String& currentDirectory,
  350. STARTUPINFO& startupInformation,
  351. PROCESS_INFORMATION& processInformation);
  352. HRESULT
  353. CreatePropertySheetPage(
  354. const PROPSHEETPAGE& pageInfo,
  355. HPROPSHEETPAGE& result);
  356. HRESULT
  357. CreateSolidBrush(
  358. COLORREF color,
  359. HBRUSH& result);
  360. HRESULT
  361. CreateStreamOnHGlobal(
  362. HGLOBAL hglobal,
  363. bool deleteOnRelease,
  364. IStream*& result);
  365. HRESULT
  366. CreateWindowEx(
  367. DWORD exStyle,
  368. const String& className,
  369. const String& windowName,
  370. DWORD style,
  371. int x,
  372. int y,
  373. int width,
  374. int height,
  375. HWND parent,
  376. HMENU menuOrChildID,
  377. void* param,
  378. HWND& result);
  379. HRESULT
  380. DeleteFile(const String& path);
  381. // object is set to 0
  382. HRESULT
  383. DeleteObject(HGDIOBJ& object);
  384. HRESULT
  385. DeleteObject(HFONT& object);
  386. HRESULT
  387. DeleteObject(HBITMAP& object);
  388. // icon is set to 0
  389. HRESULT
  390. DestroyIcon(HICON& icon);
  391. // menu is set to 0
  392. HRESULT
  393. DestroyMenu(HMENU& menu);
  394. // page is set to 0
  395. HRESULT
  396. DestroyPropertySheetPage(HPROPSHEETPAGE& page);
  397. // window is set to 0
  398. HRESULT
  399. DestroyWindow(HWND& window);
  400. INT_PTR
  401. DialogBoxParam(
  402. HINSTANCE hInstance,
  403. const TCHAR* templateName,
  404. HWND owner,
  405. DLGPROC dialogProc,
  406. LPARAM param);
  407. HRESULT
  408. DisconnectNamedPipe(HANDLE pipe);
  409. HRESULT
  410. DrawFocusRect(HDC dc, const RECT& rect);
  411. // appends text to the contents of an edit control.
  412. //
  413. // editbox - HWND of the edit control
  414. //
  415. // text - text to append. Must not be empty.
  416. //
  417. // preserveSelection - true to keep any active selection, false to move
  418. // the care to the end of the appended text.
  419. //
  420. // canUndo - true to allow undo of the append, false if not.
  421. void
  422. Edit_AppendText(
  423. HWND editbox,
  424. const String& text,
  425. bool preserveSelection = true,
  426. bool canUndo = true);
  427. #undef Edit_GetSel
  428. void
  429. Edit_GetSel(HWND editbox, int& start, int& end);
  430. #undef Edit_LimitText
  431. void
  432. Edit_LimitText(HWND editbox, int limit);
  433. #undef Edit_ReplaceSel
  434. void
  435. Edit_ReplaceSel(HWND editbox, const String& newText, bool canUndo);
  436. #undef Edit_SetSel
  437. void
  438. Edit_SetSel(HWND editbox, int start, int end);
  439. bool
  440. EqualSid(PSID sid1, PSID sid2);
  441. void
  442. EnableWindow(HWND window, bool state);
  443. HRESULT
  444. EndDialog(HWND dialog, int result);
  445. #undef EnumUILanguages
  446. HRESULT
  447. EnumUILanguages(
  448. UILANGUAGE_ENUMPROCW proc,
  449. DWORD flags,
  450. LONG_PTR lParam);
  451. HRESULT
  452. ExitWindowsEx(UINT options);
  453. // expands strings in s, returns s on failure, expanded version on
  454. // success.
  455. String
  456. ExpandEnvironmentStrings(const String& s);
  457. HRESULT
  458. FindFirstFile(
  459. const String& fileName,
  460. WIN32_FIND_DATA& data,
  461. HANDLE& result);
  462. HRESULT
  463. FindClose(HANDLE& findHandle);
  464. HRESULT
  465. FindNextFile(HANDLE& findHandle, WIN32_FIND_DATA& data);
  466. HRESULT
  467. FlushFileBuffers(HANDLE handle);
  468. HRESULT
  469. FrameRect(HDC dc, const RECT& rect, HBRUSH brush);
  470. HRESULT
  471. FreeLibrary(HMODULE& module);
  472. void
  473. FreeSid(PSID sid);
  474. // used to free the result returned by Win::GetTokenInformation
  475. void
  476. FreeTokenInformation(TOKEN_USER* userInfo);
  477. HWND
  478. GetActiveWindow();
  479. // for Windows pre-defined classes.
  480. HRESULT
  481. GetClassInfoEx(const String& className, WNDCLASSEX& info);
  482. HRESULT
  483. GetClassInfoEx(
  484. HINSTANCE hInstance,
  485. const String& className,
  486. WNDCLASSEX& info);
  487. String
  488. GetClassName(HWND window);
  489. String
  490. GetClipboardFormatName(UINT format);
  491. HRESULT
  492. GetClientRect(HWND window, RECT& rect);
  493. HRESULT
  494. GetColorDepth(int& result);
  495. String
  496. GetCommandLine();
  497. // Inserts the command line arguments of the current process into the
  498. // provided list. The list is not cleared beforehand. The list is similar
  499. // to the traditional argv array. Returns the number of args inserted.
  500. //
  501. // Use instead of ::GetCommandLine, ::ComandLineToArgVW.
  502. //
  503. // BackInsertionSequence - any type that supports the construction of
  504. // a back_insert_iterator on itself, and has a value type that can be
  505. // constructed from an PWSTR.
  506. //
  507. // bii - a reference to a back_insert_iterator of the
  508. // BackInsertionSequence template parameter. The simplest way to make
  509. // one of these is to use the back_inserter helper function.
  510. //
  511. // Example:
  512. //
  513. // StringList container;
  514. // int argCount = Win::GetCommandLineArgs(std::back_inserter(container));
  515. //
  516. // StringVector container;
  517. // int argCount = Win::GetCommandLineArgs(std::back_inserter(container));
  518. template <class BackInsertableContainer>
  519. int
  520. GetCommandLineArgs(
  521. std::back_insert_iterator<BackInsertableContainer>& bii)
  522. {
  523. PWSTR* clArgs = 0;
  524. int argCount = 0;
  525. int retval = 0;
  526. clArgs =
  527. ::CommandLineToArgvW(Win::GetCommandLine().c_str(), &argCount);
  528. ASSERT(clArgs);
  529. if (clArgs)
  530. {
  531. for (retval = 0; retval < argCount; retval++)
  532. {
  533. // the container values can be any type that can be constructed
  534. // from PWSTR...
  535. //lint --e(*) lint does not grok back_insert_iterator
  536. *bii++ = clArgs[retval];
  537. }
  538. Win::LocalFree(clArgs);
  539. }
  540. ASSERT(argCount == retval);
  541. return retval;
  542. }
  543. // HRESULT
  544. // GetComputerNameEx(COMPUTER_NAME_FORMAT format, String& result);
  545. String
  546. GetComputerNameEx(COMPUTER_NAME_FORMAT format);
  547. HRESULT
  548. GetCurrentDirectory(String& result);
  549. HANDLE
  550. GetCurrentProcess();
  551. HRESULT
  552. GetCursorPos(POINT& result);
  553. HRESULT
  554. GetDC(HWND window, HDC& result);
  555. int
  556. GetDeviceCaps(HDC hdc, int index);
  557. HWND
  558. GetDesktopWindow();
  559. HRESULT
  560. GetDiskFreeSpaceEx(
  561. const String& path,
  562. ULARGE_INTEGER& available,
  563. ULARGE_INTEGER& total,
  564. ULARGE_INTEGER* free);
  565. HWND
  566. GetDlgItem(HWND parentDialog, int itemResID);
  567. String
  568. GetDlgItemText(HWND parentDialog, int itemResID);
  569. int
  570. GetDlgItemInt(HWND parentDialog, int itemResID, bool isSigned = false);
  571. UINT
  572. GetDriveType(const String& path);
  573. EncodedString
  574. GetEncodedDlgItemText(HWND parentDialog, int itemResID);
  575. String
  576. GetEnvironmentVariable(const String& name);
  577. HRESULT
  578. GetExitCodeProcess(HANDLE hProcess, DWORD& exitCode);
  579. HRESULT
  580. GetFileAttributes(const String& path, DWORD& result);
  581. HRESULT
  582. GetFileSizeEx(HANDLE handle, LARGE_INTEGER& result);
  583. DWORD
  584. GetFileType(HANDLE handle);
  585. // DWORD
  586. // GetLastError();
  587. HRESULT
  588. GetFullPathName(const String& path, String& result);
  589. HRESULT
  590. GetLastErrorAsHresult();
  591. void
  592. GetLocalTime(SYSTEMTIME& time);
  593. HRESULT
  594. GetLogicalDriveStrings(size_t bufChars, TCHAR* buf, DWORD& result);
  595. HRESULT
  596. GetMailslotInfo(
  597. HANDLE mailslot,
  598. DWORD* maxMessageSize,
  599. DWORD* nextMessageSize,
  600. DWORD* messageCount,
  601. DWORD* readTimeout);
  602. String
  603. GetModuleFileName(HMODULE hModule);
  604. // of this process exe
  605. HINSTANCE
  606. GetModuleHandle();
  607. HWND
  608. GetParent(HWND child);
  609. String
  610. GetPrivateProfileString(
  611. const String& section,
  612. const String& key,
  613. const String& defaultValue,
  614. const String& filename);
  615. HRESULT
  616. GetProcAddress(HMODULE module, const String& procName, FARPROC& result);
  617. HRESULT
  618. GetStringTypeEx(
  619. LCID localeId,
  620. DWORD infoTypeOptions,
  621. const String& sourceString,
  622. WORD* charTypeInfo);
  623. HRESULT
  624. GetSysColor(int element, DWORD& result);
  625. // returns %systemroot%\system32
  626. String
  627. GetSystemDirectory();
  628. void
  629. GetSystemInfo(SYSTEM_INFO& info);
  630. // returns %systemroot%, always (even under terminal server).
  631. String
  632. GetSystemWindowsDirectory();
  633. // // returns %systemroot%, always
  634. //
  635. // String
  636. // GetSystemRootDirectory();
  637. int
  638. GetSystemMetrics(int index);
  639. #undef GetTempPath
  640. HRESULT
  641. GetTempPath(String& result);
  642. HRESULT
  643. GetTextExtentPoint32(HDC hdc, const String& string, SIZE& size);
  644. HRESULT
  645. GetTextMetrics(HDC hdc, TEXTMETRIC& tm);
  646. // free the result with Win::FreeTokenInformation.
  647. //
  648. // allocates the result and returns it thru userInfo.
  649. HRESULT
  650. GetTokenInformation(HANDLE hToken, TOKEN_USER*& userInfo);
  651. // ... other varations of GetTokenInformation could be defined for
  652. // other infomation classes...
  653. // trims off leading and trailing whitespace
  654. String
  655. GetTrimmedDlgItemText(HWND parentDialog, int itemResID);
  656. // trims off leading and trailing whitespace
  657. String
  658. GetTrimmedWindowText(HWND window);
  659. HRESULT
  660. GetVersionEx(OSVERSIONINFO& info);
  661. HRESULT
  662. GetVersionEx(OSVERSIONINFOEX& info);
  663. HRESULT
  664. GetVolumeInformation(
  665. const String& volume,
  666. String* name,
  667. DWORD* serialNumber,
  668. DWORD* maxFilenameLength,
  669. DWORD* flags,
  670. String* fileSystemName);
  671. HRESULT
  672. GetWindowDC(HWND window, HDC& result);
  673. #undef GetWindowFont
  674. HFONT
  675. GetWindowFont(HWND window);
  676. HRESULT
  677. GetWindowPlacement(HWND window, WINDOWPLACEMENT& placement);
  678. HRESULT
  679. GetWindowRect(HWND window, RECT& rect);
  680. // returns %windir%, which may vary for terminal server users.
  681. String
  682. GetWindowsDirectory();
  683. #undef GetWindowLong
  684. HRESULT
  685. GetWindowLong(HWND window, int index, LONG& result);
  686. #undef GetWindowLongPtr
  687. HRESULT
  688. GetWindowLongPtr(HWND window, int index, LONG_PTR& result);
  689. String
  690. GetWindowText(HWND window);
  691. HRESULT
  692. GlobalAlloc(UINT flags, size_t bytes, HGLOBAL& result);
  693. HRESULT
  694. GlobalFree(HGLOBAL mem);
  695. HRESULT
  696. GlobalLock(HGLOBAL mem, PVOID& result);
  697. HRESULT
  698. GlobalUnlock(HGLOBAL mem);
  699. void
  700. HtmlHelp(
  701. HWND caller,
  702. const String& file,
  703. UINT command,
  704. DWORD_PTR data);
  705. #undef ImageList_Add
  706. int
  707. ImageList_Add(HIMAGELIST list, HBITMAP image, HBITMAP mask);
  708. #undef ImageList_AddIcon
  709. int
  710. ImageList_AddIcon(HIMAGELIST list, HICON icon);
  711. #undef ImageList_AddMasked
  712. int
  713. ImageList_AddMasked(HIMAGELIST list, HBITMAP bitmap, COLORREF mask);
  714. HIMAGELIST
  715. ImageList_Create(
  716. int pixelsx,
  717. int pixelsy,
  718. UINT flags,
  719. int initialSize,
  720. int reserve);
  721. HRESULT
  722. InitializeSecurityDescriptor(SECURITY_DESCRIPTOR& sd);
  723. LONG
  724. InterlockedDecrement(LONG& addend);
  725. LONG
  726. InterlockedIncrement(LONG& addend);
  727. bool
  728. IsDlgButtonChecked(HWND parentDialog, int buttonResID);
  729. // returns true if the name matches one of the local computer's names
  730. // (case insensitive)
  731. bool
  732. IsLocalComputer(const String& computerName);
  733. bool
  734. IsWindow(HWND candidate);
  735. bool
  736. IsWindowEnabled(HWND window);
  737. #undef ListBox_AddString
  738. int
  739. ListBox_AddString(HWND box, const String& s);
  740. #undef ListBox_SetItemData
  741. int
  742. ListBox_SetItemData(HWND box, int index, LPARAM value);
  743. #undef ListBox_GetItemData
  744. LPARAM
  745. ListBox_GetItemData(HWND box, int index);
  746. #undef ListBox_SetCurSel
  747. int
  748. ListBox_SetCurSel(HWND box, int index);
  749. #undef ListBox_GetCurSel
  750. int
  751. ListBox_GetCurSel(HWND box);
  752. #undef ListView_DeleteItem
  753. bool
  754. ListView_DeleteItem(HWND listview, int item);
  755. #undef ListView_GetItem
  756. bool
  757. ListView_GetItem(HWND listview, LVITEM& item);
  758. #undef ListView_GetItemCount
  759. int
  760. ListView_GetItemCount(HWND listview);
  761. #undef ListView_GetItemState
  762. UINT
  763. ListView_GetItemState(HWND listview, int index, UINT mask);
  764. #undef ListView_GetSelectedCount
  765. int
  766. ListView_GetSelectedCount(HWND listview);
  767. #undef ListView_GetSelectionMark
  768. int
  769. ListView_GetSelectionMark(HWND listview);
  770. #undef ListView_InsertColumn
  771. int
  772. ListView_InsertColumn(HWND listview, int index, const LVCOLUMN& column);
  773. #undef ListView_InsertItem
  774. int
  775. ListView_InsertItem(HWND listview, const LVITEM& item);
  776. #undef ListView_SetImageList
  777. HIMAGELIST
  778. ListView_SetImageList(HWND listview, HIMAGELIST images, int type);
  779. #undef ListView_SetItem
  780. void
  781. ListView_SetItem(HWND listview, const LVITEM& item);
  782. #undef ListView_SetItemText
  783. void
  784. ListView_SetItemText(
  785. HWND listview,
  786. int item,
  787. int subItem,
  788. const String& text);
  789. HRESULT
  790. LoadBitmap(unsigned resId, HBITMAP& result);
  791. HRESULT
  792. LoadCursor(const String& cursorName, HCURSOR& result);
  793. // provided for MAKEINTRESOURCE versions of cursorName
  794. HRESULT
  795. LoadCursor(
  796. const TCHAR* cursorName,
  797. HCURSOR& result,
  798. bool isSystemCursor = true);
  799. HRESULT
  800. LoadIcon(int resID, HICON& result);
  801. HRESULT
  802. LoadImage(unsigned resID, unsigned type, HANDLE& result);
  803. HRESULT
  804. LoadImage(unsigned resID, HICON& result);
  805. HRESULT
  806. LoadImage(unsigned resID, HBITMAP& result);
  807. HRESULT
  808. LoadLibrary(const String& libFileName, HINSTANCE& result);
  809. HRESULT
  810. LoadLibraryEx(const String& libFileName, DWORD flags, HINSTANCE& result);
  811. HRESULT
  812. LoadMenu(unsigned resID, HMENU& result);
  813. // Loads from the module indicated by GetResourceModuleHandle()
  814. String
  815. LoadString(unsigned resID);
  816. String
  817. LoadString(unsigned resID, HINSTANCE hInstance);
  818. HRESULT
  819. LocalFree(HLOCAL mem);
  820. HRESULT
  821. LookupAccountSid(
  822. const String& machineName,
  823. PSID sid,
  824. String& accountName,
  825. String& domainName);
  826. #undef LookupPrivilegeValue
  827. HRESULT
  828. LookupPrivilegeValue(
  829. const TCHAR* systemName,
  830. const TCHAR* privName,
  831. LUID& luid);
  832. HRESULT
  833. MapWindowPoints(
  834. HWND from,
  835. HWND to,
  836. RECT& rect,
  837. int* dh = 0, // number of pixels added to horizontal coord
  838. int* dv = 0); // number of pixels added to vertical coord
  839. int
  840. MessageBox(
  841. HWND owner,
  842. const String& text,
  843. const String& title,
  844. UINT flags);
  845. HRESULT
  846. MoveFileEx(
  847. const String& srcPath,
  848. const String& dstPath,
  849. DWORD flags);
  850. HRESULT
  851. MoveWindow(
  852. HWND window,
  853. int x,
  854. int y,
  855. int width,
  856. int height,
  857. bool shouldRepaint);
  858. HRESULT
  859. OpenProcessToken(
  860. HANDLE processHandle,
  861. DWORD desiredAccess,
  862. HANDLE& tokenHandle);
  863. HRESULT
  864. OpenSCManager(
  865. const String& machine,
  866. DWORD desiredAccess,
  867. SC_HANDLE& result);
  868. HRESULT
  869. OpenService(
  870. SC_HANDLE managerHandle,
  871. const String& serviceName,
  872. DWORD desiredAccess,
  873. SC_HANDLE& result);
  874. void
  875. OutputDebugString(const String& string);
  876. HRESULT
  877. PeekNamedPipe(
  878. HANDLE pipe,
  879. void* buffer,
  880. DWORD bufferSize,
  881. DWORD* bytesRead,
  882. DWORD* bytesAvailable,
  883. DWORD* bytesRemainingThisMessage);
  884. HRESULT
  885. PostMessage(HWND window, UINT msg, WPARAM wParam, LPARAM lParam);
  886. HRESULT
  887. PropertySheet(PROPSHEETHEADER* header, INT_PTR& result);
  888. #undef PropSheet_Changed
  889. void
  890. PropSheet_Changed(HWND propSheet, HWND page);
  891. #undef PropSheet_Unchanged
  892. void
  893. PropSheet_Unchanged(HWND propSheet, HWND page);
  894. #undef PropSheet_RebootSystem
  895. void
  896. PropSheet_RebootSystem(HWND propSheet);
  897. #undef PropSheet_SetTitle
  898. void
  899. PropSheet_SetTitle(
  900. HWND propSheet,
  901. DWORD style,
  902. const String& title);
  903. #undef PropSheet_SetWizButtons
  904. void
  905. PropSheet_SetWizButtons(HWND propSheet, DWORD buttonFlags);
  906. HRESULT
  907. QueryServiceStatus(
  908. SC_HANDLE handle,
  909. SERVICE_STATUS& status);
  910. HRESULT
  911. ReadFile(
  912. HANDLE file,
  913. void* buffer,
  914. DWORD bytesToRead,
  915. DWORD& bytesRead,
  916. OVERLAPPED* overlapped);
  917. void
  918. ReleaseStgMedium(STGMEDIUM& medium);
  919. HRESULT
  920. RegCloseKey(HKEY hKey);
  921. HRESULT
  922. RegConnectRegistry(
  923. const String& machine,
  924. HKEY hKey,
  925. HKEY& result);
  926. HRESULT
  927. RegCreateKeyEx(
  928. HKEY hKey,
  929. const String& subkeyName,
  930. DWORD options,
  931. REGSAM access,
  932. SECURITY_ATTRIBUTES* securityAttrs,
  933. HKEY& result,
  934. DWORD* disposition);
  935. HRESULT
  936. RegDeleteValue(
  937. HKEY hKey,
  938. const String& valueName);
  939. HRESULT
  940. RegOpenKeyEx(
  941. HKEY hKey,
  942. const String& subKey,
  943. REGSAM accessDesired,
  944. HKEY& result);
  945. HRESULT
  946. RegQueryValueEx(
  947. HKEY hKey,
  948. const String& valueName,
  949. DWORD* type,
  950. BYTE* data,
  951. DWORD* dataSize);
  952. HRESULT
  953. RegSetValueEx(
  954. HKEY hKey,
  955. const String& valueName,
  956. DWORD type,
  957. const BYTE* data,
  958. size_t dataSize);
  959. HRESULT
  960. RegisterClassEx(const WNDCLASSEX& wndclass, ATOM& result);
  961. CLIPFORMAT
  962. RegisterClipboardFormat(const String& name);
  963. void
  964. ReleaseDC(HWND window, HDC dc);
  965. HRESULT
  966. ReleaseMutex(HANDLE mutex);
  967. HRESULT
  968. RemoveDirectory(const String& path);
  969. inline
  970. HRESULT
  971. RemoveFolder(const String& path)
  972. {
  973. return Win::RemoveDirectory(path);
  974. }
  975. HRESULT
  976. ResetEvent(HANDLE event);
  977. HRESULT
  978. ScreenToClient(HWND window, POINT& point);
  979. HRESULT
  980. ScreenToClient(HWND window, RECT& rect);
  981. HGDIOBJ
  982. SelectObject(HDC hdc, HGDIOBJ hobject);
  983. LRESULT
  984. SendMessage(HWND window, UINT msg, WPARAM wParam, LPARAM lParam);
  985. HRESULT
  986. SetComputerNameEx(COMPUTER_NAME_FORMAT format, const String& newName);
  987. HCURSOR
  988. SetCursor(HCURSOR newCursor);
  989. HRESULT
  990. SetDlgItemText(
  991. HWND parentDialog,
  992. int itemResID,
  993. const String& text);
  994. inline
  995. HRESULT
  996. SetDlgItemText(
  997. HWND parentDialog,
  998. int itemResID,
  999. int textResID)
  1000. {
  1001. return
  1002. Win::SetDlgItemText(
  1003. parentDialog,
  1004. itemResID,
  1005. String::load(textResID));
  1006. }
  1007. HRESULT
  1008. SetDlgItemText(
  1009. HWND parentDialog,
  1010. int itemResID,
  1011. const EncodedString& cypherText);
  1012. HRESULT
  1013. SetEvent(HANDLE event);
  1014. HRESULT
  1015. SetFilePointerEx(
  1016. HANDLE handle,
  1017. const LARGE_INTEGER& distanceToMove,
  1018. LARGE_INTEGER* newPosition,
  1019. DWORD moveMethod);
  1020. HWND
  1021. SetFocus(HWND window);
  1022. bool
  1023. SetForegroundWindow(HWND window);
  1024. HRESULT
  1025. SetSecurityDescriptorDacl(
  1026. SECURITY_DESCRIPTOR& sd,
  1027. bool daclPresent,
  1028. ACL* dacl, // ptr not ref to allow null dacl
  1029. bool daclDefaulted);
  1030. #undef SetWindowFont
  1031. void
  1032. SetWindowFont(HWND window, HFONT font, bool redraw);
  1033. #undef SetWindowLong
  1034. HRESULT
  1035. SetWindowLong(
  1036. HWND window,
  1037. int index,
  1038. LONG value,
  1039. LONG* oldValue = 0);
  1040. #undef SetWindowLongPtr
  1041. HRESULT
  1042. SetWindowLongPtr(
  1043. HWND window,
  1044. int index,
  1045. LONG_PTR value,
  1046. LONG_PTR* oldValue = 0);
  1047. HRESULT
  1048. SetWindowPos(
  1049. HWND window,
  1050. HWND insertAfter,
  1051. int x,
  1052. int y,
  1053. int width,
  1054. int height,
  1055. UINT flags);
  1056. HRESULT
  1057. SetWindowText(HWND window, const String& text);
  1058. LPITEMIDLIST
  1059. SHBrowseForFolder(BROWSEINFO& bi);
  1060. HRESULT
  1061. SHGetMalloc(LPMALLOC& pMalloc);
  1062. String
  1063. SHGetPathFromIDList(LPCITEMIDLIST pidl);
  1064. HRESULT
  1065. SHGetSpecialFolderLocation(
  1066. HWND hwndOwner,
  1067. int nFolder,
  1068. LPITEMIDLIST& pidl);
  1069. void
  1070. ShowWindow(HWND window, int swOption);
  1071. // 'Spin' is a synonym for 'Up-Down' control
  1072. void
  1073. Spin_GetRange(HWND spinControl, int* low, int* high);
  1074. void
  1075. Spin_SetRange(HWND spinControl, int low, int high);
  1076. int
  1077. Spin_GetPosition(HWND spinControl);
  1078. void
  1079. Spin_SetPosition(HWND spinControl, int position);
  1080. #undef Static_SetIcon
  1081. void
  1082. Static_SetIcon(HWND staticText, HICON icon);
  1083. String
  1084. StringFromCLSID(const CLSID& clsID);
  1085. // inline synonym
  1086. inline
  1087. String
  1088. CLSIDToString(const CLSID& clsID)
  1089. {
  1090. return StringFromCLSID(clsID);
  1091. }
  1092. String
  1093. StringFromGUID2(const GUID& guid);
  1094. // inline synonym
  1095. inline
  1096. String
  1097. GUIDToString(const GUID& guid)
  1098. {
  1099. return StringFromGUID2(guid);
  1100. }
  1101. HRESULT
  1102. SystemParametersInfo(
  1103. UINT action,
  1104. UINT param,
  1105. void* vParam,
  1106. UINT WinIni);
  1107. HRESULT
  1108. TlsAlloc(DWORD& result);
  1109. HRESULT
  1110. TlsFree(DWORD index);
  1111. HRESULT
  1112. TlsSetValue(DWORD index, PVOID value);
  1113. HRESULT
  1114. TlsGetValue(DWORD index, PVOID& result);
  1115. HRESULT
  1116. UpdateWindow(HWND winder);
  1117. bool
  1118. ToolTip_AddTool(HWND toolTip, TOOLINFO& info);
  1119. bool
  1120. ToolTip_GetToolInfo(HWND toolTip, TOOLINFO& info);
  1121. bool
  1122. ToolTip_SetTitle(HWND toolTip, int icon, const String& title);
  1123. void
  1124. ToolTip_TrackActivate(HWND toolTip, bool activate, TOOLINFO& info);
  1125. void
  1126. ToolTip_TrackPosition(HWND toolTip, int xPos, int yPos);
  1127. HRESULT
  1128. UnregisterClass(const String& classname, HINSTANCE module);
  1129. HRESULT
  1130. WaitForSingleObject(
  1131. HANDLE object,
  1132. unsigned timeoutMillis,
  1133. DWORD& result);
  1134. HRESULT
  1135. WideCharToMultiByte(
  1136. DWORD flags,
  1137. const String& string,
  1138. char* buffer,
  1139. size_t bufferSize,
  1140. size_t& result);
  1141. HRESULT
  1142. WinHelp(
  1143. HWND window,
  1144. const String& helpFileName,
  1145. UINT command,
  1146. ULONG_PTR data);
  1147. HRESULT
  1148. WriteFile(
  1149. HANDLE handle,
  1150. const void* buffer,
  1151. DWORD numberOfBytesToWrite,
  1152. DWORD* numberOfBytesWritten);
  1153. HRESULT
  1154. WritePrivateProfileString(
  1155. const String& section,
  1156. const String& key,
  1157. const String& value,
  1158. const String& filename);
  1159. }
  1160. } // namespace Burnslib
  1161. #endif // WIN_HPP_INCLUDED