|
@@ -47,6 +47,19 @@ func csn_OpenUSB(name string) (uintptr, error) {
|
|
|
return ret, nil
|
|
return ret, nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func csn_OpenPRN(name string) (uintptr, error) {
|
|
|
|
|
+ if csnDll == nil {
|
|
|
|
|
+ return 0, fmt.Errorf("DLL 未加载")
|
|
|
|
|
+ }
|
|
|
|
|
+ nameBytes := append([]byte(name), 0)
|
|
|
|
|
+ ret, _, _ := csnDll.NewProc("Port_OpenPRNIO").Call(
|
|
|
|
|
+ uintptr(unsafe.Pointer(&nameBytes[0])))
|
|
|
|
|
+ if ret == 0 {
|
|
|
|
|
+ return 0, fmt.Errorf("打开 Windows 打印机失败: %s", name)
|
|
|
|
|
+ }
|
|
|
|
|
+ return ret, nil
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func csn_Close(handle uintptr) {
|
|
func csn_Close(handle uintptr) {
|
|
|
if csnDll != nil && handle != 0 {
|
|
if csnDll != nil && handle != 0 {
|
|
|
csnDll.NewProc("Port_ClosePort").Call(handle)
|
|
csnDll.NewProc("Port_ClosePort").Call(handle)
|