csx 4 gadus atpakaļ
vecāks
revīzija
6055b29435
1 mainītis faili ar 28 papildinājumiem un 35 dzēšanām
  1. 28 35
      controllers/his_api_controller.go

+ 28 - 35
controllers/his_api_controller.go Parādīt failu

@@ -14,7 +14,6 @@ import (
14 14
 	"github.com/shopspring/decimal"
15 15
 	"io"
16 16
 	"io/ioutil"
17
-	"log"
18 17
 	"math/rand"
19 18
 	"net/http"
20 19
 	"os"
@@ -344,30 +343,24 @@ func (c *HisApiController) Sscard() {
344 343
 		}
345 344
 	}
346 345
 }
346
+func StrPtr2(s string) uintptr {
347
+	return uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s)))
348
+}
349
+
347 350
 func GetBasBaseInfo() (jsonStr string, err error) {
348 351
 	//handle := syscall.MustLoadDLL("SSCard.dll")
352
+	fmt.Println(ReadCardBas)
353
+	h := syscall.NewLazyDLL("SSCard.dll")
354
+	proc := h.NewProc("ReadCardBas")
349 355
 
350
-	h, e := syscall.LoadLibrary("SSCard.dll") //Make sure this DLL follows Golang machine bit architecture (64-bit in my case)
351
-	if e != nil {
352
-		log.Fatal(e)
353
-	}
354
-	defer syscall.FreeLibrary(h)
355
-	proc, e := syscall.GetProcAddress(h, "ReadCardBas") //One of the functions in the DLL
356
-	if e != nil {
357
-		log.Fatal(e)
358
-	}
356
+	str := ""
357
+	str1 := ""
358
+	r, _, _ := proc.Call(StrPtr2(str), IntPtr(1024), StrPtr2(str1), IntPtr(1024))
359 359
 
360
-	n, _, _ := syscall.Syscall9(uintptr(proc), 0, 2, 2, 2, 2, 0, 0, 0, 0, 0) //Pay attention to the positioning of the parameter
361
-	fmt.Printf("Hello dll function returns %d\n", n)
360
+	fmt.Println(r)
361
+	fmt.Println(str)
362 362
 
363
-	//str := make([]byte, 1024)
364
-	//str1 := make([]byte, 1024)
365
-	//r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(0), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(0))
366
-	//
367
-	//fmt.Println(r)
368
-	//fmt.Println(string(str))
369
-	//
370
-	return "112222", nil
363
+	return "", nil
371 364
 }
372 365
 
373 366
 func GetSFZBaseInfo() (jsonStr string, err error) {
@@ -2710,18 +2703,18 @@ func RemoveRepeatedCode(arr []string) (newArr []string) {
2710 2703
 	return
2711 2704
 }
2712 2705
 
2713
-func ShowMessage1(caption, text string, style uintptr) (result int) {
2714
-	user32, _ := syscall.LoadLibrary("SSCard.dll")
2715
-	messageBox, _ := syscall.GetProcAddress(user32, "MessageBoxW")
2716
-	defer syscall.FreeLibrary(user32)
2717
-
2718
-	ret, _, _ := syscall.Syscall9(messageBox,
2719
-		4,
2720
-		0,
2721
-		StrPtr(text),
2722
-		StrPtr(caption),
2723
-		style,
2724
-		0, 0, 0, 0, 0)
2725
-	result = int(ret)
2726
-	return
2727
-}
2706
+//func ShowMessage1(caption, text string, style uintptr) (result int) {
2707
+//	user32, _ := syscall.LoadLibrary("SSCard.dll")
2708
+//	messageBox, _ := syscall.GetProcAddress(user32, "MessageBoxW")
2709
+//	defer syscall.FreeLibrary(user32)
2710
+//
2711
+//	ret, _, _ := syscall.Syscall9(messageBox,
2712
+//		4,
2713
+//		0,
2714
+//		StrPtr(text),
2715
+//		StrPtr(caption),
2716
+//		style,
2717
+//		0, 0, 0, 0, 0)
2718
+//	result = int(ret)
2719
+//	return
2720
+//}