I was reading the great SO post about how to determine the size and other information of cache memory: Programmatically get the cache line size?
I wrote the following program to find out these information on Windows platform:
#include<Windows.h>
int main() 
{
    BOOL retval;
    SYSTEM_LOGICAL_PROCESSOR_INFORMATION *buffer = 0;
    int buffersize = 0;
    retval = GetLogicalProcessorInformation(buffer,(PDWORD)&buffersize);    
    if(retval == FALSE) 
    {
        DWORD ret = GetLastError();
        if(ret == ERROR_INSUFFICIENT_BUFFER) 
        {
            // Use the actual length required information while allocating the memory
            char* tmp = new char[buffersize];
            buffer = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION *)tmp;
            retval = GetLogicalProcessorInformation(buffer,(PDWORD)&buffersize);
            CACHE_DESCRIPTOR x;
            if(retval == TRUE) 
            {
                x = buffer->Cache;
            }
            delete [] tmp;
        }
    }
    return 0;
}
However while running/debugging the program I am not getting all information about cache(except the level of cache and its type). Below is the output of variable x
x.Level = 1
x.Associativity = 0
x.LineSize = 0
x.Size = 0
x.Type = CacheUnified
Why above program does not give the LineSize and Size information about this cache? Am I doing something wrong over here?. Is there another way to find out these information programmatically on Windows platform?.
My Platform information is:
Windows 7
64 Bit Operating System
Intel i5 CPU
Visual Studio 2010
 
     
    