jjzjj

java - 连接的显示器名称

coder 2024-02-23 原文

我正在开发一个使用附加显示器(Wacom 数位板)的应用程序。 我需要确定它的放置位置,但我从 Java 代码中收集到的 DisplayName 始终是 Display 0、Display 1 等... 我尝试使用小型 C++ 来获取系统显示:

void DumpDevice(const DISPLAY_DEVICE& dd, size_t nSpaceCount)
{   
    printf("%*sDevice Name: %s\n", nSpaceCount, "", dd.DeviceName);
    printf("%*sDevice String: %s\n", nSpaceCount, "", dd.DeviceString);
    printf("%*sState Flags: %x\n", nSpaceCount, "", dd.StateFlags);
    printf("%*sDeviceID: %s\n", nSpaceCount, "", dd.DeviceID);
    printf("%*sDeviceKey: ...%s\n\n", nSpaceCount, "", dd.DeviceKey + 42);
}

int main()
{
    DISPLAY_DEVICE dd;

    dd.cb = sizeof(DISPLAY_DEVICE);

    DWORD deviceNum = 0;
    while (EnumDisplayDevices(NULL, deviceNum, &dd, 0)){
        DumpDevice(dd, 0);
        DISPLAY_DEVICE newdd = { 0 };
        newdd.cb = sizeof(DISPLAY_DEVICE);
        DWORD monitorNum = 0;
        while (EnumDisplayDevices(dd.DeviceName, monitorNum, &newdd, 0))
        {
            DumpDevice(newdd, 4);
            monitorNum++;
        }
        puts("");
        deviceNum++;
    }

    system("pause");

    return 0;
}

(我从堆栈溢出的另一个答案中得到这段代码,但我不记得链接到它的页面)。

无论如何,输出真的没有用:

Device Name: \
Device String: I
State Flags: 5
DeviceID: P
DeviceKey: ...\

    Device Name: \
    Device String: G
    State Flags: 3
    DeviceID: M
    DeviceKey: ...\


Device Name: \
Device String: I
State Flags: 1
DeviceID: P
DeviceKey: ...\

    Device Name: \
    Device String: G
    State Flags: 3
    DeviceID: M
    DeviceKey: ...\


Device Name: \
Device String: I
State Flags: 1
DeviceID: P
DeviceKey: ...\

    Device Name: \
    Device String: G
    State Flags: 3
    DeviceID: M
    DeviceKey: ...\


Device Name: \
Device String: I
State Flags: 8000000
DeviceID: P
DeviceKey: ...\


Device Name: \
Device String: I
State Flags: 0
DeviceID: P
DeviceKey: ...\


Device Name: \
Device String: I
State Flags: 0
DeviceID: P
DeviceKey: ...\

有什么解决办法吗?

编辑:Java 应用程序需要所有这些,我正在使用 C++ 创建一个简单的包装,并使用 JNI 调用我的包装。如果存在一种更好的方法来执行此操作而不从 C++ 传递则更好。

最佳答案

我更改为 ANSII 字符集,现在输出如下(感谢 SirDarius 的提示):

Device Name: \\.\DISPLAY1
Device String: Intel(R) HD Graphics Family
State Flags: 5
DeviceID: PCI\VEN_8086&DEV_0A16&SUBSYS_05CB1028&REV_0B
DeviceKey: ...\Control\Video\{80DB7D25-0399-49FD-A13A-F5FEAD8FCC0B}\0000

    Device Name: \\.\DISPLAY1\Monitor0
    Device String: Generic PnP Monitor
    State Flags: 3
    DeviceID: MONITOR\AUO133D\{4d36e96e-e325-11ce-bfc1-08002be10318}\0003
    DeviceKey: ...\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0003


Device Name: \\.\DISPLAY2
Device String: Intel(R) HD Graphics Family
State Flags: 1
DeviceID: PCI\VEN_8086&DEV_0A16&SUBSYS_05CB1028&REV_0B
DeviceKey: ...\Control\Video\{80DB7D25-0399-49FD-A13A-F5FEAD8FCC0B}\0001

    Device Name: \\.\DISPLAY2\Monitor0
    Device String: Generic PnP Monitor
    State Flags: 3
    DeviceID: MONITOR\DELA0B9\{4d36e96e-e325-11ce-bfc1-08002be10318}\0004
    DeviceKey: ...\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0004


