@@ -60,6 +60,12 @@ func csn_OpenPRN(name string) (uintptr, error) {
return ret, nil
}
+func csn_SetPort(handle uintptr) {
+ if csnDll != nil && handle != 0 {
+ csnDll.NewProc("Port_SetPort").Call(handle)
+ }
+}
+
func csn_Close(handle uintptr) {
if csnDll != nil && handle != 0 {
csnDll.NewProc("Port_ClosePort").Call(handle)
@@ -47,6 +47,7 @@ func (s *PrintService) PrintTicket(printerID uint, lotName, channelCode, plateNo
return fmt.Errorf("打开打印机失败: %w (name=%s)", err, name)
useCSN = true
+ csn_SetPort(usbHandle) // 激活端口!
defer csn_Close(usbHandle)