if i have a cert("*.cer") which matches x.509 standard to save my public key ,i d like to use rsa to encrypt my data,how can i do? may u give me some examples or sources?

in winapi help ,CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, 0), always return an error , and if it is true, which para to put my cert(or public key) ?

the winapi help:-- it is to used to sign , it send error message at "step1"


HCRYPTPROV hProv = 0;
BYTE pbData[1000];
DWORD dwDataLen;

// Get handle to the default PROV_RSA_FULL provider.
if(!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, 0)) {
//step1
printf(" Error %x during CryptAcquireContext!\n", GetLastError());
return;
}

// Read the name of the default CSP.
dwDataLen = 1000;
if(!CryptGetProvParam(hProv, PP_NAME, pbData, &dwDataLen, 0)) {
printf("Error %x reading CSP name!\n", GetLastError());

return;
}
printf("Provider name:%s\n", pbData);

// Read the name of the default key container.
dwDataLen = 1000;
if(!CryptGetProvParam(hProv, PP_CONTAINER, pbData, &dwDataLen, 0)) {
printf("Error %x reading key container name!\n", GetLastError());
return;
}
printf("Key Container name:%s\n", pbData);

// Perform cryptographic operations.
...

// Release provider handle.
if(!CryptReleaseContext(hProv, 0)) {
printf("Error %x during CryptReleaseContext!\n", GetLastError());

return;
}