{"id":106727,"date":"2022-06-08T07:00:00","date_gmt":"2022-06-08T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=106727"},"modified":"2022-06-08T06:49:28","modified_gmt":"2022-06-08T13:49:28","slug":"20220608-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20220608-00\/?p=106727","title":{"rendered":"Is there a maximum size for Windows clipboard data? Because I&#8217;m getting null for something I know should be there"},"content":{"rendered":"<p>A customer had a program that opened a very large spreadsheet in Excel. Very large, like over 300,000 rows. They then selected all of the rows in the very large spreadsheet, copied those rows to the clipboard, and then ran a program that tried to extract the data. The program used the <code>Get\u00adClipboard\u00adData<\/code> function to retrieve the data in Rich Text Format. What they found was that the call to <code>Get\u00adClipboard\u00adData<\/code> was returning <code>NULL<\/code>. Is there a maximum size for clipboard data?<\/p>\n<p>No, there is no pre-set maximum size for clipboard data. You are limited only by available memory and address space.<\/p>\n<p>However, that&#8217;s not the reason why the call to <code>Get\u00adClipboard\u00adData<\/code> is failing.<\/p>\n<p>There are two ways to make clipboard data available. One is to put the data directly on the clipboard at the time you <a title=\"How ownership of the Windows clipboard is tracked in Win32\" href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20210526-00\/?p=105252\"> take ownership of it<\/a>. Another option is to declare that you have data of a particular type, but instead of putting the data on the clipboard, you say, &#8220;If anybody asks, let me know, and I&#8217;ll produce the data.&#8221; This is known as clipboard delay-rendering, and it is a common optimization for data formats that are rarely used or expensive to produce. If somebody asks for the format, the clipboard owner gets a <code>WM_<wbr \/>RENDER\u00adFORMAT<\/code> message to say, &#8220;Somebody wants that data, can you produce it now?&#8221;<\/p>\n<p>Excel does not operate natively in Rich Text Format. The Rich Text Format data that it places on the clipboard is delay-rendered. And then when another program asks for the Rich Text Format data, Excel says, &#8220;Oh yeah, just hang on a second, let me go get that for you.&#8221; Mind you, Rich Text Format is not the best format for a data table. As its name suggests, Rich Text Format is designed for text. It can represent basic tables, but that&#8217;s not its bread and butter.<\/p>\n<p>When the system asks a clipboard owner to render clipboard data, it sends the <code>WM_<wbr \/>RENDER\u00adFORMAT<\/code> message and waits up to 30 seconds for it to return. If the clipboard owner fails to produce the data within 30 seconds, then system abandons the request, and <code>Get\u00adClipboard\u00adData<\/code> returns <code>NULL<\/code>.<\/p>\n<p>What&#8217;s happening is that this table is so large that it&#8217;s taking Excel longer than 30 seconds to produce the Rich Text Format table. The <code>Get\u00adClipboard\u00adData<\/code> function times out and returns <code>NULL<\/code>.<\/p>\n<p>Next time, we&#8217;ll see what we can do to extend this timeout.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is no pre-set maximum size, but that null might be coming from somewhere else.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-106727","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>There is no pre-set maximum size, but that null might be coming from somewhere else.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/106727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=106727"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/106727\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=106727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=106727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=106727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}