Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma comment(lib, "crypt32.lib")
- #include <stdio.h>
- #include <tchar.h>
- #include <windows.h>
- #include <wincrypt.h>
- #include <iostream>
- void MyHandleError(TCHAR* s);
- void Wait(TCHAR* s);
- int _tmain(int argc, _TCHAR* argv[])
- {
- // Declare and initialize variables.
- LPTSTR pszName;
- DWORD dwType;
- DWORD cbName;
- DWORD dwIndex = 0;
- LPTSTR pbProvName;
- DWORD cbProvName;
- //--------------------------------------------------------------
- // Print header lines for providers.
- _tprintf(TEXT("\n\nListing Available Providers.\n"));
- _tprintf(TEXT("Provider type Provider Name\n"));
- _tprintf(TEXT("_____________ ")
- TEXT("_____________________________________\n"));
- //---------------------------------------------------------------
- // Loop through enumerating providers.
- dwIndex = 0;
- while (CryptEnumProviders(
- dwIndex,
- nullptr,
- 0,
- &dwType,
- nullptr,
- &cbName))
- {
- //-----------------------------------------------------------
- // cbName is the length of the name of the next provider.
- // Allocate memory in a buffer to retrieve that name.
- if (!(pszName = static_cast<LPTSTR>(LocalAlloc(LMEM_ZEROINIT, cbName))))
- {
- //MyHandleError(TEXT("ERROR - LocalAlloc failed!"));
- _tprintf(TEXT("ccc.\n"));
- }
- //-----------------------------------------------------------
- // Get the provider name.
- if (CryptEnumProviders(
- dwIndex++,
- nullptr,
- 0,
- &dwType,
- pszName,
- &cbName))
- {
- /* _tprintf(TEXT(" %4.0d %s\n"),
- dwType,
- pszName);*/
- std::wcout << dwType << " " << pszName << "\n";
- }
- else
- {
- ///MyHandleError(TEXT("ERROR - CryptEnumProviders"));
- _tprintf(TEXT("ddd.\n"));
- }
- LocalFree(pszName);
- } // End while loop.
- //---------------------------------------------------------------
- // Get the name of the default CSP specified for the
- // PROV_RSA_FULL type for the computer.
- } // End main.
- void MyHandleError(TCHAR* s)
- {
- _tprintf(TEXT("An error occurred in running the program.\n"));
- _tprintf(TEXT("%s\n"), s);
- _tprintf(TEXT("Error number %x\n."), GetLastError());
- _tprintf(TEXT("Program terminating.\n"));
- exit(1);
- }
- void Wait(TCHAR* s)
- {
- char x;
- _tprintf(s);
- x = getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement