GetSystemCpuSetInformation function fail in i5-13600K

windwolf 0 Reputation points
2023-01-30T04:31:15.0733333+00:00

Hi there.

I'm expecting to divide P / E core index in my program.

But when I call the GetSystemCpuSetInformation, It doesn't work. The function returned FALSE.

Below is the code and envrionment

  • CPU : 13th Gen Intel(R) Core(TM) i5-13600K (14 CPUs), ~3.5GHz
  • RAM : 32768MB RAM
  • VGA : Description: NVIDIA GeForce RTX 4080
  • O/S : Windows 10 Pro 64bit, build 191206-1406
  • C++ 17
   ULONG size{ 0 };
   ::GetSystemCpuSetInformation( nullptr, 0, &size, handle, 0 );
   DWORD error{ GetLastError() };
   uint8_t* buffer = new uint8_t[ size ];
   _SYSTEM_CPU_SET_INFORMATION* cpu_info = reinterpret_cast<_SYSTEM_CPU_SET_INFORMATION*>( buffer );
   
   if ( !::GetSystemCpuSetInformation( cpu_info, size, &size, handle, 0 ) )
   {
   	SAFE_DELETE_ARRAY( buffer );
   	return false;
   }
   

Is there anything additional to do?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,422 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 81,636 Reputation points
    2023-01-30T09:11:16.29+00:00

    This works for me (Windows 10 22H2) :

                        HANDLE handle = NULL;
                        ULONG nSize = 0;
                        BOOL bRet = GetSystemCpuSetInformation(NULL, 0, &nSize, handle, 0);
                        WCHAR wsText[MAX_PATH] = L"";
                        if (!bRet)
                        {
                            int nError = GetLastError();
                            if (nError == ERROR_INSUFFICIENT_BUFFER)
                            {
                                SYSTEM_CPU_SET_INFORMATION SCSI = { sizeof SYSTEM_CPU_SET_INFORMATION };
                                bRet = GetSystemCpuSetInformation(&SCSI, nSize, &nSize, handle, 0);
                                if (!bRet)
                                {
                                    nError = GetLastError();
                                    wsprintf(wsText, L"Error : %d\r\n", nError);
                                    OutputDebugString(wsText);
                                }
                            }
                            else
                            {
                                wsprintf(wsText, L"Error : %d\r\n", nError);
                                OutputDebugString(wsText);
                            }                       
                        } 
    
    1 person found this answer helpful.
    0 comments No comments