ARGVMI~1.PIF on Nostr: So yeah, apparently the #Windows #Win32 function `CloseClipboard` doesn't actually ...
So yeah, apparently the #Windows #Win32 function `CloseClipboard` doesn't actually close the clipboard right away.
There is no guarantee that immediately calling `OpenClipboard` will succeed. Even on the same thread.
Which means mutex locking around `OpenClipboard`/`CloseClipboard` won't work. If there is contention, it'll still fail.
The docs say nothing about this.
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-closeclipboardFML.
A strategy of “mutex lock, then sleep-and-retry a few times” seems to suffice…
#programming
Published at
2026-06-04 20:25:16 UTCEvent JSON
{
"id": "cfb037c678861cfef773c7b1470514d60a34863b3a9a4319b2caa136f9e15f5b",
"pubkey": "e97cafa82a7dd144bb2ec1089abea1190be419346e906bf69f0bc243f01586fc",
"created_at": 1780604716,
"kind": 1,
"tags": [
[
"t",
"windows"
],
[
"t",
"win32"
],
[
"t",
"programming"
],
[
"proxy",
"https://mastodon.sdf.org/users/argv_minus_one/statuses/116693710706894530",
"activitypub"
],
[
"client",
"Mostr",
"31990:6be38f8c63df7dbf84db7ec4a6e6fbbd8d19dca3b980efad18585c46f04b26f9:mostr",
"wss://relay.ditto.pub"
]
],
"content": "So yeah, apparently the #Windows #Win32 function `CloseClipboard` doesn't actually close the clipboard right away.\n\nThere is no guarantee that immediately calling `OpenClipboard` will succeed. Even on the same thread.\n\nWhich means mutex locking around `OpenClipboard`/`CloseClipboard` won't work. If there is contention, it'll still fail.\n\nThe docs say nothing about this. https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-closeclipboard\n\nFML.\n\nA strategy of “mutex lock, then sleep-and-retry a few times” seems to suffice…\n\n#programming",
"sig": "617845d9c7b649da757458c363c32c7b8394146261149719dfcb479683fa385d8f6fb845f29142b20a919cf97a4bb26d154e57d96bddc2368464a48a1b7e5110"
}