WMI Win32_BaseBoard SerialNumber - wmi

I used Win32_BaseBoard SerialNumber property to obtain the motherboard serial number and it work most of the time, but sometimes in some computers I get SerialNumber = "Base Board Serial Number" as a result.
Is there a programmatic way to obtain this serial number in a more efficient way or it is simply a manufacturer problem? I have heard that all motherboards come with a serial number with no exception. Is this true?

Whether the Serial Number returned by various WMI queries will be correct or not will depend on the manufacturer of the device. See the answer to this stackoverflow question, Motherboard ID - WMI C++ Reliable? which contains a couple of examples showing that your results can vary.
Some of the variables are whether the equipment is OEM or not and whether the equipment was purchased from a manufacturer who sells to the end customer such as Dell or a manufacturer who sells equipment to resellers who then configure the equipment or if the equipment was assembled from purchased parts.
Those results are processing the properties retrieved by several different WMI queries.
L"SELECT * FROM Win32_SystemEnclosure",
L"SELECT * FROM Win32_BaseBoard",
L"SELECT * FROM Win32_BIOS",
L"SELECT * FROM Win32_ComputerSystem",
L"SELECT * FROM Win32_ComputerSystemProduct",
L"SELECT * FROM Win32_MotherboardDevice",
For instance here is from a point of sale terminal that shows missing serial number information. The intent seems to be that the reseller or dealer or other vendor will provide their own serial number along with other information to basically relabel the terminal.
Connected to ROOT\CIMV2 WMI namespace
Query for SELECT * FROM Win32_SystemEnclosure
SMBIOS SerialNumber: None
SMBIOS Name: System Enclosure
SMBIOS SMBIOSAssetTag: None
SMBIOS Manufacturer: To Be Filled By O.E.M.
Query for SELECT * FROM Win32_BaseBoard
SMBIOS SerialNumber: None
SMBIOS Product: EIN70-SAM
SMBIOS Name: Base Board
SMBIOS Manufacturer: INTEL Corporation
Query for SELECT * FROM Win32_BIOS
SMBIOS SerialNumber: None
SMBIOS Name: BIOS Date: 10/15/13 20:06:15 Ver: 04.06.05
SMBIOS Manufacturer: American Megatrends Inc.
Query for SELECT * FROM Win32_ComputerSystem
SMBIOS Name: GENPOSA-1
SMBIOS Manufacturer: To be filled by O.E.M.
Query for SELECT * FROM Win32_ComputerSystemProduct
SMBIOS Name: EIN70-SAM
SMBIOS IdentifyingNumber: None
SMBIOS UUID: 03000200-0400-0500-0006-000700080009

It is possible that the information is not exposed to WMI. You can confirm this easily using wbemtest.exe (or WMI CIM Studio if you have it installed). On my current computer Win32_BaseBoard.SerialNumber is not null but an empty string. If this is the case you will need to find another way to get this information.

I had a similar problem. You can try out this query and see if it works for you. select UUID from Win32_ComputerSystemProduct

Related

How to track screens through time? [duplicate]

I have a setup with two regular displays and three projectors connected to a windows pc. In my win32 program I need to uniquely identify each monitor and store information for each such that I can retrieve the stored information even after computer restart.
The EnumDisplayDevices seems to return different device orders after restarting the computer. There is also GetPhysicalMonitorsFromHMONITOR which at least gives me the display's name. However, I need something like a serial number for my projectors, since they are the same model. How can I get such a unique identifier?
EDIT: This is the solution I came up with after reading the answer from user Anders (thanks!):
DISPLAY_DEVICEA dispDevice;
ZeroMemory(&dispDevice, sizeof(dispDevice));
dispDevice.cb = sizeof(dispDevice);
DWORD screenID;
while (EnumDisplayDevicesA(NULL, screenID, &dispDevice, 0))
{
// important: make copy of DeviceName
char name[sizeof(dispDevice.DeviceName)];
strcpy(name, dispDevice.DeviceName);
if (EnumDisplayDevicesA(name, 0, &dispDevice, EDD_GET_DEVICE_INTERFACE_NAME))
{
// at this point dispDevice.DeviceID contains a unique identifier for the monitor
}
++screenID;
}
EnumDisplayDevices with the EDD_GET_DEVICE_INTERFACE_NAME flag should give you a usable string. And if not, you can use this string with the SetupAPI to get the hardware id or driver key or whatever is unique enough for your purpose.
Set this flag to EDD_GET_DEVICE_INTERFACE_NAME (0x00000001) to retrieve the device interface name for GUID_DEVINTERFACE_MONITOR, which is registered by the operating system on a per monitor basis. The value is placed in the DeviceID member of the DISPLAY_DEVICE structure returned in lpDisplayDevice. The resulting device interface name can be used with SetupAPI functions and serves as a link between GDI monitor devices and SetupAPI monitor devices.

