How to get the motherboard serial number on Win machine?
-
Hi,
I want to get physical ModherBoard ID and Disc ID on Windows machine. I found this website from microsoft MSDN.But I couldn't get correct result. İt's getting error on first step.
If I run this than I will use query like 'Win32_PhysicalMedia' and 'Win32_BaseBoard' to get my demands.
I use Qt 5.14 and Qt-Creator 4.11.0 on Win 10.
Regards,
Mucip:) -
@SGaist ,
hres = CoInitializeEx(NULL, COINIT_MULTITHREADED);It looks this return FALSE... :(
Regards,
Mucip:)@Mucip said in How to get the motherboard serial number on Win machine?:
CoInitializeEx
Googling for
CoInitializeEx qt
, does https://stackoverflow.com/questions/2979113/qcoreapplication-qapplication-with-wmi ("QCoreApplication QApplication with WMI") address your issue? -
Hi,
You might want to share the error you are getting.
In any case, did you try to run the code at the bottom of the article ?
-
Hi,
You might want to share the error you are getting.
In any case, did you try to run the code at the bottom of the article ?
-
Hi,
You might want to share the error you are getting.
In any case, did you try to run the code at the bottom of the article ?
-
Hi,
You might want to share the error you are getting.
In any case, did you try to run the code at the bottom of the article ?
-
@SGaist ,
hres = CoInitializeEx(NULL, COINIT_MULTITHREADED);It looks this return FALSE... :(
Regards,
Mucip:)@Mucip said in How to get the motherboard serial number on Win machine?:
CoInitializeEx
Googling for
CoInitializeEx qt
, does https://stackoverflow.com/questions/2979113/qcoreapplication-qapplication-with-wmi ("QCoreApplication QApplication with WMI") address your issue? -
@Mucip said in How to get the motherboard serial number on Win machine?:
CoInitializeEx
Googling for
CoInitializeEx qt
, does https://stackoverflow.com/questions/2979113/qcoreapplication-qapplication-with-wmi ("QCoreApplication QApplication with WMI") address your issue? -
@SGaist ,
hres = CoInitializeEx(NULL, COINIT_MULTITHREADED);It looks this return FALSE... :(
Regards,
Mucip:)@Mucip said:
It looks this return FALSE... :(
FALSE
returned fromCoInitializeEx
does not mean it failed. It means COM is already initialized on that thread.QApplication
does that. Changing the parameter causes you to have two initialization attempts with different apartments and that causes that second error.You should use the
FAILED
macro to check for the result ofCoInitializeEx
. It checks if the returned value is<0
, soFALSE
, which is defined as0
, does not mean it failed. -
@Mucip said:
It looks this return FALSE... :(
FALSE
returned fromCoInitializeEx
does not mean it failed. It means COM is already initialized on that thread.QApplication
does that. Changing the parameter causes you to have two initialization attempts with different apartments and that causes that second error.You should use the
FAILED
macro to check for the result ofCoInitializeEx
. It checks if the returned value is<0
, soFALSE
, which is defined as0
, does not mean it failed.@Chris-Kawa
...which is also what the code on the stackoverflow link showed to the OP... -
@Chris-Kawa
...which is also what the code on the stackoverflow link showed to the OP...@JonB And yet he continued as if it didn't so I thought I'd make it clear ;)
-
Hi All,
I checked this website.He add the below lines in the begining of the code.
bool WMICommunication::connect() { // result code from COM calls HRESULT hr = 0; BSTR resource = SysAllocString(L"ROOT\\CIMV2"); CoUninitialize(); hr = CoInitializeEx(0, COINIT_MULTITHREADED);
Now everything worked well. No error but no result either. :)
The result message is:
Connected to ROOT\CIMV2 WMI namespaceOS Name : 0x167ad7b1f38
I think it's not correct result!
Why?...
Regards,
Mucip:) -
Hi again,
I coppied all code again in to Qt and add the below code in the top of the code.BSTR resource = SysAllocString(L"ROOT\\CIMV2"); CoUninitialize();
Now it's OK. Thanks all.
@Mucip said in How to get the motherboard serial number on Win machine?:
Now it's OK. Thanks all.
Then please mark as SOLVED. Thanks!