Generic Class Library - bugs, description, questions, usage and suggestions - page 34

 
Edgar Akhmadeev:
As our comrade Mao said: Let a hundred colours bloom.
I wonder if the uuid matches?

The uuid is not given out. Only the serial number of the board. Experience has shown that SMBIOS does not give out serial numbers for all boards, while uuid is always present and matches what hardware analysis software (e.g. HWiNFO) gives out. How the sorcerer's serial number variant works is a matter of checking.

 

Found out how to get the UUID.

#define _WIN64  // Only for a 64-bit terminal!

#include <WbemCli.mqh>
//+-----------------------------------------------------------------------------------------------+
//| Script program start function                                                                 |
//+-----------------------------------------------------------------------------------------------+
void OnStart()
{
   HRESULT result = CoInitialize( 0 );
   if( result == S_OK ){
      lpWbemLocator pLoc;
      result = CoCreateInstance( CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, pLoc.mInterface );
      if( result == S_OK ){
         lpWbemServices pSvc;
         result = pLoc.ConnectServer( "root\\CimV2", "", "", "", pSvc );
         if( result == S_OK ){
            result = CoSetProxyBlanket( pSvc.mInterface, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, 0, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, 0, EOAC_NONE );
            if( result == S_OK ){
               lpEnumWbemClassObject pEnumerator;
               // Получаем UUID.
               result = pSvc.ExecQuery( "SELECT * FROM Win32_ComputerSystemProduct", pEnumerator );
               if( result == S_OK ){
                  uint uReturn = 0;
                  while( result == S_OK ){
                     lpWbemClassObject pclsObj;
                     result = pEnumerator.Next( pclsObj, uReturn );
                     if( uReturn == 0 ){
                        result = S_OK;
                        break;
                     }
                     Variant vtProp;
                     result = pclsObj.Get( "UUID", vtProp );
                     if( result == S_OK ){
                        Print( "UUID", ": ", vtProp.toString() );
                     }
                     pclsObj.Release();
                  }
               }
               
            }
            pSvc.Release();
         }
         pLoc.Release();
      }
      CoUninitialize();
   }
   if( result != S_OK ){
      ushort shortArray[256];
      uint len = FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, 0, result, Lcid, shortArray, 256, 0 );
      string strError = ShortArrayToString( shortArray );
      Print( strError );
   }
}
//+-----------------------------------------------------------------------------------------------+
 
Koldun Zloy:

Offtop, but since you are here. Did you close the Market Watch window and the window with current open positions/orders?

 
fxsaber:

Offtopic, but since you are here. Have you done the closing of the Market Watch window and the window with the current open positions/orders?

No i didn't.

I think you know how to get the handles of those windows.

Have you tried sending them a WM_CLOSE message?

 
Koldun Zloy:

No, I didn't.

I think you know how to get the handles of these windows.

Have you tried sending them WM_CLOSE message?

Tried different variants, but unfortunately it didn't work for some reason.

 
Please add a const modifier to the method.
   bool              TryGetValue(TKey key,TValue &value) const;
 

Question on collisions. Is it possible to run into a collision in such a case?

#include <Generic\HashMap.mqh>

CHashMap<ulong, int> Index;

If 27,000 entries have been made.

 
fxsaber:

Question on collisions. Is it possible to run into a collision in such a case?

If ulong is a ticket, yes, but with a very low probability

 
Andrei Trukhanovich:

if ulong is a ticket, then yes, but with a very small probability

It's a ticket. Thank you for the information.

 
fxsaber:

Question on collisions. Is it possible to run into a collision in such a case?

If 27,000 entries have been made.

Almost impossible and if you do, access is still super efficient.

This is practically the most efficient method of addressing. At the risk of growing the access table at monstrous values.
Reason: