first commit

This commit is contained in:
huxuejian 2026-10-19 18:08:35 +08:00
commit f9e8058931
264 changed files with 2381 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/build/
/dist/
/logs/

18
CMakeLists.txt Normal file
View File

@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.12)
project(readcard_c LANGUAGES C CXX)
# Build with: cmake -A Win32 -T v141 ..
# This project targets 32-bit Windows 7 SP1 and later, subject to the vendor
# device drivers and their installed dependencies.
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(readcard-c WIN32 src/main.cpp src/qrcodegen.c)
target_compile_definitions(readcard-c PRIVATE UNICODE _UNICODE WIN32_LEAN_AND_MEAN)
target_link_libraries(readcard-c PRIVATE ws2_32 comctl32)
if(MSVC)
target_compile_options(readcard-c PRIVATE /W4 /permissive- /utf-8 /MT)
# target_link_options was added after the CMake bundled with VS2017.
set_property(TARGET readcard-c APPEND_STRING PROPERTY LINK_FLAGS " /SUBSYSTEM:WINDOWS,6.01")
endif()

33
README.md Normal file
View File

@ -0,0 +1,33 @@
# readcard-c
面向旧版 Windows 的原生 C++/Win32 本地读卡与医保电子凭证程序。程序必须构建为 **Win32/x86**,因为 `CardReaderDLL.dll` 与 `NationECCode.dll` 均为 32 位 DLL。
## Windows 兼容性
项目使用 Win32 API 和静态链接 MSVC 运行时。建议用 Visual Studio 2017 的 `v141_xp` 工具集构建,目标为 Windows XP SP3 及以上;实际下限还取决于读卡器、扫码墩驱动及医保厂商 DLL 的支持范围。
```powershell
cmake -S . -B build -A Win32 -T v141_xp
cmake --build build --config Release
```
也可双击 `一键打包.bat`。若直接运行 `build.ps1`,请在 PowerShell 中执行 `./build.ps1`,而不是在资源管理器中双击 `.ps1` 文件。
将以下内容一起发布:
```text
readcard-c.exe
config.json
package/DWCardReaderDLL/
package/EMICDLL/
```
## GUI 与后续接口
当前首版已实现 Win32 GUI、两套 DLL 的加载、医保扫码墩输入到 `NationEcTrans` 的调用、电子凭证解析展示,以及逐步骤日志。医保电子凭证按钮会把焦点交给隐藏的扫码输入框;扫码墩输入完成并发送回车后,程序通过 `NationEcTrans` 调用医保 DLL,并显示姓名、证件号、`ecToken`。
旧项目的本地 HTTP 接口(`/health`、`/api/card/read-nopin`、`/api/card/read`、`/api/hmac-sm3`、`/api/emic/scan`)应作为下一阶段迁移到本项目;在未完成前,PC 前端仍应继续调用旧的 `readcard-go` 服务。
## 逐步骤日志
`operation_trace_enabled` 控制流程日志,开发期默认为 `true`。`operation_trace_include_sensitive` 控制是否记录姓名、身份证号、卡号、医保码和 `ecToken`,开发期默认为 `true`,正式环境应设为 `false`。日志写入 `logs/operation-YYYYMMDD.log`。

75
build.ps1 Normal file
View File

@ -0,0 +1,75 @@
param([string]$Configuration = "Release")
$ErrorActionPreference = "Stop"
$Root = $PSScriptRoot
$Build = Join-Path -Path $Root -ChildPath "build"
$Dist = Join-Path -Path $Root -ChildPath "dist"
$MSBuild = "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe"
$VCVars = "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat"
$CMakeCommand = Get-Command cmake -ErrorAction SilentlyContinue
if ($CMakeCommand) {
$CMake = $CMakeCommand.Source
} else {
$VsCMake = "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
if (-not (Test-Path -LiteralPath $VsCMake)) {
throw "CMake was not found. Install Visual Studio C++ Desktop Development and CMake."
}
$CMake = $VsCMake
}
if (-not (Test-Path -LiteralPath $MSBuild)) {
throw "Visual Studio 2017 MSBuild was not found. Install the Visual C++ Build Tools workload."
}
$env:Path = (Split-Path -Parent $MSBuild) + ";" + $env:Path
if (-not (Test-Path -LiteralPath $VCVars)) {
throw "Visual Studio 2017 C++ environment setup was not found. Install the Visual C++ Build Tools workload."
}
# Import the x86 compiler, SDK, include, and library paths into this PowerShell process.
$VCVarsCommand = 'call "' + $VCVars + '" x86 >nul && set'
cmd.exe /c $VCVarsCommand | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') {
Set-Item -Path ("env:" + $matches[1]) -Value $matches[2]
}
}
$UcrtLib = "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.26100.0\ucrt\x86"
if (Test-Path -LiteralPath $UcrtLib) {
$env:LIB = $env:LIB + ";" + $UcrtLib
}
# VS2017's bundled CMake predates the -S/-B flags, so configure from build/.
# Build a 32-bit v141 application. v141 is the appropriate target for
# Windows 7; the optional v141_xp toolset requires an obsolete XP SDK and
# prevents CMake's compiler probe from locating the modern UCRT libraries.
New-Item -ItemType Directory -Force -Path $Build | Out-Null
$Cache = Join-Path -Path $Build -ChildPath "CMakeCache.txt"
if ((Test-Path -LiteralPath $Cache) -and ((Select-String -LiteralPath $Cache -Pattern 'CMAKE_CXX_COMPILER:FILEPATH=CMAKE_CXX_COMPILER-NOTFOUND' -Quiet) -or (Test-Path -LiteralPath (Join-Path -Path $Build -ChildPath "CMakeFiles\CMakeError.log")))) {
Remove-Item -LiteralPath $Cache -Force
$CMakeFiles = Join-Path -Path $Build -ChildPath "CMakeFiles"
if (Test-Path -LiteralPath $CMakeFiles) { Remove-Item -LiteralPath $CMakeFiles -Recurse -Force }
}
Push-Location $Build
try {
# Force static CRT even for CMake's Debug compiler probe.
& $CMake -G "Visual Studio 15 2017" -A Win32 -T v141 ("-DCMAKE_MAKE_PROGRAM=" + $MSBuild) "-DCMAKE_C_FLAGS_DEBUG=/MTd" "-DCMAKE_CXX_FLAGS_DEBUG=/MTd" $Root
if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed." }
& $CMake --build . --config $Configuration
if ($LASTEXITCODE -ne 0) { throw "CMake build failed." }
} finally {
Pop-Location
}
New-Item -ItemType Directory -Force -Path $Dist | Out-Null
$ConfigurationDir = Join-Path -Path $Build -ChildPath $Configuration
$Binary = Join-Path -Path $ConfigurationDir -ChildPath "readcard-c.exe"
if (-not (Test-Path -LiteralPath $Binary)) {
throw "Build output was not found: $Binary"
}
$ExeDestination = Join-Path -Path $Dist -ChildPath "readcard-c.exe"
$ConfigSource = Join-Path -Path $Root -ChildPath "config.json"
$ConfigDestination = Join-Path -Path $Dist -ChildPath "config.json"
$PackageSource = Join-Path -Path $Root -ChildPath "package"
$PackageDestination = Join-Path -Path $Dist -ChildPath "package"
Copy-Item -LiteralPath $Binary -Destination $ExeDestination -Force
Copy-Item -LiteralPath $ConfigSource -Destination $ConfigDestination -Force
Copy-Item -LiteralPath $PackageSource -Destination $PackageDestination -Recurse -Force
Write-Host "Build completed: $Dist"

17
config.json Normal file
View File

@ -0,0 +1,17 @@
{
"host": "127.0.0.1",
"port": 17880,
"card_dll_dir": "package/DWCardReaderDLL",
"gui_reader_type": "ZJ_HZ_310000",
"emic_dll": "package/EMICDLL/NationECCode.dll",
"emic_url": "http://10.249.81.107/localcfc/api/hsecfc/localQrCodeQuery",
"emic_org_id": "H33048100004",
"emic_business_type": "01101",
"emic_operator_id": "admin",
"emic_operator_name": "administrator",
"emic_office_id": "D99",
"emic_office_name": "其他科室",
"operation_trace_enabled": true,
"operation_trace_include_sensitive": true,
"log_dir": "logs"
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,2 @@
--------------------------begin iReadCardBas_YT shanghai test

View File

@ -0,0 +1,29 @@
;-------------------------------------------------------------------------------------
;
; Version: V1.0
;
;-------------------------------------------------------------------------------------
[KEYBOARD]
;#-------------------------------------------------------------------------------------
;是否启用外部密码键盘库(公共库)
;TRUE表示启用,此时密码键盘输入受外部键盘库控制,EnableUSBKB值无效、EnablePS2KB值无效
;FALSE表示不启用
;-------------------------------------------------------------------------------------#
EnableExtKBLib=FALSE
;#-------------------------------------------------------------------------------------
;#是否启用PS2标准密码键盘
;#TRUE表示启用,此时EnableExtKBLib值无效(优先校验EnableExtKBLib)、EnableUSBKB值无效
;#FALSE表示不启用
;-------------------------------------------------------------------------------------#
EnablePS2KB=FALSE
;#-------------------------------------------------------------------------------------
;#是否启用USB通讯的密码键盘
;#TRUE表示启用
;#FALSE表示不启用
;-------------------------------------------------------------------------------------#
EnableUSBKB=TRUE

View File

@ -0,0 +1,17 @@
//加密机服务地址配置,只支持通过跳转IP和端口跳转至省厅加密机服务,默认为省厅加密机服务的地址
//杭州市加密机服务地址默认为省人社卡管系统加密机地址
[Server]
;是否启用加密机读卡模式,1为启用,0为不启用,杭州默认为启用
HSM=1
;加密机服务IP
HostName=172.16.69.3
;加密机服务端口
Port=9006
//读卡器轮询配置
[device]
;是否轮询查找读卡器,0为轮询查找,其他值为固定某类读卡器,默认为轮询模式
;0 轮询;1 明华;2 德卡;3 网新;4 顺嘉;5 明泰
search=0

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
LANDI_SSCardDriver
#串口设定 串口为1-9
COM=4

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,11 @@
[TERMINF]
#SAM卡槽
SAM=1
#端口
USBPORT=1
#加密机服务器地址
URL=http://10.87.0.72:9006/WebServiceTz/services/callBusiness

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,21 @@
[SET]
Flag = 1
SamNad_V1 = 17|18|19|20
SamNad_V2 = 17|18|19|20
SamNad_V3 = 17|18|19|20
LogFile = 4
LogDir = ""
LogLife = 1
RetPIN = 0
DevLmtType=0
[READER]
ReaderType =4
Try = "1|4"
[KEYPAD]
KeyPadType =108
Try = "110|101|105"
[FILEAUTH]
Label=32
SSSE32_TSD=F4_MDS
SSSE32_TSU=SSSE32.dll
TSW_KS=panny_dl.dll

Binary file not shown.

View File

@ -0,0 +1,9 @@
[SET]
Flag = 1
LogFile = 4
LogDir = ""
LogLife = 1

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,6 @@
[SET]
URL = "http://10.87.0.72:9006/WebServiceTz/services/callBusiness"
PKeyNo = 1
PKey = "F88041389C13DD075FAC5F2DDCE86AF8"
KLevel = 2
Location = 1

View File

@ -0,0 +1,19 @@
[SET]
SamNad_V1 = 17
SamNad_V2 = 17
SamNad_V3 = 17
LogFile = 3
LogDir = ""
LogLife = 1
VPINBEFCPIN = 1
FilePath_SSSE = 1
[READER]
ReaderType = 6
Try = "1|6"
[KEYPAD]
KeyPadType =105
Try = ""

Binary file not shown.

View File

@ -0,0 +1,29 @@
;-------------------------------------------------------------------------------------
;
; Version: V1.0
;
;-------------------------------------------------------------------------------------
[KEYBOARD]
;#-------------------------------------------------------------------------------------
;是否启用外部密码键盘库(公共库)
;TRUE表示启用,此时密码键盘输入受外部键盘库控制,EnableUSBKB值无效、EnablePS2KB值无效
;FALSE表示不启用
;-------------------------------------------------------------------------------------#
EnableExtKBLib=FALSE
;#-------------------------------------------------------------------------------------
;#是否启用PS2标准密码键盘
;#TRUE表示启用,此时EnableExtKBLib值无效(优先校验EnableExtKBLib)、EnableUSBKB值无效
;#FALSE表示不启用
;-------------------------------------------------------------------------------------#
EnablePS2KB=FALSE
;#-------------------------------------------------------------------------------------
;#是否启用USB通讯的密码键盘
;#TRUE表示启用
;#FALSE表示不启用
;-------------------------------------------------------------------------------------#
EnableUSBKB=TRUE

Binary file not shown.

View File

@ -0,0 +1,15 @@
//加密机服务地址配置,只支持通过跳转IP和端口跳转至省厅加密机服务,默认为省厅加密机服务的地址
[Server]
;是否启用加密机读卡模式,1为启用,0为不启用,湖州默认为启用
HSM=1
;加密机服务IP
HostName=10.87.0.72
;加密机服务端口
Port=9006
//读卡器轮询配置
[device]
;是否轮询查找读卡器,0为轮询查找,其他值为固定某类读卡器,默认为轮询模式
;0 轮询;1 联迪;2 明华;3 网新;4 明泰;5 德生;6 华大;7 顺嘉;8 德卡;9 捷宇星
search=0

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
LANDI_SSCardDriver
#串口设定 串口为1-9
COM=4

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More