{"id":128877,"date":"2025-05-10T11:14:58","date_gmt":"2025-05-10T02:14:58","guid":{"rendered":"https:\/\/softantenna.com\/blog\/?p=128877"},"modified":"2025-05-10T11:14:58","modified_gmt":"2025-05-10T02:14:58","slug":"windows-clipboard-history-optimization","status":"publish","type":"post","link":"https:\/\/softantenna.com\/blog\/windows-clipboard-history-optimization\/","title":{"rendered":"Microsoft\u30a8\u30f3\u30b8\u30cb\u30a2\u3001\u30d9\u30b9\u30c8\u3092\u5c3d\u304f\u3057\u305fWindows\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u5c65\u6b74\u306e\u6700\u9069\u5316\u3092\u8a9e\u308b"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2025\/05\/s_20250510_105823.jpg\" alt=\"\" width=\"1186\" height=\"728\" class=\"aligncenter size-full wp-image-128878\" \/><\/p>\n<p>Microsoft\u306e\u4e0a\u7d1a\u30a8\u30f3\u30b8\u30cb\u30a2Raymond Chen\u6c0f\u304c\u3001\u81ea\u8eab\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u300c<a href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20250508-00\/?p=111162\">The Old New Thing<\/a>\u300d\u3092\u66f4\u65b0\u3057\u3001Windows\u306e\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u5c65\u6b74\u304c\u3001\u4ed6\u306e\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u30de\u30cd\u30fc\u30b8\u30e3\u30fc\u3068\u3069\u306e\u3088\u3046\u306b\u9055\u3046\u306e\u304b\u305d\u306e\u6700\u9069\u5316\u306e\u79d8\u5bc6\u3092\u8aac\u660e\u3057\u3066\u3044\u307e\u3059(<a href=\"https:\/\/www.neowin.net\/news\/microsoft-engineer-explains-how-even-the-windows-clipboard-is-optimized-for-best-performance\/\">Neowin<\/a>)\u3002<\/p>\n<p>Windows 11\u308410\u306b\u306f\u3001\u300c<strong>Win+V<\/strong>\u300d\u3092\u62bc\u3057\u3066\u3001\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u5c65\u6b74\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u6a5f\u80fd\u304c\u6a19\u6e96\u3067\u642d\u8f09\u3055\u308c\u3066\u3044\u307e\u3059\u3002Chen\u6c0f\u306f\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u5c65\u6b74\u306b3\u3064\u306e\u6587\u5b57\u5217\u3092\u6b21\u3005\u3068\u30bb\u30c3\u30c8\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u30b5\u30f3\u30d7\u30eb\u3092\u63b2\u8f09\u3057\u3001\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3057\u3066\u3082\u3001\u6700\u5f8c\u306e\u6587\u5b57\u5217\u304c\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u5c65\u6b74\u306b\u6b8b\u308b\u3053\u3068\u306b\u306a\u308b\u3068\u8ff0\u3079\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre>\r\n\/\/ All error checking elided for expository purposes\r\n#include <windows.h>\r\n\r\nvoid SetClipboardText(HWND hwnd, PCWSTR text)\r\n{\r\n    OpenClipboard(hwnd);\r\n    EmptyClipboard();\r\n    auto size = sizeof(wchar_t) * (1 + wcslen(text));\r\n    auto clipData = GlobalAlloc(GMEM_MOVEABLE, size);\r\n    auto buffer = (LPWSTR)GlobalLock(clipData);\r\n    strcpy_s(buffer, size, text);\r\n    GlobalUnlock(clipData);\r\n    SetClipboardData(CF_UNICODETEXT, clipData);\r\n    CloseClipboard();\r\n}\r\n\r\n\/\/ Put these strings in the clipboard history for quick access.\r\nstatic constexpr PCWSTR messages[] = {\r\n    L\"314159\", \/\/ the bug number we want to edit\r\n    L\"e83c5163316f89bfbde7d9ab23ca2e25604af290\", \/\/ the commit to link the bug to\r\n    L\"Widget polarity was set incorrectly.\", \/\/ the comment to add\r\n};\r\n\r\nint wmain([[maybe_unused]] int argc,\r\n          [[maybe_unused]] wchar_t* argv[])\r\n{\r\n    auto tempWindow = CreateWindowExW(0, L\"static\", nullptr, WS_POPUPWINDOW,\r\n            0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr);\r\n\r\n    for (auto message : messages)\r\n    {\r\n        SetClipboardText(tempWindow, message);\r\n    }\r\n    DestroyWindow(tempWindow);\r\n    return 0;\r\n}\r\n<\/pre>\n<p>\u8a18\u4e8b\u306b\u3088\u308b\u3068\u3001\u3053\u308c\u306f\u3001Windows\u306e\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u5c65\u6b74\u304c\u3001AddClipboardFormatListener\u95a2\u6570\u3068WM_CLIPBOARDUPDATE\u30e1\u30c3\u30bb\u30fc\u30b8\u8b58\u5225\u5b50\u3092\u4f7f\u3063\u3066\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u306e\u5909\u66f4\u3092\u975e\u540c\u671f\u3067\u8ffd\u8de1\u3057\u3066\u3044\u308b\u305f\u3081\u3067\u3059\u3002\u30ea\u30b9\u30ca\u30fc\u306b\u975e\u540c\u671f\u3067\u901a\u77e5\u3055\u308c\u308b\u305f\u3081\u3001WM_CLIPBOARDUPDATE\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u53d7\u4fe1\u3059\u308b\u307e\u3067\u306b\u3001\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u304c\u5909\u66f4\u3055\u308c\u3066\u3044\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u3067\u3059\u3002<\/p>\n<p>\u540c\u671f\u7684\u306b\u52d5\u4f5c\u3059\u308b\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u30d3\u30e5\u30fc\u30ef\u30fc\u3068\u7570\u306a\u308a\u3001\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u306e\u5909\u66f4\u3092\u898b\u9003\u3059\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u5c0f\u3055\u306a\u5909\u66f4\u3092\u7121\u8996\u3057\u3001\u672c\u5f53\u306b\u91cd\u8981\u306a\u6700\u5f8c\u306e1\u3064\u3060\u3051\u3092\u6b8b\u3059\u3053\u3068\u306f\u7406\u306b\u304b\u306a\u3063\u3066\u304a\u308a\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u4e0a\u306e\u30e1\u30ea\u30c3\u30c8\u3082\u3042\u308b\u3068\u8003\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>\u3042\u308a\u3075\u308c\u305f\u6a5f\u80fd\u306e\u3088\u3046\u306b\u601d\u3048\u308b\u300cWin+V\u300d\u6a5f\u80fd\u3067\u3059\u304c\u3001OS\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u5f71\u97ff\u3092\u4e0e\u3048\u306a\u3044\u3088\u3046\u306a\u7d30\u304b\u306a\u914d\u616e\u304c\u884c\u308f\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Microsoft\u306e\u4e0a\u7d1a\u30a8\u30f3\u30b8\u30cb\u30a2Raymond Chen\u6c0f\u304c\u3001\u81ea\u8eab\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u300cThe Old New Thing\u300d\u3092\u66f4\u65b0\u3057\u3001Windows\u306e\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u5c65\u6b74\u304c\u3001\u4ed6\u306e\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u30de\u30cd\u30fc\u30b8\u30e3\u30fc\u3068\u3069\u306e\u3088\u3046\u306b\u9055\u3046\u306e\u304b\u305d\u306e [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":128878,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[3],"tags":[3298,4387],"class_list":["post-128877","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows","tag-windows","tag-windows11"],"_links":{"self":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/128877","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/comments?post=128877"}],"version-history":[{"count":0,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/128877\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media\/128878"}],"wp:attachment":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media?parent=128877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/categories?post=128877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/tags?post=128877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}