修改客户端实现完成
parent
e3258516ed
commit
d6deeebed3
@ -0,0 +1,39 @@
|
||||
package dde
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
ddeml "go-dde/ddeml"
|
||||
. "go-dde/types"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
MAX_BUFFER_SIZE = 16
|
||||
)
|
||||
|
||||
func DDERequest(idInst DWORD, hConv HCONV, hszItem HSZ, sDesc string) string {
|
||||
hData := ddeml.DdeClientTransaction(nil, 0, hConv, hszItem, UINT(CF_TEXT),
|
||||
UINT(XTYP_REQUEST), 5000, nil)
|
||||
if hData == 0 {
|
||||
return "Request failed"
|
||||
} else {
|
||||
size := ddeml.DdeGetData(hData, nil, 0, 0)
|
||||
var str BYTE
|
||||
ddeml.DdeGetData(hData, &str, size, 0)
|
||||
buffer := (*[MAX_BUFFER_SIZE]byte)(unsafe.Pointer(&str))[:size-1]
|
||||
return string(buffer)
|
||||
}
|
||||
}
|
||||
func DDEPoke(idInst DWORD, hConv HCONV, hszItem HSZ, szData string) {
|
||||
cs := C.CString(szData)
|
||||
ddeml.DdeClientTransaction((*BYTE)(unsafe.Pointer(cs)),
|
||||
DWORD(len(szData)+1),
|
||||
hConv, hszItem, UINT(CF_TEXT),
|
||||
UINT(XTYP_POKE), 3000, nil)
|
||||
C.free(unsafe.Pointer(cs))
|
||||
}
|
Loading…
Reference in New Issue