You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
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 {
|
|
return DDEGetMessage(hData)
|
|
}
|
|
}
|
|
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))
|
|
}
|
|
func DDESendMessage(Inst DWORD, Src string, Item HSZ, Fmt UINT) HDDEDATA {
|
|
cs := C.CString(Src)
|
|
hdata := ddeml.DdeCreateDataHandle(Inst, (*BYTE)(unsafe.Pointer(cs)), DWORD(len(Src)+1), 0, Item, Fmt, 0)
|
|
C.free(unsafe.Pointer(cs))
|
|
return hdata
|
|
}
|
|
func DDEGetMessage(hData HDDEDATA) string {
|
|
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)
|
|
}
|