How to generate random bytes via Cryptographic Service Provider (CSP) without .NET/COM?

Is there a way to generate strong random bytes via Microsoft's Cryptographic Service Provider (CSP) without using .NET/COM? For example, using command line or some other way?

I'd like to use it in NodeJS to be more specific.

Refer to http://technet.microsoft.com/en-us/library/cc733055(v=ws.10).aspx

netsh nap client set csp name = <name> keylength = <keylength>

If this command works for you, just exec it through nodejs. (require('child_process').exec)

Yes, using the Windows API. Here is a sample C++ code:

#include "Wincrypt.h"

// ==========================================================================
HCRYPTPROV hCryptProv= NULL; // handle for a cryptographic provider context

// ==========================================================================
void DoneCrypt()
{
    ::CryptReleaseContext(hCryptProv, 0);
    hCryptProv= NULL;
}

// --------------------------------------------------------------------------
// acquire crypto context and a key ccontainer
bool InitCrypt()
{
    if (hCryptProv) // already initialized
        return true;

    if (::CryptAcquireContext(&hCryptProv        ,   // handle to the CSP
                              NULL               ,   // container name
                              NULL               ,   // use the default provider
                              PROV_RSA_FULL      ,   // provider type
                              CRYPT_VERIFYCONTEXT )) // flag values
    {
        atexit(DoneCrypt);
        return true;
    }

    REPORT(REP_ERROR, _T("CryptAcquireContext failed"));
    return false;
}

// --------------------------------------------------------------------------
// fill buffer with random data
bool RandomBuf(BYTE* pBuf, size_t nLen)
{
    if (!hCryptProv)
        if (!InitCrypt())
            return false;

    size_t nIndex= 0;

    while (nLen-nIndex)
    {
        DWORD nCount= (nLen-nIndex > (DWORD)-1) ? (DWORD)-1 : (DWORD)(nLen-nIndex);
        if (!::CryptGenRandom(hCryptProv, nCount, &pBuf[nIndex]))
        {
            REPORT(REP_ERROR, _T("CryptGenRandom failed"));
            return false;
        }

        nIndex+= nCount;
    }

    return true;
}