golang 共享内存 用Qt怎么去读取:
例如:用golang :共享的内存
package main
import (
"fmt"
"log"
"os"
"os/signal"
"sync"
"syscall"
"time"
"unsafe"
)
func main() {
file, _ := syscall.UTF16PtrFromString("ShareMemory")
size := 100000 // I’ve tried unsafe.Sizeof(MumbleData{}) but that didn’t work.
handle, err := syscall.CreateFileMapping(0, nil, syscall.PAGE_READWRITE, 0, uint32(size), file)
if err != nil {
log.Fatal(err)
}
defer syscall.CloseHandle(handle)
addr, err := syscall.MapViewOfFile(handle, syscall.FILE_MAP_WRITE, 0, 0, 0)
if err != nil {
log.Fatal(err)
}
var str string = `{"aaaa":"bbbb","cccccc":"ddddddd"}`
data := (*[1024]byte)(unsafe.Pointer(addr))
for i, v := range str {
data[i] = byte(v)
}
time.Sleep(1 * time.Second)
fmt.Println("str: ", string(data[:]))
for {
}
}
怎么使用QT 去读取出来golang共享数据 如果使用
QSharedMemory sharememory("ShareMemory") 根本就读取不到。要怎么样才能 使用 qt把共享内存数据读取出来。