Retrieving information from SMBIOS - page 4

 
Vitaly Muzichenko:

I wish someone would have checked the vin.

I'm the one who uploaded it.

 
JRandomTrader:

I was just uploading from a winepad.

Well, you didn't want to check with hwinfo to see if the uuid was correct.

 

Here are the fixes.

For real-world use, when you don't need the extra info, comment out/not define #define SMBIOS_DEBUG

Files:
SMBIOS.mqh  6 kb
 
Edgar Akhmadeev:

Here are the fixes.

For real use, when you don't need extra info, comment out/not define #define SMBIOS_DEBUG

And how can mqh be cleaned of unnecessary code, so that onlyPrint("UUID: ", uuid) remains;

 
Vitaly Muzichenko:

And how can mqh be cleaned of excess code so that onlyPrint("UUID: ", uuid) remains;

Remove all wrappers #ifdef SMBIOS_DEBUG / #endif

Do not erase parts in #else

 
Edgar Akhmadeev:

Delete all wrapped #ifdef SMBIOS_DEBUG / #endif

Don't erase the parts in #else

Can't read the code at all, it's so screwed up. When deleting something I break everything.

I want to leave some lines with transfer to the script itself

Here's the code for getting the C partition number, it's short and to the point.

#import "kernel32.dll"
   bool GetVolumeInformationW(const string root_path_name,
                              string volume_name_buffer,
                              uint volume_name_size,
                              uint &volume_serial_number[],
                              uint maximum_component_length,
                              uint file_system_flags,
                              string file_system_name_buffer,
                              uint file_system_name_size
);
#import

string SystemDriveSerialNumber() {
   int iVolumeSerialNumber[1]= {0};
   string sVolumeSerialNumber="";
   if(GetVolumeInformationW("C:\\",NULL,15,iVolumeSerialNumber,0,0,NULL,15)) {
      sVolumeSerialNumber=IntegerToHexString(iVolumeSerialNumber[0]);
      sVolumeSerialNumber=StringSubstr(sVolumeSerialNumber,0,4)+"-"+StringSubstr(sVolumeSerialNumber,4);
   }
  return(sVolumeSerialNumber);
}

---

Can you do it like this, please?

 
Vitaly Muzichenko:

I can't read the code at all, it's too complicated. If I delete something, I break everything.

I would like to leave a few lines in the script itself

Here's the code for getting the C partition number, it's short and to the point.

---

Can you do it like this, please?

What's the point of cleaning up the code in the library, tweaking to suit private needs? Those pieces of code don't compile when not needed. Just to inlude the library, and it's called by a single line.

string uuid = SMBIOS::Read();

For the purpose of making sense of the code? The function is small by my standards. If you remove it carefully, as I explained - everything in the #ifdef/#endif wrapper, but leaving between #else/#endif - nothing will break. Half of the code will still be there. It's not just a query and output, but a sequence of blocks of data, processing and recoding.

 
Edgar Akhmadeev:

What is the point of cleaning the code in the library, tweaking it to suit private needs? These pieces of code are not compiled when not needed. Just an inline library, and it's called with one line of code?

For the purpose of making sense of the code? The function is small by my standards. If you remove it carefully, as I explained - everything in the #ifdef/#endif wrapper, but leaving between #else/#endif - nothing will break. Half of the code will still be there. It's not just a query and output, but a sequence of data blocks, processing and recoding.

I'll try another way, maybe something will work.

The last attempt led to this, but of course I didn't see any data either.


 

Made a cosmetic fix, no need to re-download

#define  SIG(a, b, c, d) ((a << 24) + (b << 16) + (c << 8) + d)

const uint SMBIOS_signature = SIG('R','S','M','B');

I wish it were like in c++

const uint SMBIOS_signature = 'RSMB';

There is one in MQL

datetime d = D'2020.07.06';

Maybe I don't know some subtleties?

Files:
SMBIOS.mqh  6 kb
 
Edgar Akhmadeev:

Made a cosmetic fix, no need to re-download

I wish it were like in c++

There is one in MQL

Maybe I don't know any subtleties?

Thank you very much, it worked!