Platform SDK: Certificate Enrollment Control |
The enumProviders method enumerates all providers available on the computer for the specified ProviderType property. If that property has not been changed, then it has a default value of one, as set in the registry. This means PROV_RSA_FULL for the default Microsoft Base Cryptographic Provider is used for the enumeration.
[Visual Basic] objEnroll.enumProviders( _ dwIndex As Long, _ dwFlags As Long ) As String [C++] HRESULT enumProviders ( DWORD dwIndex, // in DWORD dwFlags, // in BSTR *pbstrProvName // out );
[Visual Basic] The return value is a String variable representing the name of the provider being enumerated. An exception is raised if an error is encountered or when there are no more items remaining in the enumeration sequence.
[C++] The return value is an HRESULT. A value of S_OK indicates success. Upon successful completion of this function, pbstrProviderName will contain the name of the enumerated provider. When there are no more providers, the value ERROR_NO_MORE_ITEMS is returned.
BSTR bstrProvName = NULL; DWORD dwType, nProv; int j; HRESULT hr; // array of CSP provider types (see wincrypt.h) DWORD nProvType[] = { PROV_RSA_FULL, PROV_RSA_SIG, // list shortened for brevity //... PROV_STT_ISS }; // Loop, for each Prov Type for ( j = 0; j < ( sizeof( nProvType ) / sizeof( DWORD ) ); j++ ) { nProv = 0; // check specific prov type dwType = nProvType[j]; // pEnroll is previously instantiated ICEnroll interface pointer hr = pEnroll->put_ProviderType( dwType ); if ( FAILED(hr)) { printf("Failed put_ProviderType - %x\n", hr); goto error; } // enumerate the CSPs of this type while ( S_OK == ( hr = pEnroll->enumProviders(nProv, 0, &bstrProvName))) { printf("Provider %ws (type %d )\n", bstrProvName, dwType ); // increment the index nProv++; // Free this string, so it can be re-used. if ( NULL != bstrProvName ) { SysFreeString( bstrProvName ); bstrProvName = NULL; } } // Print message if provider type doesn't have any CSPs. if ( 0 == nProv ) printf("There were no CSPs of type %d\n", dwType ); } error: // Clean up resources, etc. if ( NULL != pEnroll ) pEnroll->Release(); if ( NULL != bstrProvName ) SysFreeString( bstrProvName ); CoUninitialize();
Dim strOut As String Dim i As Integer Dim NoMoreRecs As Boolean ' enumerate the providers i = 0 NoMoreRecs = False On Error GoTo ErrorHandler Do strOut = objEnroll.enumProviders(i, 0) If NoMoreRecs Then Exit Do End If ' display the index and Provider value MsgBox (i & " " & strOut) i = i + 1 Loop Exit Sub ErrorHandler: NoMoreRecs = True Resume Next End Sub
Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with the Windows NT 4.0 Option Pack).
Header: Declared in Xenroll.h.
Library: Use Uuid.lib.