---
title: "Discussion on \"Changing the primary display on Windows by code is easy... right?\" | Hashnode"
description: "Discussion on \"Changing the primary display on Windows by code is easy... right?\". A story about the weirdness of the Windows API."
url: "https://hashnode.com/posts/primary-display-windows/62a34a4b165482d2b3ee96a1"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Changing the primary display on Windows by code is easy... right?](https://blog.lohr.dev/primary-display-windows?utm_source=hashnode&utm_medium=feed)

A story about the weirdness of the Windows API.

Jun 10, 2022 · 4 min read · blog.lohr.dev  
Updated Jul 15, 2022  
Read the article

-   [#windows](https://hashnode.com/tag/windows)
-   [#rust](https://hashnode.com/tag/rust)
-   [#tools](https://hashnode.com/tag/tools)
-   [#operating-system](https://hashnode.com/tag/operating-system)

## Written by

[Michael Lohr](https://hashnode.com/@michidk)

@michidk · Bavaria, Germany

  
[View profile](https://hashnode.com/@michidk)

Because a Great Idea Is Never Enough

Passionate about software development and architecture, web and cloud technologies, as well as game development.

## Responses 1

Markdown supported · ⌘↵ to post

[holunder](https://hashnode.com/@holundermannski)

[Sep 20, 2022](https://hashnode.com/posts/primary-display-windows/62a34a4b165482d2b3ee96a1/comment/6329d4e299624fc71cd549b9)

Hello,

thanks for the writing. I had really similar struggles with the same topic doing it in python (pywin32).

I also came to the same solutions, but there is still one unsolved thing for me and it would be really nice if you have an answer for this.

All works fine when win10 is allready in dual monitor mode. But when one of the connected monitors is not activated I cannot change settings at all and my code keeps crashing.

Do you now is there any call or Flag that I have to set that this monitor gets active?

thank and all the best, Holunder

[Michael Lohr](https://hashnode.com/@michidk)

[Sep 21, 2022](https://hashnode.com/posts/primary-display-windows/62a34a4b165482d2b3ee96a1/comment/6329d4e299624fc71cd549b9#reply-632acd0629f9bcdf820d426e)

Hi, make sure that you only set properties for displays that are have the active flag. I don't think you can change the properties of inactive monitors.
