I am having trouble reading uint ARRAYS properties from WMI objects. I can read and process STRING properties from WMI objects.

Have you read this article?

i need c++ code
not using .net

How about this article?

not using .net

AFAIK WMI is .NET

Maybe this example will be of some help to you...

#include <windows.h>
#include <tchar.h>
#include <stdio.h>

#define _WIN32_DCOM
#include <iostream>
using namespace std;
#include <comdef.h>
#include <Wbemidl.h>
# pragma comment(lib, "wbemuuid.lib")

int _tmain(int argc, _TCHAR* argv[])
{
    CoInitialize(NULL);
    {
        VARIANTARG *pVals;
        SAFEARRAYBOUND rgsabound;
        rgsabound.lLbound = 0;
        rgsabound.cElements = 4;

        SAFEARRAY* psaValues = SafeArrayCreate( VT_VARIANT, 1, &rgsabound);
        UINT bSampe[4] = {9,2,3,4};
        SafeArrayLock(psaValues);
        VARIANT *pDescriptorData = (VARIANT *)psaValues->pvData;

        for( LONG i = 0; i < 4; ++i )
        {
            VariantClear(&pDescriptorData[i]);
            pDescriptorData[i].vt = VT_UI1; //value of a VT_UI1 type property MUST be a 1-byte unsigned integer.
            pDescriptorData[i].bVal = bSampe[i];
            SafeArrayPutElement(psaValues,&i,&pDescriptorData);
        }
        SafeArrayUnlock(psaValues);

        HRESULT hr = SafeArrayAccessData(psaValues, (void HUGEP* FAR*)&pVals); // direct access to SA memory
        if (SUCCEEDED(hr))
        {
            long lowerBound, upperBound;  // get array bounds
            SafeArrayGetLBound(psaValues, 1 , &lowerBound);
            SafeArrayGetUBound(psaValues, 1, &upperBound);
            long cnt_elements = upperBound - lowerBound + 1; 
            for (int i = 0; i < cnt_elements; ++i)  // iterate through returned values
            {                              
                std::cout << "element " << i << ": value = " <<  pVals[i].uiVal << std::endl;
            }       
            SafeArrayUnaccessData(psaValues);   
        }   
        ::CoUninitialize();
    }
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.