2

I need to get the name of monitors for my computer using C / c++. I am using this:

https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html

(Is this the best way to do this?) I can get a lot of information and do things to the monitors, but I cannot get the display name.

This question was asked here, answers were given for obj-c but not for c++.

How to Get the Display Name with the Display ID in Mac OS X?

Community
  • 1
  • 1
  • a model name could be sufficient, too. Using the quartz services you can get the model id: CGDisplayModelNumber – user2280271 Sep 10 '14 at 17:25
  • Have you thought about using `osascrip` with `system` to access the Quartz Services? – scohe001 Sep 10 '14 at 17:27
  • I think it needs to happen from within a c program. It will eventually be accessed by a node-webkit module. – user2280271 Sep 10 '14 at 17:43
  • see this answer on [using AppleScript in c](http://stackoverflow.com/questions/9957672/run-applescript-from-c) – scohe001 Sep 10 '14 at 17:45
  • Wish I could find the source code I ended up writing, but I asked this question about 10 years ago on the cocoa-dev list; maybe this will help you: http://www.cocoabuilder.com/archive/cocoa/122396-getting-list-of-connected-displays.html – Alex Reynolds Sep 10 '14 at 23:48
  • The vast majority of the accepted answer to the question you linked is in C. The only Objective-C parts are the use of `NSScreen` and `NSNumber`, but that's just to get the display ID which, as you're already aware, you can get from Quartz Display Services API. That said, it relies on `CGDisplayIOServicePort()` which has been deprecated. (Since there's no replacement, I'd still use it but write fallback code in case it fails. Deprecated doesn't mean instantly unusable.) – Ken Thomases Dec 03 '14 at 08:41

0 Answers0