Device Name: \\.\DISPLAY3
Device String: Intel(R) HD Graphics Family
State Flags: 1
DeviceID: PCI\VEN_8086&DEV_0A16&SUBSYS_05CB1028&REV_0B
DeviceKey: ...\Control\Video\{80DB7D25-0399-49FD-A13A-F5FEAD8FCC0B}\0002

    Device Name: \\.\DISPLAY3\Monitor0
    Device String: Generic PnP Monitor
    State Flags: 3
    DeviceID: MONITOR\WAC1039\{4d36e96e-e325-11ce-bfc1-08002be10318}\0006
    DeviceKey: ...\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0006


Device Name: \\.\DISPLAY4
Device String: Intel(R) HD Graphics Family
State Flags: 8000000
DeviceID: PCI\VEN_8086&DEV_0A16&SUBSYS_05CB1028&REV_0B
DeviceKey: ...\Control\Video\{80DB7D25-0399-49FD-A13A-F5FEAD8FCC0B}\0003


Device Name: \\.\DISPLAY5
Device String: Intel(R) HD Graphics Family
State Flags: 8000000
DeviceID: PCI\VEN_8086&DEV_0A16&SUBSYS_05CB1028&REV_0B
DeviceKey: ...\Control\Video\{80DB7D25-0399-49FD-A13A-F5FEAD8FCC0B}\0004


Device Name: \\.\DISPLAY6
Device String: Intel(R) HD Graphics Family
State Flags: 8000000
DeviceID: PCI\VEN_8086&DEV_0A16&SUBSYS_05CB1028&REV_0B
DeviceKey: ...\Control\Video\{80DB7D25-0399-49FD-A13A-F5FEAD8FCC0B}\0005

如何查看显示器的友好名称,全部显示为 Generic PnP!

关于java - 连接的显示器名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34652839/

有关java - 连接的显示器名称的更多相关文章

  1. ruby-on-rails - Rails 编辑表单不显示嵌套项 - 2

    我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib

  2. ruby - 解析 RDFa、微数据等的最佳方式是什么,使用统一的模式/词汇(例如 schema.org)存储和显示信息 - 2

    我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i

  3. ruby - 续集在添加关联时访问many_to_many连接表 - 2

    我正在使用Sequel构建一个愿望list系统。我有一个wishlists和itemstable和一个items_wishlists连接表(该名称是续集选择的名称)。items_wishlists表还有一个用于facebookid的额外列(因此我可以存储opengraph操作),这是一个NOTNULL列。我还有Wishlist和Item具有续集many_to_many关联的模型已建立。Wishlist类也有:selectmany_to_many关联的选项设置为select:[:items.*,:items_wishlists__facebook_action_id].有没有一种方法可以

  4. ruby-on-rails - 使用 Sublime Text 3 突出显示 HTML 背景语法中的 ERB? - 2

    所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择

  5. java - 等价于 Java 中的 Ruby Hash - 2

    我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/

  6. ruby-on-rails - link_to 不显示任何 rails - 2

    我试图在索引页中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码。ListingarticlesTitleTextssss我检查了我的路线,我认为它们也没有问题。PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/article

  7. ruby - 无法在 60 秒内获得稳定的 Firefox 连接 (127.0.0.1 :7055) - 2

    我使用的是Firefox版本36.0.1和Selenium-Webdrivergem版本2.45.0。我能够创建Firefox实例,但无法使用脚本继续进行进一步的操作无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055)错误。有人能帮帮我吗? 最佳答案 我遇到了同样的问题。降级到firefoxv33后一切正常。您可以找到旧版本here 关于ruby-无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055),我们在StackOverflow上找到一个类

  8. ruby-on-rails - 如何在 Rails View 上显示错误消息? - 2

    我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c

  9. java - 从 JRuby 调用 Java 类的问题 - 2

    我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www

  10. ruby-on-rails - 有没有办法为 CarrierWave/Fog 设置上传进度指示器? - 2

    我在Rails应用程序中使用CarrierWave/Fog将视频上传到AmazonS3。有没有办法判断上传的进度,让我可以显示上传进度如何? 最佳答案 CarrierWave和Fog本身没有这种功能;你需要一个前端uploader来显示进度。当我不得不解决这个问题时,我使用了jQueryfileupload因为我的堆栈中已经有jQuery。甚至还有apostonCarrierWaveintegration因此您只需按照那里的说明操作即可获得适用于您的应用的进度条。 关于ruby-on-r

随机推荐