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.

40 lines
873 B
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 {
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))
}