Error 127 is 'ERROR\_PROC\_NOT\_FOUND' ('The specified procedure could not be found').

I'm running on a Windows Server 2016 running Citrix XenApp with Remote Desktop Services. The CryptAcquireContext API is in advapi32.dll. I ran Microsoft's Depends32.exe on it, and the function CryptAcquireContextA and CryptAcquireContextW are *definitely* in the DLL file. Same error seems to happen with all the crypto api functions. I tested CryptDestroyHash and it also returns an error of 127 (ERROR\_PROC\_NOT\_FOUND).

Here is my C++ code:

```
    HCRYPTPROV hProv = 0;
    BOOL bCryptAcquireContext = CryptAcquireContext(&hProv, NULL, MS_ENH_RSA_AES_PROV, PROV_RSA_AES, 0);
    dwError = GetLastError();

```

This C++ does work in an EXE, but if the same code is put into a DLL that is called from VB6, it does not work. It's almost like any vb6 app is blocked from those APIs?

Here is the VB6 code:

```
Private Declare Function CryptAcquireContext Lib "advapi32.dll" Alias "CryptAcquireContextA" (ByRef phProv As Long, ByVal pszContainer As String, ByVal pszProvider As String, ByVal dwProvType As Long, ByVal dwFlags As Long) As Long
Private Sub Form_Load()
    Dim sProvider As String
    Dim rv as Long
    Dim sContainer As String
    Dim m_lProvider As Long
    Const PROV_RSA_FULL = 1
    Const CRYPT_VERIFYCONTEXT  As Long = &HF0000000
    Const MS_DEF_PROV As String = "Microsoft Base Cryptographic Provider v1.0"
    sProvider = MS_DEF_PROV & vbNullChar
    sContainer = vbNullChar
    rv = CryptAcquireContext(m_lProvider, 0, MS_ENH_RSA_AES_PROV, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)
    dwError = Err.LastDllError

    If rv = 0 and dwError <> 127 Then
        rv = CryptAcquireContext(m_lProvider, 0&, ByVal sProvider, PROV_RSA_FULL, CRYPT_NEWKEYSET)
    End If
End Sub

```