大家好我正在开发一款适用于Windows 7的智能卡驱动程序但是在Windows 8.1上有时会弹出一个错误“智能卡需要驱动程序不在此系统上.Pl;轻松尝试另一个智能卡或联系您的管理员。“ 还有一点我注意到智能卡驱动程序的行为在win 8.1上也有所不同。 为此,我写了一个简单的应用程序代码,我在下面提供win 7和Windows 8.1的驱动程序登录。
lReturn = SCardEstablishContext(SCARD_SCOPE_USER,
NULL,
NULL,
&hSC);
if ( SCARD_S_SUCCESS != lReturn )
message("Failed SCardEstablishContext\n");
else
{
message("context established\n");
lReturn = SCardGetCardTypeProviderName(hSC,
szCardName,
SCARD_PROVIDER_CSP,
(LPTSTR)&szProvider,
&chProvider);
if (SCARD_S_SUCCESS == lReturn)
{
BOOL fSts = TRUE;
HCRYPTPROV hProv = NULL;
message("successfully reads the provider name\n >> %S: \n",szProvider);
//
__try
{
// Acquire a Cryptographic operation context.
fSts = CryptAcquireContext(&hProv,
NULL,
szProvider,
PROV_RSA_FULL,
0);
if(!fSts)
{
message("crypt aquire context failed\n");
}
}
__finally
{
if (CryptReleaseContext(hProv,0))
{
mesage("The handle has been released.\n");
}
else
{
message("The handle could not be released.\n");
}
}
// Free memory allocated by SCardGetCardTypeProviderName.
lReturn = SCardFreeMemory(hSC, szProvider);
}
}
lReturn = SCardReleaseContext(hSC);
if(SCARD_S_SUCCESS != lReturn)
{
printf("failed in release context");
}
日志文件的链接在这里 赢7 Log for app for win 7 赢得8.1 Log for above app on win 8.1 尝试运行应用程序时记录获胜7
# CardAcquireContext : Enter
# CardAcquireContext : Exit, Return = 0x0
# CardGetProperty : Enter
# CardDataOperations.cppCardReadFile : Enter
# CardReadFile : Exit, Return : 0x0
# CardGetProperty : Exit, Return = 0x0
# CardReadFile : Enter
# CardReadFile : Exit, Return : 0x0
# CardGetProperty : Enter
# CardGetProperty : Exit, Return = 0x0
# CardGetProperty : Enter
# CardGetProperty : Exit, Return = 0x0
# CardGetProperty : Enter
# CardGetProperty : Exit, Return = 0x0
# CardReadFile : Enter // reads cmapfile
# CardReadFile : Exit, Return : 0x0
# CardGetContainerProperty : Enter
# CardGetContainerProperty : Exit, Return = 0x0
# CardGetProperty : Enter // collects the pin info
# CardGetProperty : Exit, Return = 0x0
# CardReadFile : Enter
# CardReadFile : Exit, Return : 0x0
# CardGetContainerInfo : Enter // reads public key
# CardGetContainerInfo : Exit, Return : 0x0
# CardDeleteContext : Enter
# CardDeleteContext : Exit, Return = 0x0
在Windows 8.1上,日志是....意味着没有调用删除上下文,我将释放所有资源
# CardAcquireContext : Enter
# CardAcquireContext : Exit, Return = 0x0
# CardGetProperty : Enter
# CardReadFile : Enter
# CardReadFile : Exit, Return : 0x0
# CardGetProperty : Exit, Return = 0x0
# CardReadFile : Enter // reads card config file
# CardReadFile : Exit, Return : 0x0
# CardGetProperty : Enter
# CardGetProperty : Exit, Return = 0x0
# CardGetProperty : Enter
# CardGetProperty : Exit, Return = 0x0
# CardGetProperty : Enter
# CardGetProperty : Exit, Return = 0x0
# CardReadFile : Enter // reads cmap file
# CardReadFile : Exit, Return : 0x0
# CardReadFile : Enter // reads cmap file
# CardReadFile : Exit, Return : 0x0
# CardGetContainerProperty : Enter
# CardGetContainerProperty : Exit, Return = 0x0
# CardGetProperty : Enter // reads pin info
# CardGetProperty : Exit, Return = 0x0
# CardAcquireContext : Enter
# CardAcquireContext : Exit, Return = 0x0
# CardGetProperty : Enter
# CardReadFile : Enter // reads card id
# CardReadFile : Exit, Return : 0x0
# CardGetProperty : Exit, Return = 0x0
# CardReadFile : Enter // reads card configuration
# CardReadFile : Exit, Return : 0x0
# CardGetProperty : Enter
# CardGetProperty : Exit, Return = 0x0
# CardGetProperty : Enter
# CardGetProperty : Exit, Return = 0x0
# CardGetProperty : Enter
# CardGetProperty : Exit, Return = 0x0
# CardReadFile : Enter reads cmap file
# CardReadFile : Exit, Return : 0x0
# CardReadFile : Enter
# CardReadFile : Exit, Return : 0x0
# CardGetContainerProperty : Enter
# CardGetContainerProperty : Exit, Return = 0x0
# CardGetProperty : Enter / gets pin info
# CardGetProperty : Exit, Return = 0x0
# CardReadFile : Enter // reads cmap file
# CardReadFile : Exit, Return : 0x0
# CardGetContainerInfo : Enter
# CardGetContainerInfo : Exit, Return : 0x0
如果我遗漏了什么,请告诉我