For my current C++ project I need to detect a unique string for every monitor that is connected and active on a large number of computers.
Research has pointed to 2 options
Use WMI and query the Win32_DesktopMonitor for all active monitors. Use the PNPDeviceID for unique identification of monitors.
Use the EnumDisplayDevices API, and dig down to get the device ID.
I'm interested in using the device id for unique model identification because monitors using the default plug and play driver will report a generic string as the monitor name "default plug and play monitor"
I have been experiencing issues with the WMI method, it seems to be only returning 1 monitor on my Vista machine, looking at the doco it turns out it does not work as expected on non WDDM devices.
The EnumDisplayDevices seems to be a little problematic to get going when it runs from a background service (especially on Vista), If it's in session 0 it will return no info.
Has anyone else had to do something similar (find unique model string for all connected active monitors?)
What approach worked best?
This is my current work-in-progress code for detecting the monitor device id, reliably.
CString DeviceID;
DISPLAY_DEVICE dd;
dd.cb = sizeof(dd);
DWORD dev = 0;
// device index
int id = 1;
// monitor number, as used by Display Properties > Settings
while (EnumDisplayDevices(0, dev, &dd, 0))
{
DISPLAY_DEVICE ddMon;
ZeroMemory(&ddMon, sizeof(ddMon));
ddMon.cb = sizeof(ddMon);
DWORD devMon = 0;
while (EnumDisplayDevices(dd.DeviceName, devMon, &ddMon, 0))
{
if (ddMon.StateFlags & DISPLAY_DEVICE_ACTIVE &&
!(ddMon.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))
{
DeviceID.Format (L"%s", ddMon.DeviceID);
DeviceID = DeviceID.Mid (8, DeviceID.Find (L"\\", 9) - 8);
}
devMon++;
ZeroMemory(&ddMon, sizeof(ddMon));
ddMon.cb = sizeof(ddMon);
}
ZeroMemory(&dd, sizeof(dd));
dd.cb = sizeof(dd);
dev++;
}
I've just discovered you can query Win32_PnPEntity for service="monitor", and it will return all monitors.
Results on my machine:
select * from Win32_PnPEntity where service="monitor"
Availability | Caption | ClassGuid | CompatibleID | ConfigManagerErrorCode | ConfigManagerUserConfig | CreationClassName | Description | DeviceID | ErrorCleared | ErrorDescription | HardwareID | InstallDate | LastErrorCode | Manufacturer | Name | PNPDeviceID | PowerManagementCapabilities | PowerManagementSupported | Service | Status | StatusInfo | SystemCreationClassName | SystemName
| Dell 2007FP (Digital) | {4d36e96e-e325-11ce-bfc1-08002be10318} | array[0..0] | 0 | False | Win32_PnPEntity | Dell 2007FP (Digital) | DISPLAY\DELA021\5&4F61016&0&UID257 | | | array[0..0] | | | Dell Inc. | Dell 2007FP (Digital) | DISPLAY\DELA021\5&4F61016&0&UID257 | | | monitor | OK | | Win32_ComputerSystem | 8HVS05J
| Dell ST2320L_Digital | {4d36e96e-e325-11ce-bfc1-08002be10318} | array[0..0] | 0 | False | Win32_PnPEntity | Dell ST2320L_Digital | DISPLAY\DELF023\5&4F61016&0&UID256 | | | array[0..0] | | | Dell Inc. | Dell ST2320L_Digital | DISPLAY\DELF023\5&4F61016&0&UID256 | | | monitor | OK | | Win32_ComputerSystem | 8HVS05J
We've been toying with EnumDisplayDevices in order to detect if the current video card manufacturer is NVIDIA. It's not the same, but maybe it would help. Our piece looked like this:
int disp_num = 0;
BOOL res = TRUE;
do {
DISPLAY_DEVICE disp_dev_info;
ZeroMemory( &disp_dev_info, sizeof(DISPLAY_DEVICE) );
disp_dev_info.cb = sizeof(DISPLAY_DEVICE);
res = EnumDisplayDevices( 0, disp_num++, &disp_dev_info, 0x00000001 );
if(res &&
disp_dev_info.DeviceString[0]!=0 && disp_dev_info.DeviceString[0]=='N' &&
disp_dev_info.DeviceString[1]!=0 && disp_dev_info.DeviceString[1]=='V' &&
disp_dev_info.DeviceString[2]!=0 && disp_dev_info.DeviceString[2]=='I' &&
disp_dev_info.DeviceString[3]!=0 && disp_dev_info.DeviceString[3]=='D' &&
disp_dev_info.DeviceString[4]!=0 && disp_dev_info.DeviceString[4]=='I' &&
disp_dev_info.DeviceString[5]!=0 && disp_dev_info.DeviceString[5]=='A'){
isNVidia = true;
}
int x = 0;
}while( res != FALSE );
Pretty dumb, but working.
The Win32_DesktopMonitor method only returns 1 monitor on my Vista machine as well. The PnP ID seems to be set correctly, though.
I've had a quick play with the EnumDisplayDevices API, and while it seems to discover the adapter details reliably (presumably because most people won't leave it as "Standard VGA" for long), it only returns "Plug and Play Monitor" for the connected monitors.
This echoes research that I did into this several years ago (had to put some code together to aid in dusting those memories off).
This is from a normal user account. If you've got a reliable way to get EnumDisplayDevices to return the PnP ID, even in normal user sessions, I'd be interested -- we're currently investigating if any of this information is available to a device driver.
One thing you could do, if running the code from session #0 isn't reliable enough, is to see if you can spawn a helper process (either using CreateProcessAsUser or using COM with activation monikers) that'll run in the user's context.
I've never tried doing it from a service, but EnumDisplayDevices generally works well when run as a user. I believe that services run in a separate (and headless) session, which could explain the problem you're seeing there.
Could you run a helper program from your service, impersonating a user account that has access to the displays?
Related
Could you check why user kcizek is not able to login to either hub.tess.io nor ecr? This is first time login but it should work with corp and PIN + Yubi. Login works for me just fine.
I am unable to access https://ecr.vip.ebayc3.com/repository/
When I log in, I am faced with this. The ‘contact us’ link doesn’t have any contact information, so I’m trying here. Any ideas? Thanks.
Potentially relevant background: this is my first time attempting to get access.
enter image description here
It's found the email info is absent in user account.
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | default |
| email | |
| enabled | True |
| id | e69fe5b9d9384b338b3c397c7c84e33f |
| name | kcizek |
+-----------+----------------------------------+
Solution is to contact Tess oncall to add email info.
Related Command
openstack user set kcizek --email kcizek#ebay.com
I want to launch a instance with two vNic card . On one vnic i want use for private network and other vNic use for public network, How we can do that in openstack ?
you need to boot the image with twice the --nic net-id= argument as in the example bellow:
nova boot --image cirros-0.3.3-x86_64 --flavor tiny_ram_small_disk --nic net-id=b7ab2080-a71a-44f6-9f66-fde526bb73d3 --nic net-id=120a6fde-7e2d-4856-90ee-5609a5f3035f --security-group default --key-name bob-key CIRROSone
here is the result
root#columbo:~# nova list
+--------------------------------------+-----------+---------+------------+-------------+-----------------------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+-----------+---------+------------+-------------+-----------------------------------------------+
| d75ef5b3-060d-4ec0-9ddf-a3685a7f1199 | CIRROSone | ACTIVE | - | Running | SecondVlan=5.5.5.4; SERVER_VLAN_1=10.255.1.16 |
+--------------------------------------+-----------+---------+------------+-------------+-----------------------------------------------+
I have used bosh-lite to deploy a single node cloudfoundry in my development environment. After deployment, I run the bosh vms, and it returns the vms list:
+------------------------------------+---------+---------------+--------------+
| Job/index | State | Resource Pool | IPs |
+------------------------------------+---------+---------------+--------------+
| api_z1/0 | running | large_z1 | 10.244.0.138 |
| etcd_leader_z1/0 | running | medium_z1 | 10.244.0.38 |
| ha_proxy_z1/0 | running | router_z1 | 10.244.0.34 |
| hm9000_z1/0 | running | medium_z1 | 10.244.0.142 |
| loggregator_trafficcontroller_z1/0 | running | small_z1 | 10.244.0.10 |
| loggregator_z1/0 | running | medium_z1 | 10.244.0.14 |
| login_z1/0 | running | medium_z1 | 10.244.0.134 |
| nats_z1/0 | running | medium_z1 | 10.244.0.6 |
| postgres_z1/0 | running | medium_z1 | 10.244.0.30 |
| router_z1/0 | running | router_z1 | 10.244.0.22 |
| runner_z1/0 | running | runner_z1 | 10.244.0.26 |
| uaa_z1/0 | running | medium_z1 | 10.244.0.130 |
+------------------------------------+---------+---------------+--------------+
But when I try to use "cf api https://api.10.244.0.34.xip.io --skip-ssl-validation" to connect the cloudfoundry, it returns an error:
ConnectEx tcp: No connection could be made because the target machine
actively refused it.
The log information is very general (actually this is the exception from CF client which is written in .net), and doesn't provide useful information.
My question is, which VM handles the api command? And, where can I find the detail log in that VM?
api_z1/0 is handling the command. You can get its logs via the BOSH CLI itself: bosh logs api_z1 0 --all.
You probably also need to add the route to your local route table so that traffic to HAProxy container at 10.244.0.24 knows to go through the BOSH-lite VM at 192.168.50.4. Run bin/add-route or bin/add-route.bat from the root of your BOSH-lite repo.
I'm using these flags:
SHFILEOPSTRUCTW op;
// ..
op.wFunc = FO_DELETE;
op.fFlags = FOF_ALLOWUNDO | FOF_NORECURSION |
FOF_RENAMEONCOLLISION | FOF_WANTNUKEWARNING |
FOF_FILESONLY | FOF_NOCONFIRMATION |
FOF_NO_CONNECTED_ELEMENTS | FOF_SILENT | FOF_NOERRORUI;
And all works ok for files that are not read-only nor system, but when such file is encountered there is a dialog window for user to confirm moving such file to trash. How to disable it ? Must I work around this by first stripping these attributes or is there a setting I do not know of ?
What I need to do is simply to move a file (one by one, I don't need wildcards) to trash. Are there any other api calls that can do this ?
Hidden attribute is not affected by this behavior.
I have set up my version table info in my version.rc file as follows:
+-----------------+-----------------------------------------+
| Key | Value |
+-----------------+-----------------------------------------+
| CompanyName | MyCompany
| FileDescription | A test application that does something. |
| InternalName | TestApp |
| FileVersion | 1.0.0 |
| OriginalFilename| TestApp.exe
| ProductVersion | 1.0.0 |
| ProductName | Test Application |
+-----------------+-----------------------------------------+
Whenever my application crashes or some antivirus message pops up asking for permission or basically any event that displays my application name occurs, the application name is displayed as "A test application that does something", i.e. FileDescription is taken as the application name. I am using this article as my reference.
What I see:
What I Want to See:
To achieve the second image, I edited FileDescription to "Test Application".
BUT, now in the task manager (and other areas where the description is used),
After Editing FileDescription to "Test Application":
Before Editing FileDescription:
I want to know if there's some way to specify to the OS to use the ProductName in the first case above (and other similar cases) and FileDescription in the second case above (and other similar cases).