Share via

Compile a keyboard layout with Visual Studio

François T 20 Reputation points
2026-02-23T12:36:26.8+00:00

Hello all,

I created a custom keyboard layout for my own usage. I edited the usual keyboard files (kbdxx.c, kbdxx.def, kbdxx.rc, kbdxx.h and sources) and added the others files (makefile and makefile.inc) based on WDK samples in a folder. I installed an old standalone version of Windows Driver Kits (https://download.microsoft.com/download/4/a/2/4a25c7d5-efbe-4182-b6a9-ae6850409a78/GRMWDK_EN_7600_1.ISO) and used the build command into the x64 Checked Build Environment console after locating it into my layout folder. It worked well and the produced layout dll is operational and well accepted by my Windows 11 OS. I therefore conclude that my files are OK.

To be honest, I wanted to use a more modern way. I tried too many times to do exactly the same thing through Visual Studio (2022 and even 2026 but given up due to the lack of helpful documentation), with the installed WDK module.

I added my keyboard files (kbdxx.c, kbdxx.def, kbdxx.rc, kbdxx.h) in my project, and saw that VS uploaded the Reference files (including kbd.h and winuser.h). I was then full of hope. I compiled but in vain.

I tried to uncheck the precompiled header option and to force "c" compilation. I also tried to add the 3 other files from the WDK (makefile, makefile.inc and my customed version of sources) to my project. Alas, even if a dll is produced, it never worked. Oddly, the dll produced this is quite bigger in size than the other one (18ko vs 10ko), don't know if it could help understanding the issue.

I'm not very used to Visual Studio, so I suspect I'm not setting it the right way up. Has anyone a step-by-step protocol to be sure to produce a clean dll for Windows x64 by using the kbdxx.c & co files?

Many thanks!

Windows development | Windows Driver Kit (WDK)
0 comments No comments
{count} votes

Answer accepted by question author
  1. Tom Tran (WICLOUD CORPORATION) 4,580 Reputation points Microsoft External Staff Moderator
    2026-02-24T11:12:34.6233333+00:00

    Hi @François T ,

    Based on what you described, your layout tables are likely correct. The key signal is that the same sources produce a working layout when built with the legacy WDK build.exe flow. In cases like this, the issue most often comes down to how the DLL is being produced in Visual Studio, rather than the table content itself.

    A keyboard layout DLL is not the same as a generic “New DLL Project” in Visual Studio. Microsoft provides dedicated keyboard layout samples that are preconfigured to generate the expected binary shape. The documentation specifically instructs opening kbd.sln under the WDK src\input\layout folder and building from there using Visual Studio or MSBuild ([Microsoft Learn][1]).

    Because of this, having KbdLayerDescriptor present in the source is necessary, but it does not by itself guarantee that the final DLL matches what Windows expects.


    Perhaps you could try these suggestions:

    1. Build a sample unchanged first Open the WDK keyboard layout sample solution:

    …\src\input\layout\kbd.sln
    

    Build one of the stock layouts (for example kbdus). This confirms your Visual Studio + WDK environment is producing a valid layout DLL.

    Reference: https://learn.microsoft.com/en-us/samples/microsoft/windows-driver-samples/keyboard-layout-samples/

    2. Verify the export table of your DLL

    After building your custom DLL, run:

    dumpbin /exports yourdll.dll
    

    You should see KbdLayerDescriptor exported. If it is missing or differs from the sample build, Windows may not activate the layout correctly.

    3. Check how your project was created

    If your current project started from a generic DLL template, Visual Studio could introduce default runtime behavior unless carefully configured. The most reliable approach is to clone or modify an existing WDK keyboard sample project rather than building from a blank DLL template.


    Also, if you are testing with Visual Studio 2026, try switching to Visual Studio 2022 for WDK work. Microsoft currently states that the WDK has not been validated with Visual Studio 2026 and recommends continuing with Visual Studio 2022.Reference: https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk#:~:text=Don%27t%20use%20Visual,supported%20by%20WDK.


    Hope this helps! If you have any questions, please feel free to comment. I'll be happy to assist!


1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2026-02-23T12:36:40.1566667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To compile a keyboard layout using Visual Studio, ensure that you have set up your project correctly. Here are some steps and considerations that may help you produce a functional DLL:

    1. Project Configuration: Make sure your project is configured to use the Windows Driver Kit (WDK). You should include the necessary headers and libraries that are part of the WDK in your project settings.
    2. Include Files: Ensure that your project includes all required header files, such as kbd.h and winuser.h. These files are essential for keyboard driver development.
    3. Precompiled Headers: If you are experiencing issues with precompiled headers, try disabling them in your project settings. This can sometimes resolve compilation issues.
    4. Makefile and Sources: If you are using makefile and makefile.inc, ensure that they are correctly referenced in your project. Visual Studio may not automatically handle these files as it would in a command-line build environment.
    5. Build Configuration: Check your build configuration (Debug/Release) and ensure that it matches the environment you are targeting (x64). Sometimes, mismatched configurations can lead to unexpected results.
    6. Output Size: The difference in DLL size might indicate that the compilation settings or included libraries differ between the command-line build and Visual Studio build. Compare the settings to identify discrepancies.
    7. Testing the DLL: After building the DLL, test it thoroughly to ensure that it behaves as expected in your Windows environment. If it fails to load or operate correctly, check the output logs for any errors or warnings that could provide insight into the issue.

    If you continue to face challenges, consider consulting the WDK documentation for specific guidelines on building keyboard layouts and troubleshooting common issues.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.