csx 4 lat temu
rodzic
commit
5f8d07171d
1 zmienionych plików z 10 dodań i 18 usunięć
  1. 10 18
      controllers/his_api_controller.go

+ 10 - 18
controllers/his_api_controller.go Wyświetl plik

@@ -346,34 +346,26 @@ func GetBasBaseInfo() (jsonStr string, err error) {
346 346
 	handle := syscall.NewLazyDLL("SSCard.dll")
347 347
 	ReadCardBas := handle.NewProc("ReadCardBas")
348 348
 
349
-	str5 := ""
350
-	str6 := ""
351
-
352 349
 	str := make([]byte, 256)
353 350
 	str1 := make([]byte, 256)
354
-	str3 := make([]byte, 256)
355
-	str4 := make([]byte, 256)
356 351
 
357 352
 	//sssssswwwww
358 353
 	//a := 256
359 354
 
360 355
 	r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), 1024, (uintptr)(unsafe.Pointer(&str1[0])), 1024)
361 356
 
362
-	str3 = str
363
-	str4 = str1
364
-	fmt.Println(str3)
365
-	fmt.Println(str4)
366
-	fmt.Println(r)
357
+	p := (*byte)(unsafe.Pointer(r))
358
+	// define a slice to fill with the p string
359
+	data := make([]byte, 0)
367 360
 
368
-	fmt.Println(str5)
369
-	fmt.Println(str6)
361
+	// loop until find '\0'
362
+	for *p != 0 {
363
+		data = append(data, *p)        // append 1 byte
364
+		r += unsafe.Sizeof(byte(0))    // move r to next byte
365
+		p = (*byte)(unsafe.Pointer(r)) // get the byte value
366
+	}
370 367
 
371
-	str1 = nil
372
-	str3 = nil
373
-	//a = 0
374
-	ReadCardBas = nil
375
-	handle = nil
376
-	return string(str3), nil
368
+	return string(data), nil
377 369
 }
378 370
 
379 371
 //func GetSFZBaseInfo() (jsonStr string, err error) {