usb_string from user space in Linux

I have a USB Device with the following string present in the string descriptor table:
Index 0: Standard Language 0x0409 (English)
Index 1: Standard Manufacturer "xxx Corporation"
Index 2: Standard Product "xxx Board HID Device"
Index 3: Custom Sector "Bootloader" or "Application" (depending on current mode of operation).
I want to read the string at Index 3. For Windows, we have an API
HidD_GetIndexedString() which allows to get the string at any Index. What is the corresponding API in Linux? I see the driver is using usb_string to get the string in drivers but do we have any similar userspace API for usb in Linux?

Get unique identifier for Windows monitors

I have a setup with two regular displays and three projectors connected to a windows pc. In my win32 program I need to uniquely identify each monitor and store information for each such that I can retrieve the stored information even after computer restart.
The EnumDisplayDevices seems to return different device orders after restarting the computer. There is also GetPhysicalMonitorsFromHMONITOR which at least gives me the display's name. However, I need something like a serial number for my projectors, since they are the same model. How can I get such a unique identifier?
EDIT: This is the solution I came up with after reading the answer from user Anders (thanks!):
DISPLAY_DEVICEA dispDevice;
ZeroMemory(&dispDevice, sizeof(dispDevice));
dispDevice.cb = sizeof(dispDevice);
DWORD screenID;
while (EnumDisplayDevicesA(NULL, screenID, &dispDevice, 0))
{
// important: make copy of DeviceName
char name[sizeof(dispDevice.DeviceName)];
strcpy(name, dispDevice.DeviceName);
if (EnumDisplayDevicesA(name, 0, &dispDevice, EDD_GET_DEVICE_INTERFACE_NAME))
{
// at this point dispDevice.DeviceID contains a unique identifier for the monitor
}
++screenID;
}
EnumDisplayDevices with the EDD_GET_DEVICE_INTERFACE_NAME flag should give you a usable string. And if not, you can use this string with the SetupAPI to get the hardware id or driver key or whatever is unique enough for your purpose.
Set this flag to EDD_GET_DEVICE_INTERFACE_NAME (0x00000001) to retrieve the device interface name for GUID_DEVINTERFACE_MONITOR, which is registered by the operating system on a per monitor basis. The value is placed in the DeviceID member of the DISPLAY_DEVICE structure returned in lpDisplayDevice. The resulting device interface name can be used with SetupAPI functions and serves as a link between GDI monitor devices and SetupAPI monitor devices.

Slow Sqlite3 Select Query while Insert/Update/Delete has no issue

