获得类型为PROV_RSA_FULL的默认CSP类型
来源:互联网 发布:unity3d室内灯光开关 编辑:程序博客网 时间:2024/05/17 07:10
#include <stdio.h>#include <stdlib.h>#include <windows.h>#include "eboy_wincrypt.h"void main(){//--------------------------------------------------------------------// Declare and initialize variables.//---------------------------------------------------------------DWORD cbProvName;LPTSTR pbProvName;// Get the length of the RSA_FULL default provider name.if (!(CryptGetDefaultProvider( PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT, NULL, &cbProvName))) { printf("Error getting the length of the default provider name."); exit(1);}//---------------------------------------------------------------// Allocate local memory for the name of the default provider.if (!(pbProvName = (LPTSTR)LocalAlloc(LMEM_ZEROINIT, cbProvName))){printf("Error during memory allocation for provider name.");exit(1);}//---------------------------------------------------------------// Get the default provider name.if (CryptGetDefaultProvider(PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT,pbProvName,&cbProvName)) {printf("The default provider name is %s\n\n",pbProvName);}else{printf("Getting the name of the provider failed.");exit(1);}LocalFree(pbProvName);}