none
excessive use comctl32.dll with .net framework 4.x under win10 RRS feed

  • Question

  • With processmonitor we traced a winforms application using comctl32.dll. Under Win7 with Framework 4.x the application starts fast an there is a normal using of comctl32.dll. Unter win10 with framework 4.x the same applikation start two oder three times slower. Reason is the excessive use comctl32.dll, which we see with the processmonitor.

    Problem seems the function in Framework 4.x with win10 GetModuleHandle("comctl32.dll")

    Details:
    https://stackoverflow.com/questions/39673069/windows-10-exessive-use-of-comctl32-dll-in-net-4-0-and-up

    Wednesday, September 5, 2018 1:17 PM

All replies

  • Hi cheidler,

    Thank you for posting here.

    For your question, have you check the suggestions in the the same thread in StackOverFlow? I guess, it caused by the different System composition of Win10 and Win7. I need more information to do the test. Could you provide the details which could reproduce the scenario.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 17, 2018 3:17 AM
    Moderator
  • Hi Wendy,

    Create a Windows Forms project with .NET Framework 4 or above. Add a button to the Main Form. Call this in Button_Click:

            private void button_Click(object sender, EventArgs e)
            {
                Controls.Add(new Control());
            }
    

    Start Process Monitor and add a filter:

    Path ends with \comctl32.dll then Include

    Run the project and click your Button. With every click you would see 3 new entries in Process monitor:

    CreateFile
    QueryBasicInformationFile
    CloseFile
    
    Now if you run this on Windows 7 OR change Framework to .NET 2, there will be no file operations on comctl32.dll.

    As stated on StackOverflow, the cause is the API function GetModuleHandle. This function gets called in System.Windows.Forms.Control.CreateParams in .NET 4 but not in .NET 2. And obviously the GetModuleHandle produces these file operations only under Windows 10, not under Windows 7.

    You can verify this calling GetModuleHandle directly instead of creating new controls:

            [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
            public static extern IntPtr GetModuleHandle(string modName);
    
    
            private void button1_Click(object sender, EventArgs e)
            {
                MessageBox.Show(NativeMethods.GetModuleHandle("comctl32.dll").ToString());
            }
    

    Monday, September 24, 2018 7:51 AM