gpt4 book ai didi

java - 连接的显示器名称

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:08:41 25 4
gpt4 key购买 nike

我正在开发一个使用附加显示器(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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com