E:\huaihaiProject\readCard\ThCardReader\ThCardReader\bin\Debug\
├── ThCardReader.exe
├── HeaSecReadInfo.dll ← 主DLL文件
├── 其他依赖DLL文件...
└── config\
└── jiangsu_config.json
优势:
E:\huaihaiProject\readCard\ThCardReader\
├── ThCardReader.sln
├── HeaSecReadInfo.dll ← 也可以放这里
└── ThCardReader\
└── bin\Debug\ThCardReader.exe
C:\Windows\System32\HeaSecReadInfo.dll
缺点:需要管理员权限,可能影响其他程序
根据江苏医保规范,可能需要的文件包括:
文件名 | 说明 | 是否必需 |
---|---|---|
HeaSecReadInfo.dll | 江苏医保主DLL | ✅ 必需 |
config.ini | 配置文件(如果有) | ❓ 可选 |
license.dat | 授权文件(如果有) | ❓ 可选 |
文件名 | 说明 | 来源 |
---|---|---|
msvcr120.dll | Visual C++ 2013运行时 | Microsoft |
msvcp120.dll | Visual C++ 2013运行时 | Microsoft |
vcruntime140.dll | Visual C++ 2015-2019运行时 | Microsoft |
从江苏医保部门获取
验证文件完整性 ```powershell
Get-ItemProperty "HeaSecReadInfo.dll" | Select Name, Length, LastWriteTime
# 检查文件版本(如果有版本信息) Get-ItemProperty "HeaSecReadInfo.dll" | Select VersionInfo
### 第二步:部署到推荐位置
```powershell
# 复制到程序目录
Copy-Item "HeaSecReadInfo.dll" "E:\huaihaiProject\readCard\ThCardReader\ThCardReader\bin\Debug\"
# 验证复制成功
Test-Path "E:\huaihaiProject\readCard\ThCardReader\ThCardReader\bin\Debug\HeaSecReadInfo.dll"
# 给程序执行用户添加读取权限
icacls "E:\huaihaiProject\readCard\ThCardReader\ThCardReader\bin\Debug\HeaSecReadInfo.dll" /grant Users:R
在程序中添加测试代码:
// 在JiangSuSocialCardBusiness.cs中添加测试方法
public static bool TestDllExists()
{
try
{
// 尝试加载DLL
var dllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "HeaSecReadInfo.dll");
if (File.Exists(dllPath))
{
Console.WriteLine($"✅ DLL文件存在: {dllPath}");
return true;
}
else
{
Console.WriteLine($"❌ DLL文件不存在: {dllPath}");
return false;
}
}
catch (Exception ex)
{
Console.WriteLine($"❌ DLL检查异常: {ex.Message}");
return false;
}
}
ThCardReader/
├── ThCardReader.sln
├── ThCardReader/
│ ├── ThCardReader.csproj
│ ├── Program.cs
│ ├── JiangSuSocialCardBusiness.cs
│ ├── JiangSuController.cs
│ └── bin/
│ └── Debug/
│ ├── ThCardReader.exe
│ ├── ThCardReader.exe.config
│ ├── HeaSecReadInfo.dll ← 江苏医保DLL
│ ├── Newtonsoft.Json.dll
│ ├── System.Web.Http.dll
│ └── config/
│ └── jiangsu_config.json ← 配置文件
├── ThCardReaderSetup/ ← 安装包项目
└── docs/
├── 江苏医保参数申请指南.md
└── 江苏医保DLL部署指南.md
Windows系统按以下顺序查找DLL:
DllNotFoundException: 无法加载 DLL"HeaSecReadInfo.dll": 找不到指定的模块
解决方案:
System.DllNotFoundException: 无法加载 DLL 的依赖项
解决方案:
# 安装Visual C++ Redistributable
# 下载地址:https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist
System.UnauthorizedAccessException: 访问被拒绝
解决方案:
# 以管理员身份运行程序,或调整文件权限
icacls "HeaSecReadInfo.dll" /grant Everyone:F
# deploy_jiangsu_medical.ps1
param(
[string]$TargetPath = "E:\huaihaiProject\readCard\ThCardReader\ThCardReader\bin\Debug"
)
Write-Host "🚀 开始部署江苏医保DLL文件..." -ForegroundColor Green
# 1. 检查目标目录
if (-not (Test-Path $TargetPath)) {
Write-Host "❌ 目标目录不存在: $TargetPath" -ForegroundColor Red
exit 1
}
# 2. 复制DLL文件
$dllSource = ".\HeaSecReadInfo.dll"
$dllTarget = Join-Path $TargetPath "HeaSecReadInfo.dll"
if (Test-Path $dllSource) {
Copy-Item $dllSource $dllTarget -Force
Write-Host "✅ DLL文件已复制到: $dllTarget" -ForegroundColor Green
} else {
Write-Host "❌ 源DLL文件不存在: $dllSource" -ForegroundColor Red
exit 1
}
# 3. 设置权限
icacls $dllTarget /grant Users:R
# 4. 验证部署
if (Test-Path $dllTarget) {
$fileInfo = Get-ItemProperty $dllTarget
Write-Host "✅ 部署成功! 文件大小: $($fileInfo.Length) 字节" -ForegroundColor Green
Write-Host "📅 修改时间: $($fileInfo.LastWriteTime)" -ForegroundColor Yellow
} else {
Write-Host "❌ 部署失败!" -ForegroundColor Red
exit 1
}
Write-Host "🎉 江苏医保DLL部署完成!" -ForegroundColor Green
正确部署DLL文件后,配合正确的初始化参数,就可以成功使用江苏医保读卡功能了。