{"id":34913,"date":"2005-07-18T10:00:16","date_gmt":"2005-07-18T10:00:16","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2005\/07\/18\/if-initcommoncontrols-doesnt-do-anything-why-do-you-have-to-call-it\/"},"modified":"2005-07-18T10:00:16","modified_gmt":"2005-07-18T10:00:16","slug":"if-initcommoncontrols-doesnt-do-anything-why-do-you-have-to-call-it","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20050718-16\/?p=34913","title":{"rendered":"If InitCommonControls doesn&#8217;t do anything, why do you have to call it?"},"content":{"rendered":"<p>One of the problems beginners run into when they start using shell common controls is that they forget to call <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/shellcc\/platform\/commctls\/common\/functions\/initcommoncontrols.asp\"> the <code>InitCommonControls<\/code> function<\/a>. But if you were to disassemble the <code>InitCommonControls<\/code> function itself, you&#8217;ll see that it, <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2003\/12\/08\/55954.aspx\"> like the <code>FlushInstructionCache<\/code> function<\/a>, doesn&#8217;t actually do anything.<\/p>\n<p> Then why do you need to call it? <\/p>\n<p> As with <code>FlushInstructionCache<\/code>, what&#8217;s important is not what it performs, but just the fact that you called it. <\/p>\n<p> Recall that merely listing a lib file in your dependencies doesn&#8217;t actually cause your program to be bound to the corresponding DLL. You have to call a function in that DLL in order for there to be an import entry for that DLL. And <code>InitCommonControls<\/code> is that function. <\/p>\n<p> Without the <code>InitCommonControls<\/code> function, a program that wants to use the shell common controls library would otherwise have no reference to COMCTL32.DLL in its import table. This means that when the program loads, COMCTL32.DLL is not loaded and therefore is not initialized. Which means that it doesn&#8217;t register its window classes. Which means that your call to <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/winui\/winui\/windowsuserinterface\/windowing\/windows\/windowreference\/windowfunctions\/createwindow.asp\"> the <code>CreateWindow<\/code> function<\/a> fails because the window class has not been registered. <\/p>\n<p> That&#8217;s why you have to call a function that does nothing. It&#8217;s for your own good. <\/p>\n<p> (Of course, there&#8217;s the new <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/shellcc\/platform\/commctls\/common\/functions\/initcommoncontrolsex.asp\"> <code>InitCommonControlsEx<\/code> function<\/a> that lets you specify which classes you would like to be registered. Only the classic Windows&nbsp;95 classes are registered when COMCTL32.DLL loads. For everything else you have to ask for it explicitly.) <\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the problems beginners run into when they start using shell common controls is that they forget to call the InitCommonControls function. But if you were to disassemble the InitCommonControls function itself, you&#8217;ll see that it, like the FlushInstructionCache function, doesn&#8217;t actually do anything. Then why do you need to call it? As with [&hellip;]<\/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":[2],"class_list":["post-34913","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-history"],"acf":[],"blog_post_summary":"<p>One of the problems beginners run into when they start using shell common controls is that they forget to call the InitCommonControls function. But if you were to disassemble the InitCommonControls function itself, you&#8217;ll see that it, like the FlushInstructionCache function, doesn&#8217;t actually do anything. Then why do you need to call it? As with [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/34913","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=34913"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/34913\/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=34913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=34913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=34913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}