Solved

Need Win7 x86/x64 source code to set duplicate/extend monitor display modes

Posted on 2011-03-25
9
1,568 Views
Last Modified: 2013-12-04
Can anyone point me to (preferably C#, C++ ok) source code to change display mode back and forth between mirror (duplicate) display mode vs extended mode? Need to target Win7 x86/x64 dual-monitor PCs and need code that's display driver independent. This for an app that reads desired video settings from registry and sets up displays accordingly.

Essentially I want to replicate what happens on Win7 when you hit Windows-P and select Duplicate or Extend.

WMI or not WMI is good. Prefer something expected to be portable to future Windows versions.
0
Comment
Question by:mab
  • 5
  • 2
9 Comments
 
LVL 87

Expert Comment

by:rindi
ID: 35221327
I'm afraid as windows 7 isn't opensource, you will never be able to get their source code. They don't even sell it to partners.
0
 

Assisted Solution

by:mab
mab earned 0 total points
ID: 35226964
Don't need source to Win7, just a bit of source I can put in an app to interact with Win7. Other folks have done this, e.g. UltraMon, but I don't know how. And I need a bit of code I can integrate into an app instead of an existing app which won't have the non-UI control interface I need.
0
 
LVL 87

Expert Comment

by:rindi
ID: 35227042
You won't be able to get even a bit of source code for any Windows OS, at least not legally, and on this site you'll only ever going to get answers that are legal. How others did things I don't know, maybe through reverse engineering, or maybe by creating something new from scratch? But either way you'd have to do it yourself.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Assisted Solution

by:mab
mab earned 0 total points
ID: 35235670
rindi,

My apologies if I'm misinterpreting what you've said, but I get the impression you think I'm trying to obtain some Win7 OS source code, legally or illegally. That's not what I'm after at all.

When I press Windows+P and Duplicate/Extend, something (shell?) responds and calls some Win7 APIs to change the display config. What I want to do is identify what APIs get called to accomplish this so that I can call the same APIs from my code.

0
 

Accepted Solution

by:
mab earned 0 total points
ID: 35449084
Close it as "solved by originator"? Also "abandoned", I guess, but "abandoned" doesn't indicate solution found.

I found a very simple solution buried in the Win7 display driver docs:
SetDisplayConfig(0,NULL,0,NULL,SDC_TOPOLOGY_CLONE|SDC_APPLY);

Guess I'll have to award the points to myself... ;-)
0
 

Author Comment

by:mab
ID: 35449225
so easy to do, so well hidden in the docs...

Why does EE closing insist I choose at least two comments to award points to? None of the comments were useful except my own on closing that showed the solution I found.
0
 

Author Closing Comment

by:mab
ID: 35473563
SetDisplayConfig() and related Win7 APIs are more powerful/flexible and more complex than what was available previously.

Wish I'd thought of digging around in the driver docs sooner. Been looking into this issue off and on for some time now.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
OfficeMate Freezes on login or does not load after login credentials are input.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now