Sha256: 8a6a425c1f5073261695959c51ac4efce1f65b06b3c4d5a809c8e4737d3dfff1

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# Quick and dirty DDE Server (for experimentation)

require 'win/gui/message'
include Win::GUI::Message

#require_relative 'exp_lib'
#include DdeLib

require 'win/dde'
include Win::Dde

calls = []
buffer = FFI::MemoryPointer.new(:long).write_long(0)
buffer.address

callback = lambda do |*args|
  calls << [*args]
  puts "#{Time.now.strftime('%T.%6N')} #{args.map{|e|e.respond_to?(:address) ? e.address : (Win::Dde::TYPES[e] || e)}}"
  args.first == XTYP_CONNECT ? 1 : DDE_FACK
end

status = DdeInitialize(buffer, callback, APPCLASS_STANDARD, 0)
id = buffer.read_long

service = FFI::MemoryPointer.from_string('test_service')

p handle = DdeCreateStringHandle(id, service, CP_WINANSI)

p DdeNameService(id, handle, 0, DNS_REGISTER)

#p DdeDisconnect(conv_handle)

msg = Msg.new  # pointer to Msg FFI struct

# Starting message loop (necessary for DDE processing)
puts "Starting message loop\n"
while msg = get_message()
  translate_message(msg)
  dispatch_message(msg)
end

p calls.map{|c| c.map{|e|e.respond_to?(:address) ? e.address : (Win::Dde::TYPES[e] || e)}}

p Win::Dde::ERRORS[DdeGetLastError(id)]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dde-0.2.11 exp/exp_server.rb