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
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
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?
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);
}
}