I am stuck in a issue related to slow sqlite3 select. I have searched alot on this forum and have applied many of the suggestion which has somewhere helped me in moving ahead. I assume there are some fault in the way i am trying to use sqlite or may be the settings which i have used while compiling it.
I decided to use sqlite3 in c++ after reading a lot about its performance. Since the data inflow is very high and the server is set in co-location at exchange , if the packet processing is delayed due to any reason there canbe a packet drop and a delayed packet is of no use in High Frequency
trading environment. There can be a minimum packet flow of 5 mbps where each packet is of a maximum 45 bytes size. My sqlite is set for In Memory
use.
To understand my comlete issue please go through the details below.
Below are the details of the Server:
Server Details on which i am trying to use Sqlite3
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 2
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 45
Model name: Intel(R) Xeon(R) CPU E5-2643 0 # 3.30GHz
Stepping: 7
CPU MHz: 3400.160
BogoMIPS: 6603.86
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 10240K
NUMA node0 CPU(s): 0,2,4,6,8,10,12,14
NUMA node1 CPU(s): 1,3,5,7,9,11,13,15
Ram: 48 gb
Operating System : CentOS 7
Kernel Version : Linux version 3.10.0-123.el7.x86_64 (builder#kbuilder.dev.centos.org) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) )
Details of process which i am using:
Compiling Sqlite3 with the following command
./configure --prefix=/usr --disable-static CFLAGS="-O3 -m64 -DSQLITE_DEFAULT_SYNCHRONOUS=0 -DSQLITE_CONFIG_SINGLETHREAD -DSQLITE_DEFAULT_AUTOMATIC_INDEX=0 -DSQLITE_DEFAULT_PAGE_SIZE=4096 -DSQLITE_DEFAULT_CACHE_SIZE=4000 -DHAVE_FDATASYNC=0"
Create Table Query :
create table 'Stream0' ( TokenNo int NOT NULL,OrderId integer NOT NULL,SIDE int NOT NULL,PRICE int NOT NULL,QTY int NOT NULL,PRIMARY KEY (OrderId));
Index On Table :
CREATE INDEX DataFilterIndex ON 'Stream0'(TokenNo , SIDE, Price,Qty);
Pragma Statement :
void SqliteManager::SetPragma()
{
rc= sqlite3_exec(db, "PRAGMA synchronous = OFF", NULL, NULL, &zErrMsg);
rc= sqlite3_exec(db, "PRAGMA count_changes = false", NULL, NULL, &zErrMsg);
rc= sqlite3_exec(db, "PRAGMA journal_mode = OFF", NULL, NULL, &zErrMsg);
}
Preparing Sqlite Query :
MyString <<"insert or replace into 'Stream0' values( ?1,?2,?3,?4,?5);";
rc= sqlite3_prepare_v2(db,MyString.str().c_str(),strlen(MyString.str().c_str()),&insert_stmt,NULL);
Note : -- Insert or replace has been used because the incoming data for any specified TokenNo may be with modify tag without any insert tag prior to this.
MyString.str(std::string());
MyString <<"delete from 'Stream0' where OrderId = ?1;";
rc = sqlite3_prepare_v2(db,MyString.str().c_str(),strlen(MyString.str().c_str()),&delete_stmt,NULL);
Once either data for specific TokenNo is asked to delete/Insert/Modify a select statement is raised to publish data to the user.
Select Statement:
MyString<<"select TokenNo,Price ,sum(QTY) from 'Stream0' where TokenNo=?1 and Side=66 group by Price order by Price desc limit 5";
rc = sqlite3_prepare_v2(db,MyString.str().c_str(),strlen(MyString.str().c_str()),&select_bid_stmt,NULL);
Here Side = 66 stands for price of Buyers and Price desc says price sorted in decreasing order.
One more is there which has Side = 83 which stands for Sellers and Price Asc says price sorted in ascending mode
If Insert/Modify data comes for a token then one of the query is raised either with Side = 66 or Side = 83 depending on the Side received in the incoming data Packet.
If Delete packet is recieved then Both of the query has to be released back to back.
If I run my executable with Insert/Replace/delete every thing goes well i.e : No packet drop, but the moment I start using Select query either single after Insert/Replace or both after Delete, packet drop starts.
I hope I have been able to describe my whole situation. Running Select query is a must for me. Please help.
Seems you are polling heavily listening for incoming packets but you query routine is just not fast enough.
You are using a powerful Xeon E5 processor capable of doing heavy duty muti-threading but you have configured the sqlite3 in single threaded mode. Try opening the database in multi- threading mode. Better keep the packet listener in one thread so that the main GUI thread remains responsive.Worker threads can easily perform the insert/delete/query database routines.

Windows Device properties documentation?

in windows if you go
DeviceManager -> Select Device(Like a a keyboard) -> Go to details -> List of properties:
Device description
Hardware Ids
Compatible Ids
Device class
Device class guid
Driver key
ConfigFlags
... etc
Where can I find what each of these properties mean?
From MSDN documentation, you will find description for Device Instance IDs, and link to other descriptions. This link briefly describes some of them, which are listed as following:
Device IDs
A device ID is a vendor-defined identification string that is the most
specific ID that Setup uses to match a device to an INF file. A device
has only one device ID. A device ID has the same format as a hardware
ID. If an enumerator reports a list of hardware IDs for a device, the
device ID should be the first hardware ID in the list.
The PnP Manager uses the device ID to create a subkey for a device
under the registry key for the device's enumerator.
To obtain a device ID, use an IRP_MN_QUERY_ID request and set the
Parameters.QueryId.IdType field to BusQueryDeviceID.
Hardware IDs
A hardware ID is a vendor-defined identification string that Setup
uses to match a device to an INF file. In most cases, a device has
associated with it a list of hardware IDs. (However, there are
exceptions – see Identifiers for 1394 Devices). The first hardware ID
in the list should be the device ID, and the remaining IDs should be
listed in order of decreasing suitability.
A hardware ID has one of the following generic formats:
<enumerator>\<enumerator-specific-device-ID> This is the most common
format for individual PnP devices reported to the PnP Manager by a
single enumerator. New enumerators should use this format or the
following format.
*<enumerator-specific-ID> The asterisk indicates that the device is supported by more than one enumerator, such as ISAPNP and the BIOS.
<device-class-specific-ID> An existing device class that has
established its own naming convention might use a custom format. For
information on their hardware ID formats, see the hardware
specification for such buses. New enumerators should not use this
format. The number of characters of a hardware ID, excluding a
NULL-terminator, must be less than MAX_LENGTH_LEN. This constraint
applies to the sum of the lengths of all the fields and any “\” field
separators in a hardware ID. In addition, when an instance ID is
concatenated to a hardware ID to create a device instance ID, the
lengths of the hardware ID and the instance ID are further constrained
by the maximum possible length of a device instance ID.
To obtain the list of hardware IDs for a device, call
IoGetDeviceProperty with the DeviceProperty parameter set to
DevicePropertyHardwareID. The list of hardware IDs that this routine
retrieves is a REG_MULTI_SZ value. The maximum number of characters in
a hardware list, including a NULL terminator after each hardware ID
and a final NULL terminator, is REGSTR_VAL_MAX_HCID_LEN. The maximum
possible number of IDs in a list of hardware IDs is MAX_HCID_COUNT.
Examples of Hardware IDs
In the following, the first example is a generic identifier for a PnP
device, and the second example is an identifier for a PCI device:
root*PNP0F08
PCI\VEN_1000&DEV_0001&SUBSYS_00000000&REV_02
Compatible IDs
A compatible ID is a vendor-defined identification string that Setup
uses to match a device to an INF file. A device can have associated
with it a list of compatible IDs. The compatible IDs should be listed
in order of decreasing suitability. If Setup cannot locate an INF file
that matches one of a device's hardware IDs, it uses compatible IDs to
locate an INF file. Compatible IDs have the same format as hardware
IDs; however, compatible IDs are typically more generic than hardware
IDs.
If a vendor ships an INF file that specifies a compatible ID for a
driver node, the vendor should ensure that their INF file can support
all the hardware that matches the compatible ID. Because a match with
a compatible ID is not as strong as a match to a hardware ID, the PnP
Manager prompts the user for confirmation before processing the INF
file.
To obtain a list of compatible IDs for a device, call
IoGetDeviceProperty with the DeviceProperty parameter set to
DevicePropertyCompatibleID. The list of compatible IDs that this
routine retrieves is a REG_MULTI_SZ value. The maximum number of
characters in a compatible ID list, including a NULL terminator after
each compatible ID and a final NULL terminator, is
REGSTR_VAL_MAX_HCID_LEN. The maximum possible number of IDs in a list
of compatible IDs is MAX_HCID_COUNT.
Instance IDs
An instance ID is a device identification string that distinguishes a
device from other devices of the same type on a machine. An instance
ID contains serial number information, if supported by the underlying
bus, or some kind of location information. The string cannot contain
any "\" characters; otherwise, the generic format of the string is
bus-specific.
The number of characters of an instance ID, excluding a
NULL-terminator, must be less than MAX_LENGTH_LEN. In addition, when
an instance ID is concatenated to a device ID to create a device
instance ID, the lengths of the device ID and the instance ID are
further constrained by the maximum possible length of a device
instance ID.
The UniqueID member of the DEVICE_CAPABILITIES structure for a device
indicates if a bus-supplied instance ID is unique across the system,
as follows:
If UniqueID is FALSE, the bus-supplied instance ID for a device is
unique only to the device's bus. The PnP Manager modifies the
bus-supplied instance ID, and combines it with the corresponding
device ID, to create a device instance ID that is unique in the
system. If UniqueID is TRUE, the device instance ID, formed from the
bus-supplied device ID and instance ID, uniquely identifies a device
in the system. An instance ID is persistent across system boots.
To obtain the bus-supplied instance ID for a device, use an
IRP_MN_QUERY_ID request and set the Parameters.QueryId.IdType member
to BusQueryInstanceID.
Device Instance IDs
A device instance ID is a system-supplied device identification string
that uniquely identifies a device in the system. The PnP Manager
assigns a device instance ID to each device node in a system's device
tree.
The format of this string consists of an instance ID concatenated to a
device ID, as follows:
\ The number of characters of a
device instance ID, excluding a NULL-terminator, must be less than
MAX_LENGTH_LEN. This constraint applies to the sum of the lengths of
all the fields and “\” field separator between the device ID and
instance-specific-ID fields. A device instance ID is persistent across
system boots.
The following is an example of an instance ID ("1&08") concatenated to
a device ID for a PCI device:
PCI\VEN_1000&DEV_0001&SUBSYS_00000000&REV_02\1&08
Most of it is exposed via the "Setup API". Some data may be driver-specific, in which case you'd have to ask the driver writer. The ones you've listed are all standard Microsoft properties. E.g. the "device class" describes what type of device it is, eg. mouse/keyboard/storage/videocard/audio/...