win 0.1.27 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.27
1
+ 0.3.1
@@ -1,4 +1,4 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
- require 'win'
3
-
4
- require 'spec/expectations'
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
+ require 'win'
3
+
4
+ require 'spec/expectations'
data/features/win.feature CHANGED
@@ -1,9 +1,9 @@
1
- Feature: something something
2
- In order to something something
3
- A user something something
4
- something something something
5
-
6
- Scenario: something something
7
- Given inspiration
8
- When I create a sweet new gem
9
- Then everyone should see how awesome I am
1
+ Feature: something something
2
+ In order to something something
3
+ A user something something
4
+ something something something
5
+
6
+ Scenario: something something
7
+ Given inspiration
8
+ When I create a sweet new gem
9
+ Then everyone should see how awesome I am
data/lib/win/dde.rb CHANGED
@@ -1,1234 +1,1234 @@
1
- require 'win/library'
2
-
3
- module Win
4
-
5
- # Includes functions related to DDE exchange protocol in Windows
6
- #
7
- module DDE
8
- include Win::Library
9
-
10
- # Windows ANSI codepage:
11
- CP_WINANSI = 1004
12
-
13
- # DDE name service afCmd commands used by DdeNameService function:
14
-
15
- # Registers the service name.
16
- DNS_REGISTER = 1
17
- # Unregisters the service name. When hsz1 == 0L, ALL service names registered by the server will be unregistered.
18
- DNS_UNREGISTER = 2
19
- # Turns on service name initiation filtering. The filter prevents a server from receiving
20
- # XTYP_CONNECT transactions for service names it has not registered. This is the default
21
- # setting for this filter. If a server application does not register any service names,
22
- # the application cannot receive XTYP_WILDCONNECT transactions.
23
- DNS_FILTERON = 4
24
- # Turns off service name initiation filtering. If this flag is specified, the server
25
- # receives an XTYP_CONNECT transaction whenever another DDE application calls the
26
- # DdeConnect function, regardless of the service name.
27
- DNS_FILTEROFF = 8
28
-
29
- # Transaction confirmations:
30
-
31
- # Transaction confirmation
32
- DDE_FACK = 0x8000
33
- # Server is too busy to process transaction
34
- DDE_FBUSY = 0x4000
35
- DDE_FDEFERUPD = 0x4000
36
- DDE_FACKREQ = 0x8000
37
- DDE_FRELEASE = 0x2000
38
- DDE_FREQUESTED = 0x1000
39
- DDE_FAPPSTATUS = 0x00ff
40
- # Transaction rejected
41
- DDE_FNOTPROCESSED = 0
42
-
43
- # Transaction types:
44
-
45
- XTYPF_NOBLOCK = 0x0002
46
- XTYPF_NODATA = 0x0004
47
- XTYPF_ACKREQ = 0x0008
48
-
49
- XCLASS_MASK = 0xFC00
50
- XCLASS_BOOL = 0x1000
51
- XCLASS_DATA = 0x2000
52
- XCLASS_FLAGS = 0x4000
53
- XCLASS_NOTIFICATION = 0x8000
54
-
55
- XTYP_ERROR = XCLASS_NOTIFICATION | XTYPF_NOBLOCK
56
- XTYP_ADVDATA = 0x0010 | XCLASS_FLAGS
57
- XTYP_ADVREQ = 0x0020 | XCLASS_DATA | XTYPF_NOBLOCK
58
- XTYP_ADVSTART = 0x0030 | XCLASS_BOOL
59
- XTYP_ADVSTOP = 0x0040 | XCLASS_NOTIFICATION
60
- XTYP_EXECUTE = 0x0050 | XCLASS_FLAGS
61
- # A client uses the XTYP_CONNECT transaction to establish a conversation. A DDE server callback function,
62
- # DdeCallback, receives this transaction when a client specifies a service name that the server supports
63
- # (and a topic name that is not NULL) in a call to the DdeConnect function.
64
- XTYP_CONNECT = 0x0060 | XCLASS_BOOL | XTYPF_NOBLOCK
65
- XTYP_CONNECT_CONFIRM = 0x0070 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK
66
- XTYP_XACT_COMPLETE = 0x0080 | XCLASS_NOTIFICATION
67
- # A client uses the XTYP_POKE transaction to send unsolicited data to the server. DDE server callback function,
68
- # DdeCallback, receives this transaction when a client specifies XTYP_POKE in the DdeClientTransaction function.
69
- XTYP_POKE = 0x0090 | XCLASS_FLAGS
70
- XTYP_REGISTER = 0x00A0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK
71
- XTYP_REQUEST = 0x00B0 | XCLASS_DATA
72
- XTYP_DISCONNECT = 0x00C0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK
73
- XTYP_UNREGISTER = 0x00D0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK
74
- XTYP_WILDCONNECT = 0x00E0 | XCLASS_DATA | XTYPF_NOBLOCK
75
- XTYP_MONITOR = 0X00F0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK
76
- XTYP_MASK = 0x00F0
77
- XTYP_SHIFT = 0x0004
78
-
79
- # Types Hash {TRANSACTION_TYPE=>'Type description')}
80
- TYPES = {
81
- XTYPF_NOBLOCK => 'XTYPF_NOBLOCK',
82
- XTYPF_NODATA => 'XTYPF_NODATA',
83
- XTYPF_ACKREQ => 'XTYPF_ACKREQ',
84
- XCLASS_MASK => 'XCLASS_MASK',
85
- XCLASS_BOOL => 'XCLASS_BOOL',
86
- XCLASS_DATA => 'XCLASS_DATA',
87
- XCLASS_FLAGS => 'XCLASS_FLAGS',
88
- XCLASS_NOTIFICATION => 'XCLASS_NOTIFICATION',
89
- XTYP_ERROR => 'XTYP_ERROR',
90
- XTYP_ADVDATA => 'XTYP_ADVDATA',
91
- XTYP_ADVREQ => 'XTYP_ADVREQ',
92
- XTYP_ADVSTART => 'XTYP_ADVSTART',
93
- XTYP_ADVSTOP => 'XTYP_ADVSTOP',
94
- XTYP_EXECUTE => 'XTYP_EXECUTE',
95
- XTYP_CONNECT => 'XTYP_CONNECT',
96
- XTYP_CONNECT_CONFIRM=> 'XTYP_CONNECT_CONFIRM',
97
- XTYP_XACT_COMPLETE => 'XTYP_XACT_COMPLETE',
98
- XTYP_POKE => 'XTYP_POKE',
99
- XTYP_REGISTER => 'XTYP_REGISTER',
100
- XTYP_REQUEST => 'XTYP_REQUEST',
101
- XTYP_DISCONNECT => 'XTYP_DISCONNECT',
102
- XTYP_UNREGISTER => 'XTYP_UNREGISTER',
103
- XTYP_WILDCONNECT => 'XTYP_WILDCONNECT',
104
- XTYP_MONITOR => 'XTYP_MONITOR',
105
- XTYP_MASK => 'XTYP_MASK',
106
- XTYP_SHIFT => 'XTYP_SHIFT'
107
- }
108
-
109
-
110
- # DdeInitialize afCmd flaggs:
111
-
112
- # Registers the application as a standard (nonmonitoring) DDEML application.
113
- APPCLASS_STANDARD = 0
114
- # Makes it possible for the application to monitor DDE activity in the system.
115
- # This flag is for use by DDE monitoring applications. The application specifies the types of DDE
116
- # activity to monitor by combining one or more monitor flags with the APPCLASS_MONITOR flag.
117
- APPCLASS_MONITOR = 0x00000001
118
- # ?
119
- APPCLASS_MASK = 0x0000000F
120
- # Prevents the application from becoming a server in a DDE conversation. The application can only be a client.
121
- # This flag reduces consumption of resources by the DDEML. It includes the CBF_FAIL_ALLSVRXACTIONS flag.
122
- APPCMD_CLIENTONLY = 0x00000010
123
- # Prevents the DDEML from sending XTYP_CONNECT and XTYP_WILDCONNECT transactions to the application until
124
- # the application has created its string handles and registered its service names or has turned off filtering
125
- # by a subsequent call to the DdeNameService or DdeInitialize function. This flag is always in effect when an
126
- # application calls DdeInitialize for the first time, regardless of whether the application specifies the flag.
127
- # On subsequent calls to DdeInitialize, not specifying this flag turns off the application's service-name
128
- # filters, but specifying it turns on the application's service name filters.
129
- APPCMD_FILTERINITS = 0x00000020
130
- # ?
131
- APPCMD_MASK = 0x00000FF0
132
- # Prevents the callback function from receiving XTYP_CONNECT transactions from the application's own instance.
133
- # This flag prevents an application from establishing a DDE conversation with its own instance. An application
134
- # should use this flag if it needs to communicate with other instances of itself but not with itself.
135
- CBF_FAIL_SELFCONNECTIONS = 0x00001000
136
- # Prevents the callback function from receiving XTYP_CONNECT and XTYP_WILDCONNECT.
137
- CBF_FAIL_CONNECTIONS = 0x00002000
138
- # Prevents the callback function from receiving XTYP_ADVSTART and XTYP_ADVSTOP transactions. The system returns
139
- # DDE_FNOTPROCESSED to each client that sends an XTYP_ADVSTART or XTYP_ADVSTOP transaction to the server.
140
- CBF_FAIL_ADVISES = 0x00004000
141
- # Prevents the callback function from receiving XTYP_EXECUTE transactions. The system returns DDE_FNOTPROCESSED
142
- # to a client that sends an XTYP_EXECUTE transaction to the server.
143
- CBF_FAIL_EXECUTES = 0x00008000
144
- # Prevents the callback function from receiving XTYP_POKE transactions. The system returns DDE_FNOTPROCESSED
145
- # to a client that sends an XTYP_POKE transaction to the server.
146
- CBF_FAIL_POKES = 0x00010000
147
- # Prevents the callback function from receiving XTYP_REQUEST transactions. The system returns DDE_FNOTPROCESSED
148
- # to a client that sends an XTYP_REQUEST transaction to the server.
149
- CBF_FAIL_REQUESTS = 0x00020000
150
- # Prevents the callback function from receiving server transactions. The system returns DDE_FNOTPROCESSED to each
151
- # client that sends a transaction to this application. This flag is equivalent to combining all CBF_FAIL_ flags.
152
- CBF_FAIL_ALLSVRXACTIONS = 0x0003f000
153
- # Prevents the callback function from receiving XTYP_CONNECT_CONFIRM.
154
- CBF_SKIP_CONNECT_CONFIRMS = 0x00040000
155
- # Prevents the callback function from receiving XTYP_REGISTER notifications.
156
- CBF_SKIP_REGISTRATIONS = 0x00080000
157
- # Prevents the callback function from receiving XTYP_UNREGISTER notifications.
158
- CBF_SKIP_UNREGISTRATIONS = 0x00100000
159
- # Prevents the callback function from receiving XTYP_DISCONNECT notifications.
160
- CBF_SKIP_DISCONNECTS = 0x00200000
161
- # Prevents the callback function from receiving any notifications. Equivalent to combining all CBF_SKIP_ flags.
162
- CBF_SKIP_ALLNOTIFICATIONS = 0x003c0000
163
- # Notifies the callback function whenever a DDE application creates, frees, or increments the usage count of
164
- # a string handle or whenever a string handle is freed as a result of a call to the DdeUninitialize function.
165
- MF_HSZ_INFO = 0x01000000
166
- # Notifies the callback function whenever the system or an application sends a DDE message.
167
- MF_SENDMSGS = 0x02000000
168
- # Notifies the callback function whenever the system or an application posts a DDE message.
169
- MF_POSTMSGS = 0x04000000
170
- # Notifies the callback function whenever a transaction is sent to any DDE callback function in the system.
171
- MF_CALLBACKS = 0x08000000
172
- # Notifies the callback function whenever a DDE error occurs.
173
- MF_ERRORS = 0x10000000
174
- # Notifies the callback function whenever an advise loop is started or ended.
175
- MF_LINKS = 0x20000000
176
- # Notifies the callback function whenever a conversation is established or terminated.
177
- MF_CONV = 0x40000000
178
- # ?
179
- MF_MASK = 0xFF000000
180
-
181
- # Flags Hash {FLAG=>'Flag description')}
182
- FLAGS = {
183
- APPCLASS_STANDARD => 'APPCLASS_STANDARD',
184
- APPCLASS_MONITOR => 'APPCLASS_MONITOR',
185
- APPCLASS_MASK => 'APPCLASS_MASK',
186
- APPCMD_CLIENTONLY => 'APPCMD_CLIENTONLY',
187
- APPCMD_FILTERINITS => 'APPCMD_FILTERINITS',
188
- APPCMD_MASK => 'APPCMD_MASK',
189
- CBF_FAIL_SELFCONNECTIONS => 'CBF_FAIL_SELFCONNECTIONS',
190
- CBF_FAIL_CONNECTIONS => 'CBF_FAIL_CONNECTIONS',
191
- CBF_FAIL_ADVISES => 'CBF_FAIL_ADVISES',
192
- CBF_FAIL_EXECUTES => 'CBF_FAIL_EXECUTES',
193
- CBF_FAIL_POKES => 'CBF_FAIL_POKES',
194
- CBF_FAIL_REQUESTS => 'CBF_FAIL_REQUESTS',
195
- CBF_FAIL_ALLSVRXACTIONS => 'CBF_FAIL_ALLSVRXACTIONS',
196
- CBF_SKIP_CONNECT_CONFIRMS => 'CBF_SKIP_CONNECT_CONFIRMS',
197
- CBF_SKIP_REGISTRATIONS => 'CBF_SKIP_REGISTRATIONS',
198
- CBF_SKIP_UNREGISTRATIONS => 'CBF_SKIP_UNREGISTRATIONS',
199
- CBF_SKIP_DISCONNECTS => 'CBF_SKIP_DISCONNECTS',
200
- CBF_SKIP_ALLNOTIFICATIONS => 'CBF_SKIP_ALLNOTIFICATIONS',
201
- MF_HSZ_INFO => 'MF_HSZ_INFO',
202
- MF_SENDMSGS => 'MF_SENDMSGS',
203
- MF_POSTMSGS => 'MF_POSTMSGS',
204
- MF_CALLBACKS => 'MF_CALLBACKS',
205
- MF_ERRORS => 'MF_ERRORS',
206
- MF_LINKS => 'MF_LINKS',
207
- MF_CONV => 'MF_CONV',
208
- MF_MASK => 'MF_MASK'
209
- }
210
-
211
- # Error codes:
212
-
213
- # Returned if DDE Init successful
214
- DMLERR_NO_ERROR = 0x00
215
- # First (lowest) error code
216
- DMLERR_FIRST = 0x4000
217
- # A request for a synchronous advise transaction has timed out.
218
- DMLERR_ADVACKTIMEOUT = DMLERR_FIRST
219
- # The response to the transaction caused the DDE_FBUSY flag to be set
220
- DMLERR_BUSY = 0x4001
221
- # A request for a synchronous data transaction has timed out.
222
- DMLERR_DATAACKTIMEOUT = 0x4002
223
- # A DDEML function was called without first calling the DdeInitialize function, or an invalid instance
224
- # identifier was passed to a DDEML function.
225
- DMLERR_DLL_NOT_INITIALIZED = 0x4003
226
- # An application initialized as APPCLASS_MONITOR has attempted to perform a Dynamic Data Exchange (DDE) transaction,
227
- # or an application initialized as APPCMD_CLIENTONLY has attempted to perform server transactions.
228
- DMLERR_DLL_USAGE = 0x4004
229
- # A request for a synchronous execute transaction has timed out.
230
- DMLERR_EXECACKTIMEOUT = 0x4005
231
- # A parameter failed to be validated by the DDEML. Some of the possible causes follow:
232
- # - The application used a data handle initialized with a different item name handle than was required by the
233
- # transaction.
234
- # - The application used a data handle that was initialized with a different clipboard data format than was
235
- # required by the transaction.
236
- # - The application used a client-side conversation handle with a server-side function or vice versa.
237
- # - The application used a freed data handle or string handle.
238
- # - More than one instance of the application used the same object.
239
- DMLERR_INVALIDPARAMETER = 0x4006
240
- # A DDEML application has created a prolonged race condition (in which the server application
241
- # outruns the client), causing large amounts of memory to be consumed.
242
- DMLERR_LOW_MEMORY = 0x4007
243
- # A memory allocation has failed.
244
- DMLERR_MEMORY_ERROR = 0x4008
245
- # A transaction has failed.
246
- DMLERR_NOTPROCESSED = 0x4009
247
- # A client's attempt to establish a conversation has failed.
248
- DMLERR_NO_CONV_ESTABLISHED = 0x400a
249
- # A request for a synchronous poke transaction has timed out.
250
- DMLERR_POKEACKTIMEOUT = 0x400b
251
- # An internal call to the PostMessage function has failed.
252
- DMLERR_POSTMSG_FAILED = 0x400c
253
- # An application instance with a synchronous transaction already in progress attempted to initiate another
254
- # synchronous transaction, or the DdeEnableCallback function was called from within a DDEML callback function.
255
- DMLERR_REENTRANCY = 0x400d
256
- # A server-side transaction was attempted on a conversation terminated by the client, or the server terminated
257
- # before completing a transaction.
258
- DMLERR_SERVER_DIED = 0x400e
259
- # An internal error has occurred in the DDEML.
260
- DMLERR_SYS_ERROR = 0x400f
261
- # A request to end an advise transaction has timed out.
262
- DMLERR_UNADVACKTIMEOUT = 0x4010
263
- # An invalid transaction identifier was passed to a DDEML function. Once the application has returned from an
264
- # XTYP_XACT_COMPLETE callback, the transaction identifier for that callback function is no longer valid.
265
- DMLERR_UNFOUND_QUEUE_ID = 0x4011
266
- # Last (highest) error code
267
- DMLERR_LAST = DMLERR_UNFOUND_QUEUE_ID
268
-
269
- # Errors Hash {ERROR_CODE=>'Error description')}
270
- ERRORS = {
271
- nil => 'No DDEML error',
272
- DMLERR_NO_ERROR => 'No DDEML error',
273
- DMLERR_ADVACKTIMEOUT => 'A request for a synchronous advise transaction has timed out.',
274
- DMLERR_BUSY => 'The response to the transaction caused the DDE_FBUSY flag to be set.',
275
- DMLERR_DATAACKTIMEOUT => 'A request for a synchronous data transaction has timed out.',
276
- DMLERR_DLL_NOT_INITIALIZED => 'A DDEML function was called without first calling the DdeInitialize ' +
277
- 'function, or an invalid instance identifier was passed to a DDEML function.',
278
- DMLERR_DLL_USAGE => 'An application initialized as APPCLASS_MONITOR has attempted to perform a DDE ' +
279
- 'transaction, or an application initialized as APPCMD_CLIENTONLY has attempted to perform ' +
280
- 'server transactions.',
281
- DMLERR_EXECACKTIMEOUT => 'A request for a synchronous execute transaction has timed out.',
282
- DMLERR_INVALIDPARAMETER => 'A parameter failed to be validated by the DDEML. Possible causes: ' +
283
- 'Application used a data handle initialized with a different item name handle than was required ' +
284
- 'by the transaction. ' +
285
- 'The application used a data handle that was initialized with a different clipboard data format ' +
286
- 'than was required by the transaction. ' +
287
- 'The application used a client-side conversation handle with server-side function or vice versa. ' +
288
- 'The application used a freed data handle or string handle. ' +
289
- 'More than one instance of the application used the same object.',
290
- DMLERR_LOW_MEMORY => 'A DDEML application has created a prolonged race condition (in which the server ' +
291
- 'application outruns the client), causing large amounts of memory to be consumed.',
292
- DMLERR_MEMORY_ERROR => 'A memory allocation has failed.',
293
- DMLERR_NO_CONV_ESTABLISHED => 'A client`s attempt to establish a conversation has failed.',
294
- DMLERR_NOTPROCESSED => 'A transaction has failed.',
295
- DMLERR_POKEACKTIMEOUT => 'A request for a synchronous poke transaction has timed out.',
296
- DMLERR_POSTMSG_FAILED => 'An internal call to the PostMessage function has failed.',
297
- DMLERR_REENTRANCY => 'An application instance with a synchronous transaction already in progress ' +
298
- 'attempted to initiate another synchronous transaction, or the DdeEnableCallback function ' +
299
- 'was called from within a DDEML callback function.',
300
- DMLERR_SERVER_DIED => 'A server-side transaction was attempted on a conversation terminated by the ' +
301
- 'client, or the server terminated before completing a transaction.',
302
- DMLERR_SYS_ERROR => 'An internal error has occurred in the DDEML.',
303
- DMLERR_UNADVACKTIMEOUT => 'A request to end an advise transaction has timed out.',
304
- DMLERR_UNFOUND_QUEUE_ID => 'An invalid transaction identifier was passed to a DDEML function. Once the ' +
305
- 'application has returned from an XTYP_XACT_COMPLETE callback, the transaction identifier for ' +
306
- 'that callback function is no longer valid.'
307
- }
308
-
309
- # Predefined Clipboard Formats:
310
-
311
- # The simplest form of Clipboard data. It is a null-terminated string containing a carriage return
312
- # and linefeed at the end of each line.
313
- CF_TEXT = 1
314
- # A Windows version 2.x-compatible bitmap
315
- CF_BITMAP = 2
316
- # A metafile picture structure. See docs for Microsoft Windows Software Development Kit.
317
- CF_METAFILEPICT = 3
318
- # Microsoft symbolic link (SYLK) format. Microsoft Excel for the Apple Macintosh was originally designed to use
319
- # SYLK format, and this format is now supported by Microsoft Excel on both the Windows and Macintosh platforms
320
- CF_SYLK = 4
321
- # An ASCII format used by the VisiCalc spreadsheet program
322
- CF_DIF = 5
323
- CF_TIFF = 6
324
- CF_OEMTEXT = 7
325
- CF_DIB = 8
326
- CF_PALETTE = 9
327
- CF_PENDATA = 10
328
- CF_RIFF = 11
329
- CF_WAVE = 12
330
- CF_UNICODETEXT = 13
331
- CF_ENHMETAFILE = 14
332
- # Filename copied to clipboard
333
- CF_HDROP = 15
334
- CF_LOCALE = 16
335
- CF_MAX = 17
336
-
337
- # DdeClientTransaction timeout value indicating async transaction
338
- TIMEOUT_ASYNC = 0xFFFFFFFF
339
-
340
- # The MONCBSTRUCT structure contains information about the current Dynamic Data Exchange (DDE)
341
- # transaction. A DDE debugging application can use this structure when monitoring transactions that the
342
- # system passes to the DDE callback functions of other applications.
343
- #
344
- # [*Typedef*] struct { UINT cb; DWORD dwTime; HANDLE hTask; DWORD dwRet; UINT wType; UINT wFmt; HCONV
345
- # hConv; HSZ hsz1; HSZ hsz2; HDDEDATA hData; ULONG_PTR dwData1; ULONG_PTR dwData2;
346
- # CONVCONTEXT cc; DWORD cbData; DWORD Data[8] } MONCBSTRUCT;
347
- #
348
- # cb:: Specifies the structure's size, in bytes.
349
- # dwTime:: Specifies the Windows time at which the transaction occurred. Windows time is the number of
350
- # milliseconds that have elapsed since the system was booted.
351
- # hTask:: Handle to the task (app instance) containing the DDE callback function that received the transaction.
352
- # dwRet:: Specifies the value returned by the DDE callback function that processed the transaction.
353
- # wType:: Specifies the transaction type.
354
- # wFmt:: Specifies the format of the data exchanged (if any) during the transaction.
355
- # hConv:: Handle to the conversation in which the transaction took place.
356
- # hsz1:: Handle to a string.
357
- # hsz2:: Handle to a string.
358
- # hData:: Handle to the data exchanged (if any) during the transaction.
359
- # dwData1:: Specifies additional data.
360
- # dwData2:: Specifies additional data.
361
- # cc:: Specifies a CONVCONTEXT structure containing language information used to share data in different languages.
362
- # cbData:: Specifies the amount, in bytes, of data being passed with the transaction. This value can be
363
- # more than 32 bytes.
364
- # Data:: Contains the first 32 bytes of data being passed with the transaction (8 * sizeof(DWORD)).
365
- # ---
366
- # *Information*:
367
- # Header Declared in Ddeml.h, include Windows.h
368
-
369
- class MonCbStruct < FFI::Struct # :nodoc:
370
- layout :cb, :uint,
371
- :dw_time, :uint32,
372
- :h_task, :ulong,
373
- :dw_ret, :uint32,
374
- :w_type, :uint,
375
- :w_fmt, :uint,
376
- :h_conv, :ulong,
377
- :hsz1, :ulong,
378
- :hsz2, :ulong,
379
- :h_data, :pointer,
380
- :dw_data1, :pointer,
381
- :dw_data2, :pointer,
382
- :cc, :pointer,
383
- :cb_data, :uint32,
384
- :data, [:uint32, 8]
385
- end
386
-
387
- # The MONCONVSTRUCT structure contains information about a Dynamic Data Exchange (DDE) conversation. A
388
- # DDE monitoring application can use this structure to obtain information about a conversation that has
389
- # been established or has terminated.
390
- #
391
- # [*Typedef*] struct { UINT cb; BOOL fConnect; DWORD dwTime; HANDLE hTask; HSZ hszSvc; HSZ hszTopic;
392
- # HCONV hConvClient; HCONV hConvServer } MONCONVSTRUCT;
393
- #
394
- # cb:: Specifies the structure's size, in bytes.
395
- # fConnect:: Indicates whether the conversation is currently established. A value of TRUE indicates the
396
- # conversation is established; FALSE indicates it is not.
397
- # dwTime:: Specifies the Windows time at which the conversation was established or terminated. Windows
398
- # time is the number of milliseconds that have elapsed since the system was booted.
399
- # hTask:: Handle to a task (application instance) that is a partner in the conversation.
400
- # hszSvc:: Handle to the service name on which the conversation is established.
401
- # hszTopic:: Handle to the topic name on which the conversation is established.
402
- # hConvClient:: Handle to the client conversation.
403
- # hConvServer:: Handle to the server conversation.
404
- # ---
405
- # *Remarks*:
406
- #
407
- # Because string handles are local to the process, the hszSvc and hszTopic members are global atoms.
408
- # Similarly, conversation handles are local to the instance; therefore, the hConvClient and hConvServer
409
- # members are window handles.
410
- # The hConvClient and hConvServer members of the MONCONVSTRUCT structure do not hold the same value as
411
- # would be seen by the applications engaged in the conversation. Instead, they hold a globally unique
412
- # pair of values that identify the conversation.
413
- # ---
414
- # Structure Information:
415
- # Header Declared in Ddeml.h, include Windows.h
416
- #
417
- class MonConvStruct < FFI::Struct # :nodoc:
418
- layout :cb, :uint,
419
- :f_connect, :uchar,
420
- :dw_time, :uint32,
421
- :h_task, :ulong,
422
- :hsz_svc, :ulong,
423
- :hsz_topic, :ulong,
424
- :h_conv_client, :ulong,
425
- :h_conv_server, :ulong
426
- end
427
-
428
- # The MONERRSTRUCT structure contains information about the current Dynamic Data Exchange (DDE) error. A
429
- # DDE monitoring application can use this structure to monitor errors returned by DDE Management Library
430
- # functions.
431
- #
432
- # [*Typedef*] struct { UINT cb; UINT wLastError; DWORD dwTime; HANDLE hTask } MONERRSTRUCT;
433
- #
434
- # cb:: Specifies the structure's size, in bytes.
435
- # wLastError:: Specifies the current error.
436
- # dwTime:: Specifies the Windows time at which the error occurred. Windows time is the number of
437
- # milliseconds that have elapsed since the system was booted.
438
- # hTask:: Handle to the task (application instance) that called the DDE function that caused the error.
439
- # ---
440
- # Structure Information:
441
- # Header Declared in Ddeml.h, include Windows.h
442
- #
443
- class MonErrStruct < FFI::Struct # :nodoc:
444
- layout :cb, :uint,
445
- :w_last_error, :uint,
446
- :dw_time, :uint32,
447
- :h_task, :ulong
448
- end
449
-
450
- MH_CREATE = 1
451
- MH_KEEP = 2
452
- MH_DELETE = 3
453
- MH_CLEANUP = 4
454
-
455
- # The MONHSZSTRUCT structure contains information about a Dynamic Data Exchange (DDE) string handle. A
456
- # DDE monitoring application can use this structure when monitoring the activity of the string manager
457
- # component of the DDE Management Library.
458
- #
459
- # [*Typedef*] struct { UINT cb; BOOL fsAction; DWORD dwTime; HSZ hsz; HANDLE hTask; TCHAR str[1] } MONHSZSTRUCT;
460
- #
461
- # cb:: Specifies the structure's size, in bytes.
462
- # fsAction:: Specifies the action being performed on the string identified by the hsz member.
463
- # MH_CLEANUP:: An application is freeing its DDE resources, causing the system to delete string handles
464
- # the application had created. (The application called the DdeUninitialize function.)
465
- # MH_CREATE:: An application is creating a string handle. (The app called the DdeCreateStringHandle)
466
- # MH_DELETE:: An application is deleting a string handle. (The app called the DdeFreeStringHandle)
467
- # MH_KEEP:: An application is increasing the usage count of a string handle. (The application called the
468
- # DdeKeepStringHandle function.)
469
- # dwTime:: Specifies the Windows time at which the action specified by the fsAction member takes place.
470
- # Windows time is the number of milliseconds that have elapsed since the system was booted.
471
- # hsz:: Handle to the string. Because string handles are local to the process, this member is a global atom.
472
- # hTask:: Handle to the task (application instance) performing the action on the string handle.
473
- # str:: Pointer to the string identified by the hsz member.
474
- # ---
475
- # Structure Information
476
- # Header Declared in Ddeml.h, include Windows.h
477
- #
478
- class MonHszStruct < FFI::Struct # :nodoc:
479
- layout :cb, :uint,
480
- :fs_action, :uchar,
481
- :dw_time, :uint32,
482
- :hsz, :ulong,
483
- :h_task, :ulong,
484
- :str, :pointer
485
- end
486
-
487
- # The MONLINKSTRUCT structure contains information about a Dynamic Data Exchange (DDE) advise loop. A
488
- # DDE monitoring application can use this structure to obtain information about an advise loop that has
489
- # started or ended.
490
- #
491
- # [*Typedef*] struct { UINT cb; DWORD dwTime; HANDLE hTask; BOOL fEstablished; BOOL fNoData; HSZ hszSvc;
492
- # HSZ hszTopic; HSZ hszItem; UINT wFmt; BOOL fServer; HCONV hConvServer; HCONV hConvClient }
493
- # MONLINKSTRUCT;
494
- #
495
- # cb:: Specifies the structure's size, in bytes.
496
- # dwTime:: Specifies the Windows time at which the advise loop was started or ended. Windows time is the
497
- # number of milliseconds that have elapsed since the system was booted.
498
- # hTask:: Handle to a task (application instance) that is a partner in the advise loop.
499
- # fEstablished:: Indicates whether an advise loop was successfully established. A value of TRUE
500
- # indicates an advise loop was established; FALSE indicates it was not.
501
- # fNoData:: Indicates whether the XTYPF_NODATA flag is set for the advise loop. A value of TRUE
502
- # indicates the flag is set; FALSE indicates it is not.
503
- # hszSvc:: Handle to the service name of the server in the advise loop.
504
- # hszTopic:: Handle to the topic name on which the advise loop is established.
505
- # hszItem:: Handle to the item name that is the subject of the advise loop.
506
- # wFmt:: Specifies the format of the data exchanged (if any) during the advise loop.
507
- # fServer:: Indicates whether the link notification came from the server. A value of TRUE indicates the
508
- # notification came from the server; FALSE indicates otherwise.
509
- # hConvServer:: Handle to the server conversation.
510
- # hConvClient:: Handle to the client conversation.
511
- # ---
512
- # *Remarks*:
513
- # Because string handles are local to the process, the hszSvc, hszTopic, and hszItem members are global atoms.
514
- # The hConvClient and hConvServer members of the MONLINKSTRUCT structure do not hold the same value as
515
- # would be seen by the applications engaged in the conversation. Instead, they hold a globally unique
516
- # pair of values that identify the conversation.
517
- # ---
518
- # Structure Information
519
- # Header Declared in Ddeml.h, include Windows.h
520
- #
521
- class MonLinkStruct < FFI::Struct # :nodoc:
522
- layout :cb, :uint,
523
- :dw_time, :uint32,
524
- :h_task, :ulong,
525
- :f_established, :uchar,
526
- :f_no_data, :uchar,
527
- :hsz_svc, :ulong,
528
- :hsz_topic, :ulong,
529
- :hsz_item, :ulong,
530
- :w_fmt, :uint,
531
- :f_server, :uchar,
532
- :h_conv_server, :ulong,
533
- :h_conv_client, :ulong
534
- end
535
-
536
- # The MONMSGSTRUCT structure contains information about a Dynamic Data Exchange (DDE) message. A DDE
537
- # monitoring application can use this structure to obtain information about a DDE message that was sent
538
- # or posted.
539
- #
540
- # [*Typedef*] struct { UINT cb; HWND hwndTo; DWORD dwTime; HANDLE hTask; UINT wMsg; WPARAM wParam;
541
- # LPARAM lParam; DDEML_MSG_HOOK_DATA dmhd } MONMSGSTRUCT;
542
- #
543
- # cb:: Specifies the structure's size, in bytes.
544
- # hwndTo:: Handle to the window that receives the DDE message.
545
- # dwTime:: Specifies the Windows time at which the message was sent or posted. Windows time is the
546
- # number of milliseconds that have elapsed since the system was booted.
547
- # hTask:: Handle to the task (application instance) containing the window that receives the DDE message.
548
- # wMsg:: Specifies the identifier of the DDE message.
549
- # wParam:: Specifies the wParam parameter of the DDE message.
550
- # lParam:: Specifies the lParam parameter of the DDE message.
551
- # dmhd:: Specifies a DDEML_MSG_HOOK_DATA structure that contains additional information about the DDE message.
552
- # ---
553
- # Structure Information
554
- # Header Declared in Ddeml.h, include Windows.h
555
- #
556
- class MonMsgStruct < FFI::Struct # :nodoc:
557
- layout :cb, :uint,
558
- :hwnd_to, :ulong,
559
- :dw_time, :uint32,
560
- :h_task, :ulong,
561
- :w_msg, :uint,
562
- :w_param, :uint,
563
- :l_param, :long,
564
- :dmhd, :pointer
565
- end
566
-
567
- # The DDEML_MSG_HOOK_DATA structure contains information about a Dynamic Data Exchange (DDE) message,
568
- # and provides read access to the data referenced by the message. This structure is intended to be used
569
- # by a Dynamic Data Exchange Management Library (DDEML) monitoring application.
570
- #
571
- # [*Typedef*] struct { UINT_PTR uiLo; UINT_PTR uiHi; DWORD cbData; DWORD Data } DDEML_MSG_HOOK_DATA;
572
- #
573
- # uiLo:: Specifies the unpacked low-order word of the lParam parameter associated with the DDE message.
574
- # uiHi:: Specifies the unpacked high-order word of the lParam parameter associated with the DDE message.
575
- # cbData:: Specifies the amount, in bytes, of data being passed with the message. This value can be > 32.
576
- # Data:: Contains the first 32 bytes of data being passed with the message (8 * sizeof(DWORD)).
577
- # ---
578
- # Structure Information
579
- # Header Declared in Ddeml.h, include Windows.h
580
- #
581
- class DdemlMsgHookData < FFI::Struct # :nodoc:
582
- layout :ui_lo, :uint,
583
- :ui_hi, :uint,
584
- :cb_data, :uint32,
585
- :data, :uint32
586
- end
587
-
588
- ##
589
- # The RegisterClipboardFormat function registers a new clipboard format.
590
- # This format can then be used as a valid clipboard format.
591
- #
592
- # [*Syntax*] UINT RegisterClipboardFormat( LPCTSTR lpszFormat )
593
- #
594
- # lpszFormat:: [in] Pointer to a null-terminated string that names the new format.
595
- #
596
- # *Returns*:: :uint or nil. If the function succeeds, the return value identifies the registered clipboard format.
597
- # If the function fails, the return value is *nil*(not zero). For error info, call GetLastError.
598
- # ---
599
- # *Remarks*:
600
- # If a registered format with the specified name already exists, a new format is not registered and the
601
- # return value identifies the existing format. This enables more than one application to copy and paste
602
- # data using the same registered clipboard format. Note that the comparison is case-insensitive.
603
- # Registered clipboard formats are identified by values in the range 0xC000 through 0xFFFF.
604
- # When registered clipboard formats are placed on or retrieved from the clipboard, they must be in the
605
- # form of an HGLOBAL value.
606
- #
607
- # :call-seq:
608
- # format_id = register_clipboard_format( format_name )
609
- #
610
- function :RegisterClipboardFormat, [:pointer], :uint, zeronil: true
611
-
612
- ##
613
- # The DdeCallback function is an application-defined callback function used with the Dynamic Data Exchange
614
- # Management Library (DDEML) functions. It processes Dynamic Data Exchange (DDE) transactions. The PFNCALLBACK
615
- # type defines a pointer to this callback function. DdeCallback is a placeholder for the application-defined
616
- # function name.
617
- #
618
- # [*Syntax*] HDDEDATA CALLBACK DdeCallback( UINT uType, UINT uFmt, HCONV hconv, HDDEDATA hsz1, HDDEDATA hsz2,
619
- # HDDEDATA hdata, HDDEDATA dwData1, HDDEDATA dwData2);
620
- # uType:: [in] Specifies the type of the current transaction. This parameter consists of a combination of
621
- # transaction class flags and transaction type flags. The following table describes each of the
622
- # transaction classes and provides a list of the transaction types in each class. For information
623
- # about a specific transaction type, see the individual description of that type.
624
- # - XCLASS_BOOL - A DDE callback function should return TRUE or FALSE when it finishes processing a
625
- # transaction that belongs to this class. The XCLASS_BOOL class consists of the following types:
626
- # - XTYP_ADVSTART
627
- # - *XTYP_CONNECT*: A client uses the XTYP_CONNECT transaction to establish a conversation.
628
- # hsz1:: Handle to the topic name.
629
- # hsz2:: Handle to the service name.
630
- # dwData1:: Pointer to a CONVCONTEXT structure that contains context information for the conversation.
631
- # If the client is not a Dynamic Data Exchange Management Library (DDEML) application,
632
- # this parameter is 0.
633
- # dwData2:: Specifies whether the client is the same application instance as the server. If the
634
- # parameter is 1, the client is the same instance. If the parameter is 0, the client
635
- # is a different instance.
636
- # *Returns*:: A server callback function should return TRUE to allow the client to establish a
637
- # conversation on the specified service name and topic name pair, or the function
638
- # should return FALSE to deny the conversation. If the callback function returns TRUE
639
- # and a conversation is successfully established, the system passes the conversation
640
- # handle to the server by issuing an XTYP_CONNECT_CONFIRM transaction to the server's
641
- # callback function (unless the server specified the CBF_SKIP_CONNECT_CONFIRMS flag
642
- # in the DdeInitialize function).
643
- # - XCLASS_DATA - A DDE callback function should return a DDE handle, the CBR_BLOCK return code, or
644
- # NULL when it finishes processing a transaction that belongs to this class. The XCLASS_DATA
645
- # transaction class consists of the following types:
646
- # - XTYP_ADVREQ
647
- # - XTYP_REQUEST
648
- # - XTYP_WILDCONNECT
649
- # - XCLASS_FLAGS - A DDE callback function should return DDE_FACK, DDE_FBUSY, or DDE_FNOTPROCESSED
650
- # when it finishes processing a transaction that belongs to this class. The XCLASS_FLAGS transaction
651
- # class consists of the following types:
652
- # - XTYP_ADVDATA
653
- # - XTYP_EXECUTE
654
- # - *XTYP_POKE*: A client uses the XTYP_POKE transaction to send unsolicited data to the server.
655
- # uFmt:: Specifies the format of the data sent from the server.
656
- # hconv:: Handle to the conversation.
657
- # hsz1:: Handle to the topic name.
658
- # hsz2:: Handle to the item name.
659
- # hdata:: Handle to the data that the client is sending to the server.
660
- # *Returns*:: A server callback function should return the DDE_FACK flag if it processes this
661
- # transaction, the DDE_FBUSY flag if it is too busy to process this transaction,
662
- # or the DDE_FNOTPROCESSED flag if it rejects this transaction.
663
- # - XCLASS_NOTIFICATION - The transaction types that belong to this class are for notification purposes
664
- # only. The return value from the callback function is ignored. The XCLASS_NOTIFICATION transaction
665
- # class consists of the following types:
666
- # - XTYP_ADVSTOP
667
- # - XTYP_CONNECT_CONFIRM
668
- # - XTYP_DISCONNECT
669
- # - XTYP_ERROR
670
- # - XTYP_MONITOR
671
- # - XTYP_REGISTER
672
- # - XTYP_XACT_COMPLETE
673
- # - XTYP_UNREGISTER
674
- # uFmt:: [in] Specifies the format in which data is sent or received.
675
- # hconv:: [in] Handle to the conversation associated with the current transaction.
676
- # hsz1:: [in] Handle to a string. The meaning of this parameter depends on the type of the current transaction.
677
- # For the meaning of this parameter, see the description of the transaction type.
678
- # hsz2:: [in] Handle to a string. The meaning of this parameter depends on the type of the current transaction.
679
- # For the meaning of this parameter, see the description of the transaction type.
680
- # hdata:: [in] Handle to DDE data. The meaning of this parameter depends on the type of the current transaction.
681
- # For the meaning of this parameter, see the description of the transaction type.
682
- # dwData1:: [in] Specifies transaction-specific data. For the meaning, see the description of the transaction type.
683
- # dwData2:: [in] Specifies transaction-specific data. For the meaning, see the description of the transaction type.
684
- # *Returns*:: The return value depends on the transaction class. For more information about the return values,
685
- # see descriptions of the individual transaction types.
686
- # ---
687
- # *Remarks*:
688
- # - The callback function is called asynchronously for transactions that do not involve the creation or termination
689
- # of conversations. An application that does not frequently accept incoming messages will have reduced DDE
690
- # performance because the Dynamic Data Exchange Management Library (DDEML) uses messages to initiate transactions.
691
- # - An application must register the callback function by specifying a pointer to the function in a call to the
692
- # DdeInitialize function.
693
- #
694
- # :call-seq:
695
- # DdeCallback block: {|type, format, hconv, hsz1, hsz2, hdata, data1, data2| your code }
696
- #
697
- callback :DdeCallback, [:uint, :uint, :HCONV, :HDDEDATA, :HDDEDATA, :HDDEDATA, :HDDEDATA, :HDDEDATA], :HDDEDATA
698
-
699
- ##
700
- # The DdeInitialize function registers an application with the Dynamic Data Exchange Management Library (DDEML).
701
- # An application must call this function before calling any other DDEML function.
702
- #
703
- # [*Syntax*] UINT DdeInitialize( LPDWORD pidInst, PFNCALLBACK pfnCallback, DWORD afCmd, DWORD ulRes );
704
- #
705
- # pidInst:: [in, out] Pointer to the application instance identifier.
706
- # At initialization, this parameter should point to 0. If the function succeeds, this parameter points
707
- # to the instance identifier for the application. This value should be passed as the idInst parameter
708
- # in all other DDEML functions that require it. If an application uses multiple instances of the DDEML
709
- # dynamic-link library (DLL), the application should provide a different callback function for each
710
- # instance. If pidInst points to a nonzero value, reinitialization of the DDEML is implied. In this
711
- # case, pidInst must point to a valid application-instance identifier.
712
- # pfnCallback:: Pointer to the application-defined Dynamic Data Exchange DdeCallback function. This function
713
- # processes DDE transactions sent by the system. For more information, see the DdeCallback.
714
- # afCmd:: [in] Specifies a set of APPCMD_, CBF_, and MF_ flags. The APPCMD_ flags provide special
715
- # instructions to DdeInitialize. The CBF_ flags specify filters that prevent specific types of transactions
716
- # from reaching the callback function. The MF_ flags specify the types of DDE activity that a DDE monitoring
717
- # application monitors. Using these flags enhances the performance of a DDE application by eliminating
718
- # unnecessary calls to the callback function. This parameter can be one or more of the following values:
719
- # APPCLASS_MONITOR, APPCLASS_STANDARD, APPCMD_CLIENTONLY, APPCMD_FILTERINITS;
720
- # CBF_FAIL_ALLSVRXACTIONS, CBF_FAIL_ADVISES, CBF_FAIL_CONNECTIONS, CBF_FAIL_EXECUTES, CBF_FAIL_POKES
721
- # CBF_FAIL_REQUESTS, CBF_FAIL_SELFCONNECTIONS, CBF_SKIP_ALLNOTIFICATIONS, CBF_SKIP_CONNECT_CONFIRMS
722
- # CBF_SKIP_DISCONNECTS, CBF_SKIP_REGISTRATIONS, CBF_SKIP_UNREGISTRATIONS;
723
- # MF_CALLBACKS, MF_CONV, MF_ERRORS, MF_HSZ_INFO, MF_LINKS, MF_POSTMSGS, MF_SENDMSGS
724
- # ulRes:: Reserved; must be set to zero.
725
- #
726
- # *Returns*:: If the function succeeds, the return value is DMLERR_NO_ERROR. If the function fails, the return
727
- # value is one of the following values:
728
- # - DMLERR_DLL_USAGE
729
- # - DMLERR_INVALIDPARAMETER
730
- # - DMLERR_SYS_ERROR
731
- # ---
732
- # <b> Enhanced API accepts only 2 parameters (get rid of reserved hsz2):
733
- # instance_id:: (optional) Application instance identifier. At initialization, this parameter should be 0, nil
734
- # or omitted altogether. If it is nonzero/non-nil, reinitialization of the DDEML is implied.
735
- # cmd(afCmd):: obligatory set of flags
736
- # ---
737
- # *Remarks*:
738
- # - An application that uses multiple instances of the DDEML must not pass DDEML objects between instances.
739
- # - A DDE monitoring application should not attempt to perform DDE operations (establish conversations,
740
- # issue transactions, and so on) within the context of the same application instance.
741
- # - A synchronous transaction fails with a DMLERR_REENTRANCY error if any instance of the same task has
742
- # a synchronous transaction already in progress.
743
- # - The CBF_FAIL_ALLSVRXACTIONS flag causes the DDEML to filter all server transactions and can be changed
744
- # by a subsequent call to DdeInitialize. The APPCMD_CLIENTONLY flag prevents the DDEML from creating key
745
- # resources for the server and cannot be changed by a subsequent call to DdeInitialize.
746
- # - There is an ANSI version and a Unicode version of DdeInitialize. The version called determines the
747
- # type of the window procedures used to control DDE conversations (ANSI or Unicode), and the default
748
- # value for the iCodePage member of the CONVCONTEXT structure (CP_WINANSI or CP_WINUNICODE).
749
- #
750
- # :call-seq:
751
- # instance_id, status = dde_initialize( [instance_id = 0], cmd )
752
- # {|type, format, hconv, hsz1, hsz2, hdata, data1, data2| your dde_callback block}
753
- #
754
- function :DdeInitialize, [:pointer, :DdeCallback, :uint32, :uint32], :uint,
755
- &->(api, old_id=0, cmd, &block){
756
- raise ArgumentError, 'No callback block' unless block
757
- old_id = 0 unless old_id
758
- id = FFI::MemoryPointer.new(:uint32).put_uint32(0, old_id)
759
- status = api.call(id, block, cmd, 0)
760
- id = status == 0 ? id.get_uint32(0) : nil
761
- [id, status] }
762
- # weird lambda literal instead of block is needed because RDoc goes crazy if block is attached to meta-definition
763
-
764
- ##
765
- # The DdeUninitialize function frees all Dynamic Data Exchange Management Library (DDEML) resources associated
766
- # with the calling application.
767
- #
768
- # [*Syntax*] BOOL DdeUninitialize( DWORD idInst);
769
- #
770
- # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the DdeInitialize.
771
- # *Returns*:: If the function succeeds, the return value is nonzero.
772
- # If the function fails, the return value is zero.
773
- # ---
774
- # *Remarks*
775
- # DdeUninitialize terminates any conversations currently open for the application.
776
- #
777
- # :call-seq:
778
- # success = dde_uninitialize( instance_id )
779
- #
780
- function :DdeUninitialize, [:uint32], :int, boolean: true
781
-
782
- ##
783
- # The DdeCreateStringHandle function creates a handle that identifies the specified string.
784
- # A Dynamic Data Exchange (DDE) client or server application can pass the string handle as a
785
- # parameter to other Dynamic Data Exchange Management Library (DDEML) functions.
786
- #
787
- # [*Syntax*] HSZ DdeCreateStringHandle( DWORD idInst, LPTSTR psz, int iCodePage );
788
- #
789
- # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the
790
- # DdeInitialize function.
791
- # psz:: [in] Pointer to a buffer that contains the null-terminated string for which a handle
792
- # is to be created. This string can be up to 255 characters. The reason for this limit is that
793
- # DDEML string management functions are implemented using global atoms.
794
- # iCodePage:: [in] Specifies the code page used to render the string. This value should be either
795
- # CP_WINANSI (the default code page) or CP_WINUNICODE, depending on whether the ANSI or Unicode
796
- # version of DdeInitialize was called by the client application.
797
- #
798
- # *Returns*:: (L) or nil: If the function succeeds, the return value is a string handle.
799
- # If the function fails, the return value is 0(changed to nil in enhanced version).
800
- # The DdeGetLastError function can be used to get the error code, which can be one of the
801
- # following values: DMLERR_NO_ERROR, DMLERR_INVALIDPARAMETER, DMLERR_SYS_ERROR
802
- # ---
803
- # <b> Enhanced (snake_case) API makes code_page param optional and returns *nil* if handle creation fails. </b>
804
- # ---
805
- # *Remarks*: The value of a string handle is not related to the case of the string it identifies.
806
- # When an application either creates a string handle or receives one in the callback function
807
- # and then uses the DdeKeepStringHandle function to keep it, the application must free that string
808
- # handle when it is no longer needed. An instance-specific string handle cannot be mapped from string
809
- # handle to string and back to string handle.
810
- #
811
- # :call-seq:
812
- # string_handle = dde_create_string_handle( instance_id, string, code_page_id )
813
- #
814
- function :DdeCreateStringHandle, [:uint32, :pointer, :int], :ulong, zeronil: true,
815
- &->(api, instance_id, string, code_page=CP_WINANSI){
816
- string_pointer = FFI::MemoryPointer.from_string(string)
817
- api.call(instance_id, string_pointer, code_page) }
818
-
819
- ##
820
- # The DdeFreeStringHandle function frees a string handle in the calling application.
821
- #
822
- # [*Syntax*] BOOL DdeFreeStringHandle( DWORD idInst, HSZ hsz );
823
- #
824
- # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the DdeInitialize.
825
- # hsz:: [in, out] Handle to the string handle to be freed. This handle must have been created by a previous call
826
- # to the DdeCreateStringHandle function.
827
- # *Returns*:: If the function succeeds, the return value is nonzero. If the function fails, it is zero.
828
- # ---
829
- # <b> Enhanced snake_case API returns boolean true/false as a success indicator. </b>
830
- # ---
831
- # *Remarks*:
832
- # An application can free string handles it creates with DdeCreateStringHandle but should not free those that
833
- # the system passed to the application's Dynamic Data Exchange (DDE) callback function or those returned in the
834
- # CONVINFO structure by the DdeQueryConvInfo function.
835
- #
836
- # :call-seq:
837
- # success = dde_free_string_handle( instance_id, string_handle )
838
- #
839
- function :DdeFreeStringHandle, [:uint32, :ulong], :int, boolean: true
840
-
841
- ##
842
- # The DdeQueryString function copies text associated with a string handle into a buffer.
843
- #
844
- # [*Syntax*] DWORD DdeQueryString( DWORD idInst, HSZ hsz, LPTSTR psz, DWORD cchMax, int iCodePage);
845
- #
846
- # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the DdeInitialize.
847
- # hsz:: [in] Handle to the string to copy. This handle must have been created by a previous call to the
848
- # DdeCreateStringHandle function.
849
- # psz:: [in, out] Pointer to a buffer that receives the string. To obtain the length of the string, this parameter
850
- # should be set to NULL.
851
- # cchMax:: [in] Specifies the length, in TCHARs, of the buffer pointed to by the psz parameter. For the ANSI
852
- # version of the function, this is the number of bytes; for the Unicode version, this is the number of
853
- # characters. If the string is longer than ( cchMax– 1), it will be truncated. If the psz parameter is
854
- # set to NULL, this parameter is ignored.
855
- # iCodePage:: [in] Code page used to render the string. This value should be either CP_WINANSI or CP_WINUNICODE.
856
- #
857
- # *Returns*:: If the psz parameter specified a valid pointer, the return value is the length, in TCHARs, of the
858
- # returned text (not including the terminating null character). If the psz parameter specified a NULL
859
- # pointer, the return value is the length of the text associated with the hsz parameter (not including
860
- # the terminating null character). If an error occurs, the return value is 0L.
861
- # ---
862
- # <b> Enhanced (snake_case) API makes all args optional except for first (dde instance id), and returns nil if
863
- # the function was unsuccessful.</b>
864
- # ---
865
- # *Remarks*
866
- # - The string returned in the buffer is always null-terminated. If the string is longer than ( cchMax– 1),
867
- # only the first ( cchMax– 1) characters of the string are copied.
868
- # - If the psz parameter is NULL, the DdeQueryString function obtains the length, in bytes, of the string
869
- # associated with the string handle. The length does not include the terminating null character.
870
- #
871
- # :call-seq:
872
- # string = dde_query_string( instance_id, handle, [code_page = CP_WINANSI ] )
873
- #
874
- function :DdeQueryString, [:uint32, :ulong, :pointer, :uint32, :int], :uint32,
875
- &->(api, instance_id, handle, code_page = CP_WINANSI){
876
- buffer = FFI::MemoryPointer.new :char, 1024
877
- num_chars = api.call(instance_id, handle, buffer, buffer.size, code_page)
878
- num_chars == 0 ? nil : buffer.get_bytes(0, num_chars) }
879
-
880
- ##
881
- # The DdeNameService function registers or unregisters the service names a Dynamic Data Exchange (DDE) server
882
- # supports. This function causes the system to send XTYP_REGISTER or XTYP_UNREGISTER transactions to other running
883
- # Dynamic Data Exchange Management Library (DDEML) client applications.
884
- #
885
- # [*Syntax*] HDDEDATA DdeNameService( DWORD idInst, UINT hsz1, UINT hsz2, UINT afCmd );
886
- #
887
- # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the DdeInitialize.
888
- # hsz1:: [in] Handle to the string that specifies the service name the server is registering or unregistering.
889
- # An application that is unregistering all of its service names should set this parameter to 0L.
890
- # hsz2:: Reserved; should be set to 0L.
891
- # afCmd:: [in] Specifies the service name options. This parameter can be one of the following values.
892
- # DNS_REGISTER:: Registers the service name.
893
- # DNS_UNREGISTER:: Unregisters the service name. If the hsz1 parameter is 0L,
894
- # all service names registered by the server will be unregistered.
895
- # DNS_FILTERON:: Turns on service name initiation filtering. The filter prevents a server from receiving
896
- # XTYP_CONNECT transactions for service names it has not registered. This is the default
897
- # setting for this filter. If a server application does not register any service names,
898
- # the application cannot receive XTYP_WILDCONNECT transactions.
899
- # DNS_FILTEROFF:: Turns off service name initiation filtering. If this flag is specified, the server
900
- # receives an XTYP_CONNECT transaction whenever another DDE application calls the
901
- # DdeConnect function, regardless of the service name.
902
- # *Returns*:: If the function succeeds, it returns nonzero (*true* in snake_case method). For CamelCase, that
903
- # value is not really HDDEDATA value, but merely a Boolean indicator of success. The function is
904
- # typed HDDEDATA to allow for future expansion of the function and more sophisticated returns.
905
- # If the function fails, the return value is 0L (*false* in snake_case method). The DdeGetLastError
906
- # function can be used to get the error code, which can be one of the following:
907
- # - DMLERR_DLL_NOT_INITIALIZED
908
- # - DMLERR_DLL_USAGE
909
- # - DMLERR_INVALIDPARAMETER
910
- # - DMLERR_NO_ERROR
911
- # ---
912
- # <b> Enhanced API accepts only 3 parameters (get rid of reserved hsz2) and returns boolean true/false. </b>
913
- # ---
914
- # *Remarks*:
915
- # The service name identified by the hsz1 parameter should be a base name (that is, the name should contain no
916
- # instance-specific information). The system generates an instance-specific name and sends it along with the
917
- # base name during the XTYP_REGISTER and XTYP_UNREGISTER transactions. The receiving applications can then
918
- # connect to the specific application instance.
919
- #
920
- # :call-seq:
921
- # success = dde_name_service( instance_id, string_handle, cmd )
922
- #
923
- function :DdeNameService, [:uint32, :ulong, :ulong, :uint], :ulong,
924
- &->(api, id, string_handle, cmd){ api.call(id, string_handle, 0, cmd) != 0 }
925
- # weird lambda literal instead of block is needed because RDoc goes crazy if block is attached to meta-definition
926
-
927
- ##
928
- # DdeConnect function establishes a conversation with a server application that supports the specified service
929
- # name and topic name pair. If more than one such server exists, the system selects only one.
930
- #
931
- # [*Syntax*] HCONV DdeConnect( DWORD idInst, HSZ hszService, HSZ hszTopic, PCONVCONTEXT pCC );
932
- #
933
- # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the DdeInitialize.
934
- # hszService:: [in] Handle to the string that specifies the service name of the server application with which
935
- # a conversation is to be established. This handle must have been created by a previous call to
936
- # the DdeCreateStringHandle function. If this parameter is 0L, a conversation is established with
937
- # any available server.
938
- # hszTopic:: [in] Handle to the string that specifies the name of the topic on which a conversation is to be
939
- # established. This handle must have been created by a previous call to DdeCreateStringHandle.
940
- # If this parameter is 0L, a conversation on any topic supported by the selected server is established.
941
- # pCC:: [in] Pointer to the CONVCONTEXT structure that contains conversation context information. If this
942
- # parameter is NULL, the server receives the default CONVCONTEXT structure during the XTYP_CONNECT
943
- # or XTYP_WILDCONNECT transaction.
944
- # *Returns*:: If the function succeeds, the return value is the handle to the established conversation.
945
- # If the function fails, the return value is 0L. The DdeGetLastError function can be used to get
946
- # the error code, which can be one of the following values:
947
- # - DMLERR_DLL_NOT_INITIALIZED
948
- # - DMLERR_INVALIDPARAMETER
949
- # - DMLERR_NO_CONV_ESTABLISHED
950
- # - DMLERR_NO_ERROR
951
- # ---
952
- # *Remarks*
953
- # - The client application cannot make assumptions regarding the server selected. If an instance-specific name
954
- # is specified in the hszService parameter, a conversation is established with only the specified instance.
955
- # Instance-specific service names are passed to an application's Dynamic Data Exchange (DDE) callback function
956
- # during the XTYP_REGISTER and XTYP_UNREGISTER transactions.
957
- # - All members of the default CONVCONTEXT structure are set to zero except cb, which specifies the size of the
958
- # structure, and iCodePage, which specifies CP_WINANSI (the default code page) or CP_WINUNICODE, depending on
959
- # whether the ANSI or Unicode version of the DdeInitialize function was called by the client application.
960
- # ---
961
- # <b>Enhanced (snake_case) API makes all args optional except for first (dde instance id), and returns nil if
962
- # the function was unsuccessful.</b>
963
- #
964
- # :call-seq:
965
- # conversation_handle = dde_connect( instance_id, [service = 0, topic = 0, context = nil] )
966
- #
967
- function :DdeConnect, [:uint32, :ulong, :ulong, :pointer], :ulong, zeronil: true,
968
- &->(api, instance_id, service = 0, topic = 0, context = nil){
969
- api.call(instance_id, service, topic, context) }
970
-
971
- ##
972
- # The DdeDisconnect function terminates a conversation started by either the DdeConnect or DdeConnectList function
973
- # and invalidates the specified conversation handle.
974
- #
975
- # [*Syntax*] BOOL DdeDisconnect( HCONV hConv );
976
- #
977
- # hConv:: [in, out] Handle to the active conversation to be terminated.
978
- #
979
- # *Returns*:: If the function succeeds, the return value is nonzero, otherwise zero. The DdeGetLastError function
980
- # can be used to get the error code, which can be one of the following values:
981
- # - DMLERR_DLL_NOT_INITIALIZED
982
- # - DMLERR_NO_CONV_ESTABLISHED
983
- # - DMLERR_NO_ERROR
984
- # ---
985
- # *Remarks*:
986
- # Any incomplete transactions started before calling DdeDisconnect are immediately abandoned. The XTYP_DISCONNECT
987
- # transaction is sent to the Dynamic Data Exchange (DDE) callback function of the partner in the conversation.
988
- # Generally, only client applications must terminate conversations.
989
- # ---
990
- # <b>Enhanced (snake_case) API returns *true/false* instead of nonzero/zero.</b>
991
- #
992
- # :call-seq:
993
- # success = dde_disconnect(conversation_handle)
994
- #
995
- function :DdeDisconnect, [:ulong], :int, boolean: true
996
-
997
-
998
- ##
999
- # The DdeGetLastError function retrieves the most recent error code set by the failure of a Dynamic Data Exchange
1000
- # Management Library (DDEML) function and resets the error code to DMLERR_NO_ERROR.
1001
- #
1002
- # [*Syntax*] UINT DdeGetLastError( DWORD idInst );
1003
- #
1004
- # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the DdeInitialize.
1005
- #
1006
- # *Returns*:: If the function succeeds, the return value is the last error code, which can be one of the following:
1007
- # DMLERR_ADVACKTIMEOUT, DMLERR_EXECACKTIMEOUT, DMLERR_INVALIDPARAMETER, DMLERR_LOW_MEMORY, DMLERR_MEMORY_ERROR,
1008
- # DMLERR_NO_CONV_ESTABLISHED, DMLERR_NOTPROCESSED, DMLERR_POKEACKTIMEOUT, DMLERR_POSTMSG_FAILED, DMLERR_REENTRANCY,
1009
- # DMLERR_SERVER_DIED, DMLERR_SYS_ERROR, DMLERR_UNADVACKTIMEOUT, DMLERR_UNFOUND_QUEUE_ID
1010
- # ---
1011
- # <b>Enhanced (snake_case) API returns *nil* if the function was unsuccessful (that is, no DDE errors raised).</b>
1012
- # ---
1013
- #
1014
- # :call-seq:
1015
- # string = dde_get_last_error( instance_id )
1016
- #
1017
- function :DdeGetLastError, [:uint32], :int, zeronil: true
1018
-
1019
- ##
1020
- # The DdeClientTransaction function begins a data transaction between a client and a server. Only a
1021
- # Dynamic Data Exchange (DDE) client application can call this function, and the application can use it
1022
- # only after establishing a conversation with the server.
1023
- #
1024
- # [*Syntax*] HDDEDATA DdeClientTransaction( LPBYTE pData, DWORD cbData, HCONV hConv, HSZ hszItem, UINT
1025
- # wFmt, UINT wType, DWORD dwTimeout, LPDWORD pdwResult );
1026
- #
1027
- # pData:: [in] Pointer to the beginning of the data the client must pass to the server.
1028
- # Optionally, an application can specify the data handle (HDDEDATA) to pass to the server and in that
1029
- # case the cbData parameter should be set to -1. This parameter is required only if the wType parameter
1030
- # is XTYP_EXECUTE or XTYP_POKE. Otherwise, this parameter should be NULL.
1031
- # For the optional usage of this parameter, XTYP_POKE transactions where pData is a data handle, the
1032
- # handle must have been created by a previous call to the DdeCreateDataHandle function, employing the
1033
- # same data format specified in the wFmt parameter.
1034
- # cbData:: [in] Specifies the length, in bytes, of the data pointed to by the pData parameter, including
1035
- # the terminating NULL, if the data is a string. A value of -1 indicates that pData is a data
1036
- # handle that identifies the data being sent.
1037
- # hConv:: [in] Handle to the conversation in which the transaction is to take place.
1038
- # hszItem:: [in] Handle to the data item for which data is being exchanged during the transaction. This
1039
- # handle must have been created by a previous call to the DdeCreateStringHandle function. This
1040
- # parameter is ignored (and should be set to 0L) if the wType parameter is XTYP_EXECUTE.
1041
- # wFmt:: [in] Specifies the standard clipboard format in which the data item is being submitted or
1042
- # requested. If the transaction specified by the wType parameter does not pass data or is XTYP_EXECUTE,
1043
- # this parameter should be zero.
1044
- # If the transaction specified by the wType parameter references non-execute DDE data ( XTYP_POKE,
1045
- # XTYP_ADVSTART, XTYP_ADVSTOP, XTYP_REQUEST), the wFmt value must be either a valid predefined (CF_) DDE
1046
- # format or a valid registered clipboard format.
1047
- # wType:: [in] Specifies the transaction type. This parameter can be one of the following values.
1048
- # - XTYP_ADVSTART: Begins an advise loop. Any number of distinct advise loops can exist within a
1049
- # conversation. An application can alter the advise loop type by combining the XTYP_ADVSTART
1050
- # transaction type with one or more of the following flags: Flag Meaning
1051
- # - XTYPF_NODATA Instructs the server to notify the client of any data changes without actually sending
1052
- # the data. This flag gives the client the option of ignoring the notification or requesting the changed
1053
- # data from the server.
1054
- # - XTYPF_ACKREQ Instructs the server to wait until the client acknowledges that it received the previous
1055
- # data item before sending the next data item. This flag prevents a fast server from sending data faster
1056
- # than the client can process it.
1057
- # - XTYP_ADVSTOP: Ends an advise loop.
1058
- # - XTYP_EXECUTE: Begins an execute transaction.
1059
- # - XTYP_POKE: Begins a poke transaction.
1060
- # - XTYP_REQUEST: Begins a request transaction.
1061
- # dwTimeout:: [in] Specifies the maximum amount of time, in milliseconds, that the client will wait for
1062
- # a response from the server application in a synchronous transaction. This parameter should
1063
- # be TIMEOUT_ASYNC for asynchronous transactions.
1064
- # pdwResult:: [out] Pointer to a variable that receives the result of the transaction. An application
1065
- # that does not check the result can use NULL for this value. For synchronous transactions,
1066
- # the low-order word of this variable contains any applicable DDE_ flags resulting from the
1067
- # transaction. This provides support for applications dependent on DDE_APPSTATUS bits. It
1068
- # is, however, recommended that applications no longer use these bits because they may not
1069
- # be supported in future versions of the Dynamic Data Exchange Management Library (DDEML).
1070
- # For asynchronous transactions, this variable is filled with a unique transaction
1071
- # identifier for use with the DdeAbandonTransaction function and the XTYP_XACT_COMPLETE
1072
- # transaction.
1073
- #
1074
- # *Returns*:: If the function succeeds, the return value is a data handle that identifies the data for
1075
- # successful synchronous transactions in which the client expects data from the server. The
1076
- # return value is nonzero for successful asynchronous transactions and for synchronous
1077
- # transactions in which the client does not expect data. The return value is zero for all
1078
- # unsuccessful transactions.
1079
- # The DdeGetLastError function can be used to get the error code, which can be one of the following values:
1080
- # - DMLERR_ADVACKTIMEOUT
1081
- # - DMLERR_BUSY
1082
- # - DMLERR_DATAACKTIMEOUT
1083
- # - DMLERR_DLL_NOT_INITIALIZED
1084
- # - DMLERR_EXECACKTIMEOUT
1085
- # - DMLERR_INVALIDPARAMETER
1086
- # - DMLERR_MEMORY_ERROR
1087
- # - DMLERR_NO_CONV_ESTABLISHED
1088
- # - DMLERR_NO_ERROR
1089
- # - DMLERR_NOTPROCESSED
1090
- # - DMLERR_POKEACKTIMEOUT
1091
- # - DMLERR_POSTMSG_FAILED
1092
- # - DMLERR_REENTRANCY
1093
- # - DMLERR_SERVER_DIED
1094
- # - DMLERR_UNADVACKTIMEOUT
1095
- # ---
1096
- # *Remarks*:
1097
- # When an application has finished using the data handle returned by DdeClientTransaction, the application should
1098
- # free the handle by calling the DdeFreeDataHandle function.
1099
- #
1100
- #Transactions can be synchronous or asynchronous. During a synchronous transaction, DdeClientTransaction does not
1101
- # return until the transaction either completes successfully or fails. Synchronous transactions cause a client to
1102
- # enter a modal loop while waiting for various asynchronous events. Because of this, a client application can still
1103
- # respond to user input while waiting on a synchronous transaction, but the application cannot begin a second
1104
- # synchronous transaction because of the activity associated with the first. DdeClientTransaction fails if any
1105
- # instance of the same task has a synchronous transaction already in progress.
1106
- #
1107
- # During an asynchronous transaction, DdeClientTransaction returns after the transaction has begun,
1108
- # passing a transaction identifier for reference. When the server's DDE callback function finishes
1109
- # processing an asynchronous transaction, the system sends an XTYP_XACT_COMPLETE transaction to the
1110
- # client. This transaction provides the client with the results of the asynchronous transaction that it
1111
- # initiated by calling DdeClientTransaction. A client application can choose to abandon an asynchronous
1112
- # transaction by calling the DdeAbandonTransaction function.
1113
- # ---
1114
- # <b>Enhanced (snake_case) API: </b>
1115
- #
1116
- # :call-seq:
1117
- # data_handle = dde_client_transaction(data_pointer, size, conv, item, format, type, timeout, result)
1118
- #
1119
- function :DdeClientTransaction, [:pointer, :uint32, :ulong, :ulong, :uint, :uint, :uint32, :pointer],
1120
- :HDDEDATA, zeronil: true
1121
-
1122
- ##
1123
- # The DdeGetData function copies data from the specified Dynamic Data Exchange (DDE) object to the specified
1124
- # local buffer.
1125
- #
1126
- # [*Syntax*] DWORD DdeGetData( HDDEDATA hData, LPBYTE pDst, DWORD cbMax, DWORD cbOff );
1127
- #
1128
- # hData:: [in] Handle to the DDE object that contains the data to copy.
1129
- # pDst:: [out] Pointer to the buffer that receives the data. If this parameter is NULL, the DdeGetData
1130
- # function returns the amount of data, in bytes, that would be copied to the buffer.
1131
- # cbMax:: [in] Specifies the maximum amount of data, in bytes, to copy to the buffer pointed to by the pDst
1132
- # parameter. Typically, this parameter specifies the length of the buffer pointed to by pDst.
1133
- # cbOff:: [in] Specifies an offset within the DDE object. Data is copied from the object beginning at this offset.
1134
- #
1135
- # *Returns*:: If the pDst parameter points to a buffer, return value is the size, in bytes, of the memory object
1136
- # associated with the data handle or the size specified in the cbMax parameter, whichever is lower.
1137
- # If the pDst parameter is NULL, the return value is the size, in bytes, of the memory object
1138
- # associated with the data handle.
1139
- # The DdeGetLastError function can be used to get the error code, which can be one of the following:
1140
- # - DMLERR_DLL_NOT_INITIALIZED
1141
- # - DMLERR_INVALIDPARAMETER
1142
- # - DMLERR_NO_ERROR
1143
- # ---
1144
- # <b> Enhanced (snake_case) API accepts data handle, and optionally max and offset (no need to pre-allocate
1145
- # buffer). It returns pointer to copied DDE data (FFI::MemoryPointer) and size of copied data in bytes.
1146
- # In case of failure, it returns [nil, 0]. This API is the same as for enhanced dde_access_data.
1147
- # No need to call function twice (first time with nil buffer just to determine length).</b>
1148
- # ---
1149
- #
1150
- # :call-seq:
1151
- # buffer, size = dde_get_data( data_handle, [max = infinite, offset = 0] )
1152
- #
1153
- function :DdeGetData, [:ulong, :pointer, :uint32, :uint32], :uint,
1154
- &->(api, data_handle, max=1073741823, offset=0){ # max is maximum DWORD Fixnum
1155
- size = api.call(data_handle, nil, 0, 0) # determining data set length
1156
- if size == 0
1157
- [nil, 0]
1158
- else
1159
- copy_size = size < max ? size : max
1160
- buffer = FFI::MemoryPointer.new(:char, offset + copy_size)
1161
- size = api.call(data_handle, buffer, copy_size, offset)
1162
- [buffer, size]
1163
- end }
1164
- # weird lambda literal instead of block is needed because RDoc goes crazy if block is attached to meta-definition
1165
-
1166
-
1167
- ##
1168
- # The DdeAccessData function provides access to the data in the specified Dynamic Data Exchange (DDE)
1169
- # object. An application must call the DdeUnaccessData function when it has finished accessing the data
1170
- # in the object.
1171
- #
1172
- # [*Syntax*] LPBYTE DdeAccessData( HDDEDATA hData, LPDWORD pcbDataSize );
1173
- #
1174
- # hData:: [in] Handle to the DDE object to access.
1175
- # pcbDataSize:: [out] Pointer to a variable that receives the size, in bytes, of the DDE object
1176
- # identified by the hData parameter. If this parameter is NULL, no size information is
1177
- # returned.
1178
- #
1179
- # *Returns*:: If the function succeeds, the return value is a pointer to the first byte of data in the
1180
- # DDE object.
1181
- # If the function fails, the return value is NULL.
1182
- # The DdeGetLastError function can be used to get the error code, which can be one of the following
1183
- # values:
1184
- # DMLERR_DLL_NOT_INITIALIZED
1185
- # DMLERR_INVALIDPARAMETER
1186
- # DMLERR_NO_ERROR
1187
- # ---
1188
- # *Remarks*:
1189
- # If the hData parameter has not been passed to a Dynamic Data Exchange Management Library (DDEML)
1190
- # function, an application can use the pointer returned by DdeAccessData for read-write access to the
1191
- # DDE object. If hData has already been passed to a DDEML function, the pointer should be used only for
1192
- # read access to the memory object.
1193
- #
1194
- # ---
1195
- # <b>Enhanced (snake_case) API accepts DDE data handle and returns FFI::MemoryPointer to raw data and
1196
- # size of data set in bytes (same API as enhanced dde_get_data). Returns [nil, 0] in case of failure. </b>
1197
- #
1198
- # :call-seq:
1199
- # data_pointer, size = dde_access_data( data_handle )
1200
- #
1201
- function :DdeAccessData, [:HDDEDATA, :pointer], :pointer,
1202
- &->(api, data_handle){
1203
- size_buffer = FFI::MemoryPointer.new(:uint32)
1204
- buffer = api.call(data_handle, size_buffer)
1205
- size = size_buffer.get_uint32(0)
1206
- size == 0 ? [nil, 0] : [buffer, size] }
1207
- # weird lambda literal instead of block is needed because RDoc goes crazy if block is attached to meta-definition
1208
-
1209
- ##
1210
- # The DdeUnaccessData function unaccesses a Dynamic Data Exchange (DDE) object. An application must call
1211
- # this function after it has finished accessing the object.
1212
- #
1213
- # [*Syntax*] BOOL DdeUnaccessData( HDDEDATA hData );
1214
- #
1215
- # hData:: [in] Handle to the DDE object.
1216
- #
1217
- # *Returns*:: If the function succeeds, the return value is nonzero.
1218
- # If the function fails, the return value is zero.
1219
- # The DdeGetLastError function can be used to get the error code, which can be one of the following
1220
- # values:
1221
- # DMLERR_DLL_NOT_INITIALIZED
1222
- # DMLERR_INVALIDPARAMETER
1223
- # DMLERR_NO_ERROR
1224
- #
1225
- # ---
1226
- # <b>Enhanced (snake_case) API returns true/false instead of nonzero/zero: </b>
1227
- #
1228
- # :call-seq:
1229
- # success = dde_unaccess_data(data_handle)
1230
- #
1231
- function :DdeUnaccessData, [:HDDEDATA], :int8, boolean: true
1232
-
1233
- end
1234
- end
1
+ require 'win/library'
2
+
3
+ module Win
4
+
5
+ # Includes functions related to DDE exchange protocol in Windows
6
+ #
7
+ module Dde
8
+ include Win::Library
9
+
10
+ # Windows ANSI codepage:
11
+ CP_WINANSI = 1004
12
+
13
+ # DDE name service afCmd commands used by DdeNameService function:
14
+
15
+ # Registers the service name.
16
+ DNS_REGISTER = 1
17
+ # Unregisters the service name. When hsz1 == 0L, ALL service names registered by the server will be unregistered.
18
+ DNS_UNREGISTER = 2
19
+ # Turns on service name initiation filtering. The filter prevents a server from receiving
20
+ # XTYP_CONNECT transactions for service names it has not registered. This is the default
21
+ # setting for this filter. If a server application does not register any service names,
22
+ # the application cannot receive XTYP_WILDCONNECT transactions.
23
+ DNS_FILTERON = 4
24
+ # Turns off service name initiation filtering. If this flag is specified, the server
25
+ # receives an XTYP_CONNECT transaction whenever another DDE application calls the
26
+ # DdeConnect function, regardless of the service name.
27
+ DNS_FILTEROFF = 8
28
+
29
+ # Transaction confirmations:
30
+
31
+ # Transaction confirmation
32
+ DDE_FACK = 0x8000
33
+ # Server is too busy to process transaction
34
+ DDE_FBUSY = 0x4000
35
+ DDE_FDEFERUPD = 0x4000
36
+ DDE_FACKREQ = 0x8000
37
+ DDE_FRELEASE = 0x2000
38
+ DDE_FREQUESTED = 0x1000
39
+ DDE_FAPPSTATUS = 0x00ff
40
+ # Transaction rejected
41
+ DDE_FNOTPROCESSED = 0
42
+
43
+ # Transaction types:
44
+
45
+ XTYPF_NOBLOCK = 0x0002
46
+ XTYPF_NODATA = 0x0004
47
+ XTYPF_ACKREQ = 0x0008
48
+
49
+ XCLASS_MASK = 0xFC00
50
+ XCLASS_BOOL = 0x1000
51
+ XCLASS_DATA = 0x2000
52
+ XCLASS_FLAGS = 0x4000
53
+ XCLASS_NOTIFICATION = 0x8000
54
+
55
+ XTYP_ERROR = XCLASS_NOTIFICATION | XTYPF_NOBLOCK
56
+ XTYP_ADVDATA = 0x0010 | XCLASS_FLAGS
57
+ XTYP_ADVREQ = 0x0020 | XCLASS_DATA | XTYPF_NOBLOCK
58
+ XTYP_ADVSTART = 0x0030 | XCLASS_BOOL
59
+ XTYP_ADVSTOP = 0x0040 | XCLASS_NOTIFICATION
60
+ XTYP_EXECUTE = 0x0050 | XCLASS_FLAGS
61
+ # A client uses the XTYP_CONNECT transaction to establish a conversation. A DDE server callback function,
62
+ # DdeCallback, receives this transaction when a client specifies a service name that the server supports
63
+ # (and a topic name that is not NULL) in a call to the DdeConnect function.
64
+ XTYP_CONNECT = 0x0060 | XCLASS_BOOL | XTYPF_NOBLOCK
65
+ XTYP_CONNECT_CONFIRM = 0x0070 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK
66
+ XTYP_XACT_COMPLETE = 0x0080 | XCLASS_NOTIFICATION
67
+ # A client uses the XTYP_POKE transaction to send unsolicited data to the server. DDE server callback function,
68
+ # DdeCallback, receives this transaction when a client specifies XTYP_POKE in the DdeClientTransaction function.
69
+ XTYP_POKE = 0x0090 | XCLASS_FLAGS
70
+ XTYP_REGISTER = 0x00A0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK
71
+ XTYP_REQUEST = 0x00B0 | XCLASS_DATA
72
+ XTYP_DISCONNECT = 0x00C0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK
73
+ XTYP_UNREGISTER = 0x00D0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK
74
+ XTYP_WILDCONNECT = 0x00E0 | XCLASS_DATA | XTYPF_NOBLOCK
75
+ XTYP_MONITOR = 0X00F0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK
76
+ XTYP_MASK = 0x00F0
77
+ XTYP_SHIFT = 0x0004
78
+
79
+ # Types Hash {TRANSACTION_TYPE=>'Type description')}
80
+ TYPES = {
81
+ XTYPF_NOBLOCK => 'XTYPF_NOBLOCK',
82
+ XTYPF_NODATA => 'XTYPF_NODATA',
83
+ XTYPF_ACKREQ => 'XTYPF_ACKREQ',
84
+ XCLASS_MASK => 'XCLASS_MASK',
85
+ XCLASS_BOOL => 'XCLASS_BOOL',
86
+ XCLASS_DATA => 'XCLASS_DATA',
87
+ XCLASS_FLAGS => 'XCLASS_FLAGS',
88
+ XCLASS_NOTIFICATION => 'XCLASS_NOTIFICATION',
89
+ XTYP_ERROR => 'XTYP_ERROR',
90
+ XTYP_ADVDATA => 'XTYP_ADVDATA',
91
+ XTYP_ADVREQ => 'XTYP_ADVREQ',
92
+ XTYP_ADVSTART => 'XTYP_ADVSTART',
93
+ XTYP_ADVSTOP => 'XTYP_ADVSTOP',
94
+ XTYP_EXECUTE => 'XTYP_EXECUTE',
95
+ XTYP_CONNECT => 'XTYP_CONNECT',
96
+ XTYP_CONNECT_CONFIRM=> 'XTYP_CONNECT_CONFIRM',
97
+ XTYP_XACT_COMPLETE => 'XTYP_XACT_COMPLETE',
98
+ XTYP_POKE => 'XTYP_POKE',
99
+ XTYP_REGISTER => 'XTYP_REGISTER',
100
+ XTYP_REQUEST => 'XTYP_REQUEST',
101
+ XTYP_DISCONNECT => 'XTYP_DISCONNECT',
102
+ XTYP_UNREGISTER => 'XTYP_UNREGISTER',
103
+ XTYP_WILDCONNECT => 'XTYP_WILDCONNECT',
104
+ XTYP_MONITOR => 'XTYP_MONITOR',
105
+ XTYP_MASK => 'XTYP_MASK',
106
+ XTYP_SHIFT => 'XTYP_SHIFT'
107
+ }
108
+
109
+
110
+ # DdeInitialize afCmd flaggs:
111
+
112
+ # Registers the application as a standard (nonmonitoring) DDEML application.
113
+ APPCLASS_STANDARD = 0
114
+ # Makes it possible for the application to monitor DDE activity in the system.
115
+ # This flag is for use by DDE monitoring applications. The application specifies the types of DDE
116
+ # activity to monitor by combining one or more monitor flags with the APPCLASS_MONITOR flag.
117
+ APPCLASS_MONITOR = 0x00000001
118
+ # ?
119
+ APPCLASS_MASK = 0x0000000F
120
+ # Prevents the application from becoming a server in a DDE conversation. The application can only be a client.
121
+ # This flag reduces consumption of resources by the DDEML. It includes the CBF_FAIL_ALLSVRXACTIONS flag.
122
+ APPCMD_CLIENTONLY = 0x00000010
123
+ # Prevents the DDEML from sending XTYP_CONNECT and XTYP_WILDCONNECT transactions to the application until
124
+ # the application has created its string handles and registered its service names or has turned off filtering
125
+ # by a subsequent call to the DdeNameService or DdeInitialize function. This flag is always in effect when an
126
+ # application calls DdeInitialize for the first time, regardless of whether the application specifies the flag.
127
+ # On subsequent calls to DdeInitialize, not specifying this flag turns off the application's service-name
128
+ # filters, but specifying it turns on the application's service name filters.
129
+ APPCMD_FILTERINITS = 0x00000020
130
+ # ?
131
+ APPCMD_MASK = 0x00000FF0
132
+ # Prevents the callback function from receiving XTYP_CONNECT transactions from the application's own instance.
133
+ # This flag prevents an application from establishing a DDE conversation with its own instance. An application
134
+ # should use this flag if it needs to communicate with other instances of itself but not with itself.
135
+ CBF_FAIL_SELFCONNECTIONS = 0x00001000
136
+ # Prevents the callback function from receiving XTYP_CONNECT and XTYP_WILDCONNECT.
137
+ CBF_FAIL_CONNECTIONS = 0x00002000
138
+ # Prevents the callback function from receiving XTYP_ADVSTART and XTYP_ADVSTOP transactions. The system returns
139
+ # DDE_FNOTPROCESSED to each client that sends an XTYP_ADVSTART or XTYP_ADVSTOP transaction to the server.
140
+ CBF_FAIL_ADVISES = 0x00004000
141
+ # Prevents the callback function from receiving XTYP_EXECUTE transactions. The system returns DDE_FNOTPROCESSED
142
+ # to a client that sends an XTYP_EXECUTE transaction to the server.
143
+ CBF_FAIL_EXECUTES = 0x00008000
144
+ # Prevents the callback function from receiving XTYP_POKE transactions. The system returns DDE_FNOTPROCESSED
145
+ # to a client that sends an XTYP_POKE transaction to the server.
146
+ CBF_FAIL_POKES = 0x00010000
147
+ # Prevents the callback function from receiving XTYP_REQUEST transactions. The system returns DDE_FNOTPROCESSED
148
+ # to a client that sends an XTYP_REQUEST transaction to the server.
149
+ CBF_FAIL_REQUESTS = 0x00020000
150
+ # Prevents the callback function from receiving server transactions. The system returns DDE_FNOTPROCESSED to each
151
+ # client that sends a transaction to this application. This flag is equivalent to combining all CBF_FAIL_ flags.
152
+ CBF_FAIL_ALLSVRXACTIONS = 0x0003f000
153
+ # Prevents the callback function from receiving XTYP_CONNECT_CONFIRM.
154
+ CBF_SKIP_CONNECT_CONFIRMS = 0x00040000
155
+ # Prevents the callback function from receiving XTYP_REGISTER notifications.
156
+ CBF_SKIP_REGISTRATIONS = 0x00080000
157
+ # Prevents the callback function from receiving XTYP_UNREGISTER notifications.
158
+ CBF_SKIP_UNREGISTRATIONS = 0x00100000
159
+ # Prevents the callback function from receiving XTYP_DISCONNECT notifications.
160
+ CBF_SKIP_DISCONNECTS = 0x00200000
161
+ # Prevents the callback function from receiving any notifications. Equivalent to combining all CBF_SKIP_ flags.
162
+ CBF_SKIP_ALLNOTIFICATIONS = 0x003c0000
163
+ # Notifies the callback function whenever a DDE application creates, frees, or increments the usage count of
164
+ # a string handle or whenever a string handle is freed as a result of a call to the DdeUninitialize function.
165
+ MF_HSZ_INFO = 0x01000000
166
+ # Notifies the callback function whenever the system or an application sends a DDE message.
167
+ MF_SENDMSGS = 0x02000000
168
+ # Notifies the callback function whenever the system or an application posts a DDE message.
169
+ MF_POSTMSGS = 0x04000000
170
+ # Notifies the callback function whenever a transaction is sent to any DDE callback function in the system.
171
+ MF_CALLBACKS = 0x08000000
172
+ # Notifies the callback function whenever a DDE error occurs.
173
+ MF_ERRORS = 0x10000000
174
+ # Notifies the callback function whenever an advise loop is started or ended.
175
+ MF_LINKS = 0x20000000
176
+ # Notifies the callback function whenever a conversation is established or terminated.
177
+ MF_CONV = 0x40000000
178
+ # ?
179
+ MF_MASK = 0xFF000000
180
+
181
+ # Flags Hash {FLAG=>'Flag description')}
182
+ FLAGS = {
183
+ APPCLASS_STANDARD => 'APPCLASS_STANDARD',
184
+ APPCLASS_MONITOR => 'APPCLASS_MONITOR',
185
+ APPCLASS_MASK => 'APPCLASS_MASK',
186
+ APPCMD_CLIENTONLY => 'APPCMD_CLIENTONLY',
187
+ APPCMD_FILTERINITS => 'APPCMD_FILTERINITS',
188
+ APPCMD_MASK => 'APPCMD_MASK',
189
+ CBF_FAIL_SELFCONNECTIONS => 'CBF_FAIL_SELFCONNECTIONS',
190
+ CBF_FAIL_CONNECTIONS => 'CBF_FAIL_CONNECTIONS',
191
+ CBF_FAIL_ADVISES => 'CBF_FAIL_ADVISES',
192
+ CBF_FAIL_EXECUTES => 'CBF_FAIL_EXECUTES',
193
+ CBF_FAIL_POKES => 'CBF_FAIL_POKES',
194
+ CBF_FAIL_REQUESTS => 'CBF_FAIL_REQUESTS',
195
+ CBF_FAIL_ALLSVRXACTIONS => 'CBF_FAIL_ALLSVRXACTIONS',
196
+ CBF_SKIP_CONNECT_CONFIRMS => 'CBF_SKIP_CONNECT_CONFIRMS',
197
+ CBF_SKIP_REGISTRATIONS => 'CBF_SKIP_REGISTRATIONS',
198
+ CBF_SKIP_UNREGISTRATIONS => 'CBF_SKIP_UNREGISTRATIONS',
199
+ CBF_SKIP_DISCONNECTS => 'CBF_SKIP_DISCONNECTS',
200
+ CBF_SKIP_ALLNOTIFICATIONS => 'CBF_SKIP_ALLNOTIFICATIONS',
201
+ MF_HSZ_INFO => 'MF_HSZ_INFO',
202
+ MF_SENDMSGS => 'MF_SENDMSGS',
203
+ MF_POSTMSGS => 'MF_POSTMSGS',
204
+ MF_CALLBACKS => 'MF_CALLBACKS',
205
+ MF_ERRORS => 'MF_ERRORS',
206
+ MF_LINKS => 'MF_LINKS',
207
+ MF_CONV => 'MF_CONV',
208
+ MF_MASK => 'MF_MASK'
209
+ }
210
+
211
+ # Error codes:
212
+
213
+ # Returned if DDE Init successful
214
+ DMLERR_NO_ERROR = 0x00
215
+ # First (lowest) error code
216
+ DMLERR_FIRST = 0x4000
217
+ # A request for a synchronous advise transaction has timed out.
218
+ DMLERR_ADVACKTIMEOUT = DMLERR_FIRST
219
+ # The response to the transaction caused the DDE_FBUSY flag to be set
220
+ DMLERR_BUSY = 0x4001
221
+ # A request for a synchronous data transaction has timed out.
222
+ DMLERR_DATAACKTIMEOUT = 0x4002
223
+ # A DDEML function was called without first calling the DdeInitialize function, or an invalid instance
224
+ # identifier was passed to a DDEML function.
225
+ DMLERR_DLL_NOT_INITIALIZED = 0x4003
226
+ # An application initialized as APPCLASS_MONITOR has attempted to perform a Dynamic Data Exchange (DDE) transaction,
227
+ # or an application initialized as APPCMD_CLIENTONLY has attempted to perform server transactions.
228
+ DMLERR_DLL_USAGE = 0x4004
229
+ # A request for a synchronous execute transaction has timed out.
230
+ DMLERR_EXECACKTIMEOUT = 0x4005
231
+ # A parameter failed to be validated by the DDEML. Some of the possible causes follow:
232
+ # - The application used a data handle initialized with a different item name handle than was required by the
233
+ # transaction.
234
+ # - The application used a data handle that was initialized with a different clipboard data format than was
235
+ # required by the transaction.
236
+ # - The application used a client-side conversation handle with a server-side function or vice versa.
237
+ # - The application used a freed data handle or string handle.
238
+ # - More than one instance of the application used the same object.
239
+ DMLERR_INVALIDPARAMETER = 0x4006
240
+ # A DDEML application has created a prolonged race condition (in which the server application
241
+ # outruns the client), causing large amounts of memory to be consumed.
242
+ DMLERR_LOW_MEMORY = 0x4007
243
+ # A memory allocation has failed.
244
+ DMLERR_MEMORY_ERROR = 0x4008
245
+ # A transaction has failed.
246
+ DMLERR_NOTPROCESSED = 0x4009
247
+ # A client's attempt to establish a conversation has failed.
248
+ DMLERR_NO_CONV_ESTABLISHED = 0x400a
249
+ # A request for a synchronous poke transaction has timed out.
250
+ DMLERR_POKEACKTIMEOUT = 0x400b
251
+ # An internal call to the PostMessage function has failed.
252
+ DMLERR_POSTMSG_FAILED = 0x400c
253
+ # An application instance with a synchronous transaction already in progress attempted to initiate another
254
+ # synchronous transaction, or the DdeEnableCallback function was called from within a DDEML callback function.
255
+ DMLERR_REENTRANCY = 0x400d
256
+ # A server-side transaction was attempted on a conversation terminated by the client, or the server terminated
257
+ # before completing a transaction.
258
+ DMLERR_SERVER_DIED = 0x400e
259
+ # An internal error has occurred in the DDEML.
260
+ DMLERR_SYS_ERROR = 0x400f
261
+ # A request to end an advise transaction has timed out.
262
+ DMLERR_UNADVACKTIMEOUT = 0x4010
263
+ # An invalid transaction identifier was passed to a DDEML function. Once the application has returned from an
264
+ # XTYP_XACT_COMPLETE callback, the transaction identifier for that callback function is no longer valid.
265
+ DMLERR_UNFOUND_QUEUE_ID = 0x4011
266
+ # Last (highest) error code
267
+ DMLERR_LAST = DMLERR_UNFOUND_QUEUE_ID
268
+
269
+ # Errors Hash {ERROR_CODE=>'Error description')}
270
+ ERRORS = {
271
+ nil => 'No DDEML error',
272
+ DMLERR_NO_ERROR => 'No DDEML error',
273
+ DMLERR_ADVACKTIMEOUT => 'A request for a synchronous advise transaction has timed out.',
274
+ DMLERR_BUSY => 'The response to the transaction caused the DDE_FBUSY flag to be set.',
275
+ DMLERR_DATAACKTIMEOUT => 'A request for a synchronous data transaction has timed out.',
276
+ DMLERR_DLL_NOT_INITIALIZED => 'A DDEML function was called without first calling the DdeInitialize ' +
277
+ 'function, or an invalid instance identifier was passed to a DDEML function.',
278
+ DMLERR_DLL_USAGE => 'An application initialized as APPCLASS_MONITOR has attempted to perform a DDE ' +
279
+ 'transaction, or an application initialized as APPCMD_CLIENTONLY has attempted to perform ' +
280
+ 'server transactions.',
281
+ DMLERR_EXECACKTIMEOUT => 'A request for a synchronous execute transaction has timed out.',
282
+ DMLERR_INVALIDPARAMETER => 'A parameter failed to be validated by the DDEML. Possible causes: ' +
283
+ 'Application used a data handle initialized with a different item name handle than was required ' +
284
+ 'by the transaction. ' +
285
+ 'The application used a data handle that was initialized with a different clipboard data format ' +
286
+ 'than was required by the transaction. ' +
287
+ 'The application used a client-side conversation handle with server-side function or vice versa. ' +
288
+ 'The application used a freed data handle or string handle. ' +
289
+ 'More than one instance of the application used the same object.',
290
+ DMLERR_LOW_MEMORY => 'A DDEML application has created a prolonged race condition (in which the server ' +
291
+ 'application outruns the client), causing large amounts of memory to be consumed.',
292
+ DMLERR_MEMORY_ERROR => 'A memory allocation has failed.',
293
+ DMLERR_NO_CONV_ESTABLISHED => 'A client`s attempt to establish a conversation has failed.',
294
+ DMLERR_NOTPROCESSED => 'A transaction has failed.',
295
+ DMLERR_POKEACKTIMEOUT => 'A request for a synchronous poke transaction has timed out.',
296
+ DMLERR_POSTMSG_FAILED => 'An internal call to the PostMessage function has failed.',
297
+ DMLERR_REENTRANCY => 'An application instance with a synchronous transaction already in progress ' +
298
+ 'attempted to initiate another synchronous transaction, or the DdeEnableCallback function ' +
299
+ 'was called from within a DDEML callback function.',
300
+ DMLERR_SERVER_DIED => 'A server-side transaction was attempted on a conversation terminated by the ' +
301
+ 'client, or the server terminated before completing a transaction.',
302
+ DMLERR_SYS_ERROR => 'An internal error has occurred in the DDEML.',
303
+ DMLERR_UNADVACKTIMEOUT => 'A request to end an advise transaction has timed out.',
304
+ DMLERR_UNFOUND_QUEUE_ID => 'An invalid transaction identifier was passed to a DDEML function. Once the ' +
305
+ 'application has returned from an XTYP_XACT_COMPLETE callback, the transaction identifier for ' +
306
+ 'that callback function is no longer valid.'
307
+ }
308
+
309
+ # Predefined Clipboard Formats:
310
+
311
+ # The simplest form of Clipboard data. It is a null-terminated string containing a carriage return
312
+ # and linefeed at the end of each line.
313
+ CF_TEXT = 1
314
+ # A Windows version 2.x-compatible bitmap
315
+ CF_BITMAP = 2
316
+ # A metafile picture structure. See docs for Microsoft Windows Software Development Kit.
317
+ CF_METAFILEPICT = 3
318
+ # Microsoft symbolic link (SYLK) format. Microsoft Excel for the Apple Macintosh was originally designed to use
319
+ # SYLK format, and this format is now supported by Microsoft Excel on both the Windows and Macintosh platforms
320
+ CF_SYLK = 4
321
+ # An ASCII format used by the VisiCalc spreadsheet program
322
+ CF_DIF = 5
323
+ CF_TIFF = 6
324
+ CF_OEMTEXT = 7
325
+ CF_DIB = 8
326
+ CF_PALETTE = 9
327
+ CF_PENDATA = 10
328
+ CF_RIFF = 11
329
+ CF_WAVE = 12
330
+ CF_UNICODETEXT = 13
331
+ CF_ENHMETAFILE = 14
332
+ # Filename copied to clipboard
333
+ CF_HDROP = 15
334
+ CF_LOCALE = 16
335
+ CF_MAX = 17
336
+
337
+ # DdeClientTransaction timeout value indicating async transaction
338
+ TIMEOUT_ASYNC = 0xFFFFFFFF
339
+
340
+ # The MONCBSTRUCT structure contains information about the current Dynamic Data Exchange (DDE)
341
+ # transaction. A DDE debugging application can use this structure when monitoring transactions that the
342
+ # system passes to the DDE callback functions of other applications.
343
+ #
344
+ # [*Typedef*] struct { UINT cb; DWORD dwTime; HANDLE hTask; DWORD dwRet; UINT wType; UINT wFmt; HCONV
345
+ # hConv; HSZ hsz1; HSZ hsz2; HDDEDATA hData; ULONG_PTR dwData1; ULONG_PTR dwData2;
346
+ # CONVCONTEXT cc; DWORD cbData; DWORD Data[8] } MONCBSTRUCT;
347
+ #
348
+ # cb:: Specifies the structure's size, in bytes.
349
+ # dwTime:: Specifies the Windows time at which the transaction occurred. Windows time is the number of
350
+ # milliseconds that have elapsed since the system was booted.
351
+ # hTask:: Handle to the task (app instance) containing the DDE callback function that received the transaction.
352
+ # dwRet:: Specifies the value returned by the DDE callback function that processed the transaction.
353
+ # wType:: Specifies the transaction type.
354
+ # wFmt:: Specifies the format of the data exchanged (if any) during the transaction.
355
+ # hConv:: Handle to the conversation in which the transaction took place.
356
+ # hsz1:: Handle to a string.
357
+ # hsz2:: Handle to a string.
358
+ # hData:: Handle to the data exchanged (if any) during the transaction.
359
+ # dwData1:: Specifies additional data.
360
+ # dwData2:: Specifies additional data.
361
+ # cc:: Specifies a CONVCONTEXT structure containing language information used to share data in different languages.
362
+ # cbData:: Specifies the amount, in bytes, of data being passed with the transaction. This value can be
363
+ # more than 32 bytes.
364
+ # Data:: Contains the first 32 bytes of data being passed with the transaction (8 * sizeof(DWORD)).
365
+ # ---
366
+ # *Information*:
367
+ # Header Declared in Ddeml.h, include Windows.h
368
+
369
+ class MonCbStruct < FFI::Struct # :nodoc:
370
+ layout :cb, :uint,
371
+ :dw_time, :uint32,
372
+ :h_task, :ulong,
373
+ :dw_ret, :uint32,
374
+ :w_type, :uint,
375
+ :w_fmt, :uint,
376
+ :h_conv, :ulong,
377
+ :hsz1, :ulong,
378
+ :hsz2, :ulong,
379
+ :h_data, :pointer,
380
+ :dw_data1, :pointer,
381
+ :dw_data2, :pointer,
382
+ :cc, :pointer,
383
+ :cb_data, :uint32,
384
+ :data, [:uint32, 8]
385
+ end
386
+
387
+ # The MONCONVSTRUCT structure contains information about a Dynamic Data Exchange (DDE) conversation. A
388
+ # DDE monitoring application can use this structure to obtain information about a conversation that has
389
+ # been established or has terminated.
390
+ #
391
+ # [*Typedef*] struct { UINT cb; BOOL fConnect; DWORD dwTime; HANDLE hTask; HSZ hszSvc; HSZ hszTopic;
392
+ # HCONV hConvClient; HCONV hConvServer } MONCONVSTRUCT;
393
+ #
394
+ # cb:: Specifies the structure's size, in bytes.
395
+ # fConnect:: Indicates whether the conversation is currently established. A value of TRUE indicates the
396
+ # conversation is established; FALSE indicates it is not.
397
+ # dwTime:: Specifies the Windows time at which the conversation was established or terminated. Windows
398
+ # time is the number of milliseconds that have elapsed since the system was booted.
399
+ # hTask:: Handle to a task (application instance) that is a partner in the conversation.
400
+ # hszSvc:: Handle to the service name on which the conversation is established.
401
+ # hszTopic:: Handle to the topic name on which the conversation is established.
402
+ # hConvClient:: Handle to the client conversation.
403
+ # hConvServer:: Handle to the server conversation.
404
+ # ---
405
+ # *Remarks*:
406
+ #
407
+ # Because string handles are local to the process, the hszSvc and hszTopic members are global atoms.
408
+ # Similarly, conversation handles are local to the instance; therefore, the hConvClient and hConvServer
409
+ # members are window handles.
410
+ # The hConvClient and hConvServer members of the MONCONVSTRUCT structure do not hold the same value as
411
+ # would be seen by the applications engaged in the conversation. Instead, they hold a globally unique
412
+ # pair of values that identify the conversation.
413
+ # ---
414
+ # Structure Information:
415
+ # Header Declared in Ddeml.h, include Windows.h
416
+ #
417
+ class MonConvStruct < FFI::Struct # :nodoc:
418
+ layout :cb, :uint,
419
+ :f_connect, :uchar,
420
+ :dw_time, :uint32,
421
+ :h_task, :ulong,
422
+ :hsz_svc, :ulong,
423
+ :hsz_topic, :ulong,
424
+ :h_conv_client, :ulong,
425
+ :h_conv_server, :ulong
426
+ end
427
+
428
+ # The MONERRSTRUCT structure contains information about the current Dynamic Data Exchange (DDE) error. A
429
+ # DDE monitoring application can use this structure to monitor errors returned by DDE Management Library
430
+ # functions.
431
+ #
432
+ # [*Typedef*] struct { UINT cb; UINT wLastError; DWORD dwTime; HANDLE hTask } MONERRSTRUCT;
433
+ #
434
+ # cb:: Specifies the structure's size, in bytes.
435
+ # wLastError:: Specifies the current error.
436
+ # dwTime:: Specifies the Windows time at which the error occurred. Windows time is the number of
437
+ # milliseconds that have elapsed since the system was booted.
438
+ # hTask:: Handle to the task (application instance) that called the DDE function that caused the error.
439
+ # ---
440
+ # Structure Information:
441
+ # Header Declared in Ddeml.h, include Windows.h
442
+ #
443
+ class MonErrStruct < FFI::Struct # :nodoc:
444
+ layout :cb, :uint,
445
+ :w_last_error, :uint,
446
+ :dw_time, :uint32,
447
+ :h_task, :ulong
448
+ end
449
+
450
+ MH_CREATE = 1
451
+ MH_KEEP = 2
452
+ MH_DELETE = 3
453
+ MH_CLEANUP = 4
454
+
455
+ # The MONHSZSTRUCT structure contains information about a Dynamic Data Exchange (DDE) string handle. A
456
+ # DDE monitoring application can use this structure when monitoring the activity of the string manager
457
+ # component of the DDE Management Library.
458
+ #
459
+ # [*Typedef*] struct { UINT cb; BOOL fsAction; DWORD dwTime; HSZ hsz; HANDLE hTask; TCHAR str[1] } MONHSZSTRUCT;
460
+ #
461
+ # cb:: Specifies the structure's size, in bytes.
462
+ # fsAction:: Specifies the action being performed on the string identified by the hsz member.
463
+ # MH_CLEANUP:: An application is freeing its DDE resources, causing the system to delete string handles
464
+ # the application had created. (The application called the DdeUninitialize function.)
465
+ # MH_CREATE:: An application is creating a string handle. (The app called the DdeCreateStringHandle)
466
+ # MH_DELETE:: An application is deleting a string handle. (The app called the DdeFreeStringHandle)
467
+ # MH_KEEP:: An application is increasing the usage count of a string handle. (The application called the
468
+ # DdeKeepStringHandle function.)
469
+ # dwTime:: Specifies the Windows time at which the action specified by the fsAction member takes place.
470
+ # Windows time is the number of milliseconds that have elapsed since the system was booted.
471
+ # hsz:: Handle to the string. Because string handles are local to the process, this member is a global atom.
472
+ # hTask:: Handle to the task (application instance) performing the action on the string handle.
473
+ # str:: Pointer to the string identified by the hsz member.
474
+ # ---
475
+ # Structure Information
476
+ # Header Declared in Ddeml.h, include Windows.h
477
+ #
478
+ class MonHszStruct < FFI::Struct # :nodoc:
479
+ layout :cb, :uint,
480
+ :fs_action, :uchar,
481
+ :dw_time, :uint32,
482
+ :hsz, :ulong,
483
+ :h_task, :ulong,
484
+ :str, :pointer
485
+ end
486
+
487
+ # The MONLINKSTRUCT structure contains information about a Dynamic Data Exchange (DDE) advise loop. A
488
+ # DDE monitoring application can use this structure to obtain information about an advise loop that has
489
+ # started or ended.
490
+ #
491
+ # [*Typedef*] struct { UINT cb; DWORD dwTime; HANDLE hTask; BOOL fEstablished; BOOL fNoData; HSZ hszSvc;
492
+ # HSZ hszTopic; HSZ hszItem; UINT wFmt; BOOL fServer; HCONV hConvServer; HCONV hConvClient }
493
+ # MONLINKSTRUCT;
494
+ #
495
+ # cb:: Specifies the structure's size, in bytes.
496
+ # dwTime:: Specifies the Windows time at which the advise loop was started or ended. Windows time is the
497
+ # number of milliseconds that have elapsed since the system was booted.
498
+ # hTask:: Handle to a task (application instance) that is a partner in the advise loop.
499
+ # fEstablished:: Indicates whether an advise loop was successfully established. A value of TRUE
500
+ # indicates an advise loop was established; FALSE indicates it was not.
501
+ # fNoData:: Indicates whether the XTYPF_NODATA flag is set for the advise loop. A value of TRUE
502
+ # indicates the flag is set; FALSE indicates it is not.
503
+ # hszSvc:: Handle to the service name of the server in the advise loop.
504
+ # hszTopic:: Handle to the topic name on which the advise loop is established.
505
+ # hszItem:: Handle to the item name that is the subject of the advise loop.
506
+ # wFmt:: Specifies the format of the data exchanged (if any) during the advise loop.
507
+ # fServer:: Indicates whether the link notification came from the server. A value of TRUE indicates the
508
+ # notification came from the server; FALSE indicates otherwise.
509
+ # hConvServer:: Handle to the server conversation.
510
+ # hConvClient:: Handle to the client conversation.
511
+ # ---
512
+ # *Remarks*:
513
+ # Because string handles are local to the process, the hszSvc, hszTopic, and hszItem members are global atoms.
514
+ # The hConvClient and hConvServer members of the MONLINKSTRUCT structure do not hold the same value as
515
+ # would be seen by the applications engaged in the conversation. Instead, they hold a globally unique
516
+ # pair of values that identify the conversation.
517
+ # ---
518
+ # Structure Information
519
+ # Header Declared in Ddeml.h, include Windows.h
520
+ #
521
+ class MonLinkStruct < FFI::Struct # :nodoc:
522
+ layout :cb, :uint,
523
+ :dw_time, :uint32,
524
+ :h_task, :ulong,
525
+ :f_established, :uchar,
526
+ :f_no_data, :uchar,
527
+ :hsz_svc, :ulong,
528
+ :hsz_topic, :ulong,
529
+ :hsz_item, :ulong,
530
+ :w_fmt, :uint,
531
+ :f_server, :uchar,
532
+ :h_conv_server, :ulong,
533
+ :h_conv_client, :ulong
534
+ end
535
+
536
+ # The MONMSGSTRUCT structure contains information about a Dynamic Data Exchange (DDE) message. A DDE
537
+ # monitoring application can use this structure to obtain information about a DDE message that was sent
538
+ # or posted.
539
+ #
540
+ # [*Typedef*] struct { UINT cb; HWND hwndTo; DWORD dwTime; HANDLE hTask; UINT wMsg; WPARAM wParam;
541
+ # LPARAM lParam; DDEML_MSG_HOOK_DATA dmhd } MONMSGSTRUCT;
542
+ #
543
+ # cb:: Specifies the structure's size, in bytes.
544
+ # hwndTo:: Handle to the window that receives the DDE message.
545
+ # dwTime:: Specifies the Windows time at which the message was sent or posted. Windows time is the
546
+ # number of milliseconds that have elapsed since the system was booted.
547
+ # hTask:: Handle to the task (application instance) containing the window that receives the DDE message.
548
+ # wMsg:: Specifies the identifier of the DDE message.
549
+ # wParam:: Specifies the wParam parameter of the DDE message.
550
+ # lParam:: Specifies the lParam parameter of the DDE message.
551
+ # dmhd:: Specifies a DDEML_MSG_HOOK_DATA structure that contains additional information about the DDE message.
552
+ # ---
553
+ # Structure Information
554
+ # Header Declared in Ddeml.h, include Windows.h
555
+ #
556
+ class MonMsgStruct < FFI::Struct # :nodoc:
557
+ layout :cb, :uint,
558
+ :hwnd_to, :ulong,
559
+ :dw_time, :uint32,
560
+ :h_task, :ulong,
561
+ :w_msg, :uint,
562
+ :w_param, :uint,
563
+ :l_param, :long,
564
+ :dmhd, :pointer
565
+ end
566
+
567
+ # The DDEML_MSG_HOOK_DATA structure contains information about a Dynamic Data Exchange (DDE) message,
568
+ # and provides read access to the data referenced by the message. This structure is intended to be used
569
+ # by a Dynamic Data Exchange Management Library (DDEML) monitoring application.
570
+ #
571
+ # [*Typedef*] struct { UINT_PTR uiLo; UINT_PTR uiHi; DWORD cbData; DWORD Data } DDEML_MSG_HOOK_DATA;
572
+ #
573
+ # uiLo:: Specifies the unpacked low-order word of the lParam parameter associated with the DDE message.
574
+ # uiHi:: Specifies the unpacked high-order word of the lParam parameter associated with the DDE message.
575
+ # cbData:: Specifies the amount, in bytes, of data being passed with the message. This value can be > 32.
576
+ # Data:: Contains the first 32 bytes of data being passed with the message (8 * sizeof(DWORD)).
577
+ # ---
578
+ # Structure Information
579
+ # Header Declared in Ddeml.h, include Windows.h
580
+ #
581
+ class DdemlMsgHookData < FFI::Struct # :nodoc:
582
+ layout :ui_lo, :uint,
583
+ :ui_hi, :uint,
584
+ :cb_data, :uint32,
585
+ :data, :uint32
586
+ end
587
+
588
+ ##
589
+ # The RegisterClipboardFormat function registers a new clipboard format.
590
+ # This format can then be used as a valid clipboard format.
591
+ #
592
+ # [*Syntax*] UINT RegisterClipboardFormat( LPCTSTR lpszFormat )
593
+ #
594
+ # lpszFormat:: [in] Pointer to a null-terminated string that names the new format.
595
+ #
596
+ # *Returns*:: :uint or nil. If the function succeeds, the return value identifies the registered clipboard format.
597
+ # If the function fails, the return value is *nil*(not zero). For error info, call GetLastError.
598
+ # ---
599
+ # *Remarks*:
600
+ # If a registered format with the specified name already exists, a new format is not registered and the
601
+ # return value identifies the existing format. This enables more than one application to copy and paste
602
+ # data using the same registered clipboard format. Note that the comparison is case-insensitive.
603
+ # Registered clipboard formats are identified by values in the range 0xC000 through 0xFFFF.
604
+ # When registered clipboard formats are placed on or retrieved from the clipboard, they must be in the
605
+ # form of an HGLOBAL value.
606
+ #
607
+ # :call-seq:
608
+ # format_id = register_clipboard_format( format_name )
609
+ #
610
+ function :RegisterClipboardFormat, [:pointer], :uint, zeronil: true
611
+
612
+ ##
613
+ # The DdeCallback function is an application-defined callback function used with the Dynamic Data Exchange
614
+ # Management Library (DDEML) functions. It processes Dynamic Data Exchange (DDE) transactions. The PFNCALLBACK
615
+ # type defines a pointer to this callback function. DdeCallback is a placeholder for the application-defined
616
+ # function name.
617
+ #
618
+ # [*Syntax*] HDDEDATA CALLBACK DdeCallback( UINT uType, UINT uFmt, HCONV hconv, HDDEDATA hsz1, HDDEDATA hsz2,
619
+ # HDDEDATA hdata, HDDEDATA dwData1, HDDEDATA dwData2);
620
+ # uType:: [in] Specifies the type of the current transaction. This parameter consists of a combination of
621
+ # transaction class flags and transaction type flags. The following table describes each of the
622
+ # transaction classes and provides a list of the transaction types in each class. For information
623
+ # about a specific transaction type, see the individual description of that type.
624
+ # - XCLASS_BOOL - A DDE callback function should return TRUE or FALSE when it finishes processing a
625
+ # transaction that belongs to this class. The XCLASS_BOOL class consists of the following types:
626
+ # - XTYP_ADVSTART
627
+ # - *XTYP_CONNECT*: A client uses the XTYP_CONNECT transaction to establish a conversation.
628
+ # hsz1:: Handle to the topic name.
629
+ # hsz2:: Handle to the service name.
630
+ # dwData1:: Pointer to a CONVCONTEXT structure that contains context information for the conversation.
631
+ # If the client is not a Dynamic Data Exchange Management Library (DDEML) application,
632
+ # this parameter is 0.
633
+ # dwData2:: Specifies whether the client is the same application instance as the server. If the
634
+ # parameter is 1, the client is the same instance. If the parameter is 0, the client
635
+ # is a different instance.
636
+ # *Returns*:: A server callback function should return TRUE to allow the client to establish a
637
+ # conversation on the specified service name and topic name pair, or the function
638
+ # should return FALSE to deny the conversation. If the callback function returns TRUE
639
+ # and a conversation is successfully established, the system passes the conversation
640
+ # handle to the server by issuing an XTYP_CONNECT_CONFIRM transaction to the server's
641
+ # callback function (unless the server specified the CBF_SKIP_CONNECT_CONFIRMS flag
642
+ # in the DdeInitialize function).
643
+ # - XCLASS_DATA - A DDE callback function should return a DDE handle, the CBR_BLOCK return code, or
644
+ # NULL when it finishes processing a transaction that belongs to this class. The XCLASS_DATA
645
+ # transaction class consists of the following types:
646
+ # - XTYP_ADVREQ
647
+ # - XTYP_REQUEST
648
+ # - XTYP_WILDCONNECT
649
+ # - XCLASS_FLAGS - A DDE callback function should return DDE_FACK, DDE_FBUSY, or DDE_FNOTPROCESSED
650
+ # when it finishes processing a transaction that belongs to this class. The XCLASS_FLAGS transaction
651
+ # class consists of the following types:
652
+ # - XTYP_ADVDATA
653
+ # - XTYP_EXECUTE
654
+ # - *XTYP_POKE*: A client uses the XTYP_POKE transaction to send unsolicited data to the server.
655
+ # uFmt:: Specifies the format of the data sent from the server.
656
+ # hconv:: Handle to the conversation.
657
+ # hsz1:: Handle to the topic name.
658
+ # hsz2:: Handle to the item name.
659
+ # hdata:: Handle to the data that the client is sending to the server.
660
+ # *Returns*:: A server callback function should return the DDE_FACK flag if it processes this
661
+ # transaction, the DDE_FBUSY flag if it is too busy to process this transaction,
662
+ # or the DDE_FNOTPROCESSED flag if it rejects this transaction.
663
+ # - XCLASS_NOTIFICATION - The transaction types that belong to this class are for notification purposes
664
+ # only. The return value from the callback function is ignored. The XCLASS_NOTIFICATION transaction
665
+ # class consists of the following types:
666
+ # - XTYP_ADVSTOP
667
+ # - XTYP_CONNECT_CONFIRM
668
+ # - XTYP_DISCONNECT
669
+ # - XTYP_ERROR
670
+ # - XTYP_MONITOR
671
+ # - XTYP_REGISTER
672
+ # - XTYP_XACT_COMPLETE
673
+ # - XTYP_UNREGISTER
674
+ # uFmt:: [in] Specifies the format in which data is sent or received.
675
+ # hconv:: [in] Handle to the conversation associated with the current transaction.
676
+ # hsz1:: [in] Handle to a string. The meaning of this parameter depends on the type of the current transaction.
677
+ # For the meaning of this parameter, see the description of the transaction type.
678
+ # hsz2:: [in] Handle to a string. The meaning of this parameter depends on the type of the current transaction.
679
+ # For the meaning of this parameter, see the description of the transaction type.
680
+ # hdata:: [in] Handle to DDE data. The meaning of this parameter depends on the type of the current transaction.
681
+ # For the meaning of this parameter, see the description of the transaction type.
682
+ # dwData1:: [in] Specifies transaction-specific data. For the meaning, see the description of the transaction type.
683
+ # dwData2:: [in] Specifies transaction-specific data. For the meaning, see the description of the transaction type.
684
+ # *Returns*:: The return value depends on the transaction class. For more information about the return values,
685
+ # see descriptions of the individual transaction types.
686
+ # ---
687
+ # *Remarks*:
688
+ # - The callback function is called asynchronously for transactions that do not involve the creation or termination
689
+ # of conversations. An application that does not frequently accept incoming messages will have reduced DDE
690
+ # performance because the Dynamic Data Exchange Management Library (DDEML) uses messages to initiate transactions.
691
+ # - An application must register the callback function by specifying a pointer to the function in a call to the
692
+ # DdeInitialize function.
693
+ #
694
+ # :call-seq:
695
+ # DdeCallback block: {|type, format, hconv, hsz1, hsz2, hdata, data1, data2| your code }
696
+ #
697
+ callback :DdeCallback, [:uint, :uint, :HCONV, :HDDEDATA, :HDDEDATA, :HDDEDATA, :HDDEDATA, :HDDEDATA], :HDDEDATA
698
+
699
+ ##
700
+ # The DdeInitialize function registers an application with the Dynamic Data Exchange Management Library (DDEML).
701
+ # An application must call this function before calling any other DDEML function.
702
+ #
703
+ # [*Syntax*] UINT DdeInitialize( LPDWORD pidInst, PFNCALLBACK pfnCallback, DWORD afCmd, DWORD ulRes );
704
+ #
705
+ # pidInst:: [in, out] Pointer to the application instance identifier.
706
+ # At initialization, this parameter should point to 0. If the function succeeds, this parameter points
707
+ # to the instance identifier for the application. This value should be passed as the idInst parameter
708
+ # in all other DDEML functions that require it. If an application uses multiple instances of the DDEML
709
+ # dynamic-link library (DLL), the application should provide a different callback function for each
710
+ # instance. If pidInst points to a nonzero value, reinitialization of the DDEML is implied. In this
711
+ # case, pidInst must point to a valid application-instance identifier.
712
+ # pfnCallback:: Pointer to the application-defined Dynamic Data Exchange DdeCallback function. This function
713
+ # processes DDE transactions sent by the system. For more information, see the DdeCallback.
714
+ # afCmd:: [in] Specifies a set of APPCMD_, CBF_, and MF_ flags. The APPCMD_ flags provide special
715
+ # instructions to DdeInitialize. The CBF_ flags specify filters that prevent specific types of transactions
716
+ # from reaching the callback function. The MF_ flags specify the types of DDE activity that a DDE monitoring
717
+ # application monitors. Using these flags enhances the performance of a DDE application by eliminating
718
+ # unnecessary calls to the callback function. This parameter can be one or more of the following values:
719
+ # APPCLASS_MONITOR, APPCLASS_STANDARD, APPCMD_CLIENTONLY, APPCMD_FILTERINITS;
720
+ # CBF_FAIL_ALLSVRXACTIONS, CBF_FAIL_ADVISES, CBF_FAIL_CONNECTIONS, CBF_FAIL_EXECUTES, CBF_FAIL_POKES
721
+ # CBF_FAIL_REQUESTS, CBF_FAIL_SELFCONNECTIONS, CBF_SKIP_ALLNOTIFICATIONS, CBF_SKIP_CONNECT_CONFIRMS
722
+ # CBF_SKIP_DISCONNECTS, CBF_SKIP_REGISTRATIONS, CBF_SKIP_UNREGISTRATIONS;
723
+ # MF_CALLBACKS, MF_CONV, MF_ERRORS, MF_HSZ_INFO, MF_LINKS, MF_POSTMSGS, MF_SENDMSGS
724
+ # ulRes:: Reserved; must be set to zero.
725
+ #
726
+ # *Returns*:: If the function succeeds, the return value is DMLERR_NO_ERROR. If the function fails, the return
727
+ # value is one of the following values:
728
+ # - DMLERR_DLL_USAGE
729
+ # - DMLERR_INVALIDPARAMETER
730
+ # - DMLERR_SYS_ERROR
731
+ # ---
732
+ # <b> Enhanced API accepts only 2 parameters (get rid of reserved hsz2):
733
+ # instance_id:: (optional) Application instance identifier. At initialization, this parameter should be 0, nil
734
+ # or omitted altogether. If it is nonzero/non-nil, reinitialization of the DDEML is implied.
735
+ # cmd(afCmd):: obligatory set of flags
736
+ # ---
737
+ # *Remarks*:
738
+ # - An application that uses multiple instances of the DDEML must not pass DDEML objects between instances.
739
+ # - A DDE monitoring application should not attempt to perform DDE operations (establish conversations,
740
+ # issue transactions, and so on) within the context of the same application instance.
741
+ # - A synchronous transaction fails with a DMLERR_REENTRANCY error if any instance of the same task has
742
+ # a synchronous transaction already in progress.
743
+ # - The CBF_FAIL_ALLSVRXACTIONS flag causes the DDEML to filter all server transactions and can be changed
744
+ # by a subsequent call to DdeInitialize. The APPCMD_CLIENTONLY flag prevents the DDEML from creating key
745
+ # resources for the server and cannot be changed by a subsequent call to DdeInitialize.
746
+ # - There is an ANSI version and a Unicode version of DdeInitialize. The version called determines the
747
+ # type of the window procedures used to control DDE conversations (ANSI or Unicode), and the default
748
+ # value for the iCodePage member of the CONVCONTEXT structure (CP_WINANSI or CP_WINUNICODE).
749
+ #
750
+ # :call-seq:
751
+ # instance_id, status = dde_initialize( [instance_id = 0], cmd )
752
+ # {|type, format, hconv, hsz1, hsz2, hdata, data1, data2| your dde_callback block}
753
+ #
754
+ function :DdeInitialize, [:pointer, :DdeCallback, :uint32, :uint32], :uint,
755
+ &->(api, old_id=0, cmd, &block){
756
+ raise ArgumentError, 'No callback block' unless block
757
+ old_id = 0 unless old_id
758
+ id = FFI::MemoryPointer.new(:uint32).put_uint32(0, old_id)
759
+ status = api.call(id, block, cmd, 0)
760
+ id = status == 0 ? id.get_uint32(0) : nil
761
+ [id, status] }
762
+ # weird lambda literal instead of block is needed because RDoc goes crazy if block is attached to meta-definition
763
+
764
+ ##
765
+ # The DdeUninitialize function frees all Dynamic Data Exchange Management Library (DDEML) resources associated
766
+ # with the calling application.
767
+ #
768
+ # [*Syntax*] BOOL DdeUninitialize( DWORD idInst);
769
+ #
770
+ # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the DdeInitialize.
771
+ # *Returns*:: If the function succeeds, the return value is nonzero.
772
+ # If the function fails, the return value is zero.
773
+ # ---
774
+ # *Remarks*
775
+ # DdeUninitialize terminates any conversations currently open for the application.
776
+ #
777
+ # :call-seq:
778
+ # success = dde_uninitialize( instance_id )
779
+ #
780
+ function :DdeUninitialize, [:uint32], :int, boolean: true
781
+
782
+ ##
783
+ # The DdeCreateStringHandle function creates a handle that identifies the specified string.
784
+ # A Dynamic Data Exchange (DDE) client or server application can pass the string handle as a
785
+ # parameter to other Dynamic Data Exchange Management Library (DDEML) functions.
786
+ #
787
+ # [*Syntax*] HSZ DdeCreateStringHandle( DWORD idInst, LPTSTR psz, int iCodePage );
788
+ #
789
+ # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the
790
+ # DdeInitialize function.
791
+ # psz:: [in] Pointer to a buffer that contains the null-terminated string for which a handle
792
+ # is to be created. This string can be up to 255 characters. The reason for this limit is that
793
+ # DDEML string management functions are implemented using global atoms.
794
+ # iCodePage:: [in] Specifies the code page used to render the string. This value should be either
795
+ # CP_WINANSI (the default code page) or CP_WINUNICODE, depending on whether the ANSI or Unicode
796
+ # version of DdeInitialize was called by the client application.
797
+ #
798
+ # *Returns*:: (L) or nil: If the function succeeds, the return value is a string handle.
799
+ # If the function fails, the return value is 0(changed to nil in enhanced version).
800
+ # The DdeGetLastError function can be used to get the error code, which can be one of the
801
+ # following values: DMLERR_NO_ERROR, DMLERR_INVALIDPARAMETER, DMLERR_SYS_ERROR
802
+ # ---
803
+ # <b> Enhanced (snake_case) API makes code_page param optional and returns *nil* if handle creation fails. </b>
804
+ # ---
805
+ # *Remarks*: The value of a string handle is not related to the case of the string it identifies.
806
+ # When an application either creates a string handle or receives one in the callback function
807
+ # and then uses the DdeKeepStringHandle function to keep it, the application must free that string
808
+ # handle when it is no longer needed. An instance-specific string handle cannot be mapped from string
809
+ # handle to string and back to string handle.
810
+ #
811
+ # :call-seq:
812
+ # string_handle = dde_create_string_handle( instance_id, string, code_page_id )
813
+ #
814
+ function :DdeCreateStringHandle, [:uint32, :pointer, :int], :ulong, zeronil: true,
815
+ &->(api, instance_id, string, code_page=CP_WINANSI){
816
+ string_pointer = FFI::MemoryPointer.from_string(string)
817
+ api.call(instance_id, string_pointer, code_page) }
818
+
819
+ ##
820
+ # The DdeFreeStringHandle function frees a string handle in the calling application.
821
+ #
822
+ # [*Syntax*] BOOL DdeFreeStringHandle( DWORD idInst, HSZ hsz );
823
+ #
824
+ # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the DdeInitialize.
825
+ # hsz:: [in, out] Handle to the string handle to be freed. This handle must have been created by a previous call
826
+ # to the DdeCreateStringHandle function.
827
+ # *Returns*:: If the function succeeds, the return value is nonzero. If the function fails, it is zero.
828
+ # ---
829
+ # <b> Enhanced snake_case API returns boolean true/false as a success indicator. </b>
830
+ # ---
831
+ # *Remarks*:
832
+ # An application can free string handles it creates with DdeCreateStringHandle but should not free those that
833
+ # the system passed to the application's Dynamic Data Exchange (DDE) callback function or those returned in the
834
+ # CONVINFO structure by the DdeQueryConvInfo function.
835
+ #
836
+ # :call-seq:
837
+ # success = dde_free_string_handle( instance_id, string_handle )
838
+ #
839
+ function :DdeFreeStringHandle, [:uint32, :ulong], :int, boolean: true
840
+
841
+ ##
842
+ # The DdeQueryString function copies text associated with a string handle into a buffer.
843
+ #
844
+ # [*Syntax*] DWORD DdeQueryString( DWORD idInst, HSZ hsz, LPTSTR psz, DWORD cchMax, int iCodePage);
845
+ #
846
+ # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the DdeInitialize.
847
+ # hsz:: [in] Handle to the string to copy. This handle must have been created by a previous call to the
848
+ # DdeCreateStringHandle function.
849
+ # psz:: [in, out] Pointer to a buffer that receives the string. To obtain the length of the string, this parameter
850
+ # should be set to NULL.
851
+ # cchMax:: [in] Specifies the length, in TCHARs, of the buffer pointed to by the psz parameter. For the ANSI
852
+ # version of the function, this is the number of bytes; for the Unicode version, this is the number of
853
+ # characters. If the string is longer than ( cchMax– 1), it will be truncated. If the psz parameter is
854
+ # set to NULL, this parameter is ignored.
855
+ # iCodePage:: [in] Code page used to render the string. This value should be either CP_WINANSI or CP_WINUNICODE.
856
+ #
857
+ # *Returns*:: If the psz parameter specified a valid pointer, the return value is the length, in TCHARs, of the
858
+ # returned text (not including the terminating null character). If the psz parameter specified a NULL
859
+ # pointer, the return value is the length of the text associated with the hsz parameter (not including
860
+ # the terminating null character). If an error occurs, the return value is 0L.
861
+ # ---
862
+ # <b> Enhanced (snake_case) API makes all args optional except for first (dde instance id), and returns nil if
863
+ # the function was unsuccessful.</b>
864
+ # ---
865
+ # *Remarks*
866
+ # - The string returned in the buffer is always null-terminated. If the string is longer than ( cchMax– 1),
867
+ # only the first ( cchMax– 1) characters of the string are copied.
868
+ # - If the psz parameter is NULL, the DdeQueryString function obtains the length, in bytes, of the string
869
+ # associated with the string handle. The length does not include the terminating null character.
870
+ #
871
+ # :call-seq:
872
+ # string = dde_query_string( instance_id, handle, [code_page = CP_WINANSI ] )
873
+ #
874
+ function :DdeQueryString, [:uint32, :ulong, :pointer, :uint32, :int], :uint32,
875
+ &->(api, instance_id, handle, code_page = CP_WINANSI){
876
+ buffer = FFI::MemoryPointer.new :char, 1024
877
+ num_chars = api.call(instance_id, handle, buffer, buffer.size, code_page)
878
+ num_chars == 0 ? nil : buffer.get_bytes(0, num_chars) }
879
+
880
+ ##
881
+ # The DdeNameService function registers or unregisters the service names a Dynamic Data Exchange (DDE) server
882
+ # supports. This function causes the system to send XTYP_REGISTER or XTYP_UNREGISTER transactions to other running
883
+ # Dynamic Data Exchange Management Library (DDEML) client applications.
884
+ #
885
+ # [*Syntax*] HDDEDATA DdeNameService( DWORD idInst, UINT hsz1, UINT hsz2, UINT afCmd );
886
+ #
887
+ # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the DdeInitialize.
888
+ # hsz1:: [in] Handle to the string that specifies the service name the server is registering or unregistering.
889
+ # An application that is unregistering all of its service names should set this parameter to 0L.
890
+ # hsz2:: Reserved; should be set to 0L.
891
+ # afCmd:: [in] Specifies the service name options. This parameter can be one of the following values.
892
+ # DNS_REGISTER:: Registers the service name.
893
+ # DNS_UNREGISTER:: Unregisters the service name. If the hsz1 parameter is 0L,
894
+ # all service names registered by the server will be unregistered.
895
+ # DNS_FILTERON:: Turns on service name initiation filtering. The filter prevents a server from receiving
896
+ # XTYP_CONNECT transactions for service names it has not registered. This is the default
897
+ # setting for this filter. If a server application does not register any service names,
898
+ # the application cannot receive XTYP_WILDCONNECT transactions.
899
+ # DNS_FILTEROFF:: Turns off service name initiation filtering. If this flag is specified, the server
900
+ # receives an XTYP_CONNECT transaction whenever another DDE application calls the
901
+ # DdeConnect function, regardless of the service name.
902
+ # *Returns*:: If the function succeeds, it returns nonzero (*true* in snake_case method). For CamelCase, that
903
+ # value is not really HDDEDATA value, but merely a Boolean indicator of success. The function is
904
+ # typed HDDEDATA to allow for future expansion of the function and more sophisticated returns.
905
+ # If the function fails, the return value is 0L (*false* in snake_case method). The DdeGetLastError
906
+ # function can be used to get the error code, which can be one of the following:
907
+ # - DMLERR_DLL_NOT_INITIALIZED
908
+ # - DMLERR_DLL_USAGE
909
+ # - DMLERR_INVALIDPARAMETER
910
+ # - DMLERR_NO_ERROR
911
+ # ---
912
+ # <b> Enhanced API accepts only 3 parameters (get rid of reserved hsz2) and returns boolean true/false. </b>
913
+ # ---
914
+ # *Remarks*:
915
+ # The service name identified by the hsz1 parameter should be a base name (that is, the name should contain no
916
+ # instance-specific information). The system generates an instance-specific name and sends it along with the
917
+ # base name during the XTYP_REGISTER and XTYP_UNREGISTER transactions. The receiving applications can then
918
+ # connect to the specific application instance.
919
+ #
920
+ # :call-seq:
921
+ # success = dde_name_service( instance_id, string_handle, cmd )
922
+ #
923
+ function :DdeNameService, [:uint32, :ulong, :ulong, :uint], :ulong,
924
+ &->(api, id, string_handle, cmd){ api.call(id, string_handle, 0, cmd) != 0 }
925
+ # weird lambda literal instead of block is needed because RDoc goes crazy if block is attached to meta-definition
926
+
927
+ ##
928
+ # DdeConnect function establishes a conversation with a server application that supports the specified service
929
+ # name and topic name pair. If more than one such server exists, the system selects only one.
930
+ #
931
+ # [*Syntax*] HCONV DdeConnect( DWORD idInst, HSZ hszService, HSZ hszTopic, PCONVCONTEXT pCC );
932
+ #
933
+ # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the DdeInitialize.
934
+ # hszService:: [in] Handle to the string that specifies the service name of the server application with which
935
+ # a conversation is to be established. This handle must have been created by a previous call to
936
+ # the DdeCreateStringHandle function. If this parameter is 0L, a conversation is established with
937
+ # any available server.
938
+ # hszTopic:: [in] Handle to the string that specifies the name of the topic on which a conversation is to be
939
+ # established. This handle must have been created by a previous call to DdeCreateStringHandle.
940
+ # If this parameter is 0L, a conversation on any topic supported by the selected server is established.
941
+ # pCC:: [in] Pointer to the CONVCONTEXT structure that contains conversation context information. If this
942
+ # parameter is NULL, the server receives the default CONVCONTEXT structure during the XTYP_CONNECT
943
+ # or XTYP_WILDCONNECT transaction.
944
+ # *Returns*:: If the function succeeds, the return value is the handle to the established conversation.
945
+ # If the function fails, the return value is 0L. The DdeGetLastError function can be used to get
946
+ # the error code, which can be one of the following values:
947
+ # - DMLERR_DLL_NOT_INITIALIZED
948
+ # - DMLERR_INVALIDPARAMETER
949
+ # - DMLERR_NO_CONV_ESTABLISHED
950
+ # - DMLERR_NO_ERROR
951
+ # ---
952
+ # *Remarks*
953
+ # - The client application cannot make assumptions regarding the server selected. If an instance-specific name
954
+ # is specified in the hszService parameter, a conversation is established with only the specified instance.
955
+ # Instance-specific service names are passed to an application's Dynamic Data Exchange (DDE) callback function
956
+ # during the XTYP_REGISTER and XTYP_UNREGISTER transactions.
957
+ # - All members of the default CONVCONTEXT structure are set to zero except cb, which specifies the size of the
958
+ # structure, and iCodePage, which specifies CP_WINANSI (the default code page) or CP_WINUNICODE, depending on
959
+ # whether the ANSI or Unicode version of the DdeInitialize function was called by the client application.
960
+ # ---
961
+ # <b>Enhanced (snake_case) API makes all args optional except for first (dde instance id), and returns nil if
962
+ # the function was unsuccessful.</b>
963
+ #
964
+ # :call-seq:
965
+ # conversation_handle = dde_connect( instance_id, [service = 0, topic = 0, context = nil] )
966
+ #
967
+ function :DdeConnect, [:uint32, :ulong, :ulong, :pointer], :ulong, zeronil: true,
968
+ &->(api, instance_id, service = 0, topic = 0, context = nil){
969
+ api.call(instance_id, service, topic, context) }
970
+
971
+ ##
972
+ # The DdeDisconnect function terminates a conversation started by either the DdeConnect or DdeConnectList function
973
+ # and invalidates the specified conversation handle.
974
+ #
975
+ # [*Syntax*] BOOL DdeDisconnect( HCONV hConv );
976
+ #
977
+ # hConv:: [in, out] Handle to the active conversation to be terminated.
978
+ #
979
+ # *Returns*:: If the function succeeds, the return value is nonzero, otherwise zero. The DdeGetLastError function
980
+ # can be used to get the error code, which can be one of the following values:
981
+ # - DMLERR_DLL_NOT_INITIALIZED
982
+ # - DMLERR_NO_CONV_ESTABLISHED
983
+ # - DMLERR_NO_ERROR
984
+ # ---
985
+ # *Remarks*:
986
+ # Any incomplete transactions started before calling DdeDisconnect are immediately abandoned. The XTYP_DISCONNECT
987
+ # transaction is sent to the Dynamic Data Exchange (DDE) callback function of the partner in the conversation.
988
+ # Generally, only client applications must terminate conversations.
989
+ # ---
990
+ # <b>Enhanced (snake_case) API returns *true/false* instead of nonzero/zero.</b>
991
+ #
992
+ # :call-seq:
993
+ # success = dde_disconnect(conversation_handle)
994
+ #
995
+ function :DdeDisconnect, [:ulong], :int, boolean: true
996
+
997
+
998
+ ##
999
+ # The DdeGetLastError function retrieves the most recent error code set by the failure of a Dynamic Data Exchange
1000
+ # Management Library (DDEML) function and resets the error code to DMLERR_NO_ERROR.
1001
+ #
1002
+ # [*Syntax*] UINT DdeGetLastError( DWORD idInst );
1003
+ #
1004
+ # idInst:: [in] Specifies the application instance identifier obtained by a previous call to the DdeInitialize.
1005
+ #
1006
+ # *Returns*:: If the function succeeds, the return value is the last error code, which can be one of the following:
1007
+ # DMLERR_ADVACKTIMEOUT, DMLERR_EXECACKTIMEOUT, DMLERR_INVALIDPARAMETER, DMLERR_LOW_MEMORY, DMLERR_MEMORY_ERROR,
1008
+ # DMLERR_NO_CONV_ESTABLISHED, DMLERR_NOTPROCESSED, DMLERR_POKEACKTIMEOUT, DMLERR_POSTMSG_FAILED, DMLERR_REENTRANCY,
1009
+ # DMLERR_SERVER_DIED, DMLERR_SYS_ERROR, DMLERR_UNADVACKTIMEOUT, DMLERR_UNFOUND_QUEUE_ID
1010
+ # ---
1011
+ # <b>Enhanced (snake_case) API returns *nil* if the function was unsuccessful (that is, no DDE errors raised).</b>
1012
+ # ---
1013
+ #
1014
+ # :call-seq:
1015
+ # string = dde_get_last_error( instance_id )
1016
+ #
1017
+ function :DdeGetLastError, [:uint32], :int, zeronil: true
1018
+
1019
+ ##
1020
+ # The DdeClientTransaction function begins a data transaction between a client and a server. Only a
1021
+ # Dynamic Data Exchange (DDE) client application can call this function, and the application can use it
1022
+ # only after establishing a conversation with the server.
1023
+ #
1024
+ # [*Syntax*] HDDEDATA DdeClientTransaction( LPBYTE pData, DWORD cbData, HCONV hConv, HSZ hszItem, UINT
1025
+ # wFmt, UINT wType, DWORD dwTimeout, LPDWORD pdwResult );
1026
+ #
1027
+ # pData:: [in] Pointer to the beginning of the data the client must pass to the server.
1028
+ # Optionally, an application can specify the data handle (HDDEDATA) to pass to the server and in that
1029
+ # case the cbData parameter should be set to -1. This parameter is required only if the wType parameter
1030
+ # is XTYP_EXECUTE or XTYP_POKE. Otherwise, this parameter should be NULL.
1031
+ # For the optional usage of this parameter, XTYP_POKE transactions where pData is a data handle, the
1032
+ # handle must have been created by a previous call to the DdeCreateDataHandle function, employing the
1033
+ # same data format specified in the wFmt parameter.
1034
+ # cbData:: [in] Specifies the length, in bytes, of the data pointed to by the pData parameter, including
1035
+ # the terminating NULL, if the data is a string. A value of -1 indicates that pData is a data
1036
+ # handle that identifies the data being sent.
1037
+ # hConv:: [in] Handle to the conversation in which the transaction is to take place.
1038
+ # hszItem:: [in] Handle to the data item for which data is being exchanged during the transaction. This
1039
+ # handle must have been created by a previous call to the DdeCreateStringHandle function. This
1040
+ # parameter is ignored (and should be set to 0L) if the wType parameter is XTYP_EXECUTE.
1041
+ # wFmt:: [in] Specifies the standard clipboard format in which the data item is being submitted or
1042
+ # requested. If the transaction specified by the wType parameter does not pass data or is XTYP_EXECUTE,
1043
+ # this parameter should be zero.
1044
+ # If the transaction specified by the wType parameter references non-execute DDE data ( XTYP_POKE,
1045
+ # XTYP_ADVSTART, XTYP_ADVSTOP, XTYP_REQUEST), the wFmt value must be either a valid predefined (CF_) DDE
1046
+ # format or a valid registered clipboard format.
1047
+ # wType:: [in] Specifies the transaction type. This parameter can be one of the following values.
1048
+ # - XTYP_ADVSTART: Begins an advise loop. Any number of distinct advise loops can exist within a
1049
+ # conversation. An application can alter the advise loop type by combining the XTYP_ADVSTART
1050
+ # transaction type with one or more of the following flags: Flag Meaning
1051
+ # - XTYPF_NODATA Instructs the server to notify the client of any data changes without actually sending
1052
+ # the data. This flag gives the client the option of ignoring the notification or requesting the changed
1053
+ # data from the server.
1054
+ # - XTYPF_ACKREQ Instructs the server to wait until the client acknowledges that it received the previous
1055
+ # data item before sending the next data item. This flag prevents a fast server from sending data faster
1056
+ # than the client can process it.
1057
+ # - XTYP_ADVSTOP: Ends an advise loop.
1058
+ # - XTYP_EXECUTE: Begins an execute transaction.
1059
+ # - XTYP_POKE: Begins a poke transaction.
1060
+ # - XTYP_REQUEST: Begins a request transaction.
1061
+ # dwTimeout:: [in] Specifies the maximum amount of time, in milliseconds, that the client will wait for
1062
+ # a response from the server application in a synchronous transaction. This parameter should
1063
+ # be TIMEOUT_ASYNC for asynchronous transactions.
1064
+ # pdwResult:: [out] Pointer to a variable that receives the result of the transaction. An application
1065
+ # that does not check the result can use NULL for this value. For synchronous transactions,
1066
+ # the low-order word of this variable contains any applicable DDE_ flags resulting from the
1067
+ # transaction. This provides support for applications dependent on DDE_APPSTATUS bits. It
1068
+ # is, however, recommended that applications no longer use these bits because they may not
1069
+ # be supported in future versions of the Dynamic Data Exchange Management Library (DDEML).
1070
+ # For asynchronous transactions, this variable is filled with a unique transaction
1071
+ # identifier for use with the DdeAbandonTransaction function and the XTYP_XACT_COMPLETE
1072
+ # transaction.
1073
+ #
1074
+ # *Returns*:: If the function succeeds, the return value is a data handle that identifies the data for
1075
+ # successful synchronous transactions in which the client expects data from the server. The
1076
+ # return value is nonzero for successful asynchronous transactions and for synchronous
1077
+ # transactions in which the client does not expect data. The return value is zero for all
1078
+ # unsuccessful transactions.
1079
+ # The DdeGetLastError function can be used to get the error code, which can be one of the following values:
1080
+ # - DMLERR_ADVACKTIMEOUT
1081
+ # - DMLERR_BUSY
1082
+ # - DMLERR_DATAACKTIMEOUT
1083
+ # - DMLERR_DLL_NOT_INITIALIZED
1084
+ # - DMLERR_EXECACKTIMEOUT
1085
+ # - DMLERR_INVALIDPARAMETER
1086
+ # - DMLERR_MEMORY_ERROR
1087
+ # - DMLERR_NO_CONV_ESTABLISHED
1088
+ # - DMLERR_NO_ERROR
1089
+ # - DMLERR_NOTPROCESSED
1090
+ # - DMLERR_POKEACKTIMEOUT
1091
+ # - DMLERR_POSTMSG_FAILED
1092
+ # - DMLERR_REENTRANCY
1093
+ # - DMLERR_SERVER_DIED
1094
+ # - DMLERR_UNADVACKTIMEOUT
1095
+ # ---
1096
+ # *Remarks*:
1097
+ # When an application has finished using the data handle returned by DdeClientTransaction, the application should
1098
+ # free the handle by calling the DdeFreeDataHandle function.
1099
+ #
1100
+ #Transactions can be synchronous or asynchronous. During a synchronous transaction, DdeClientTransaction does not
1101
+ # return until the transaction either completes successfully or fails. Synchronous transactions cause a client to
1102
+ # enter a modal loop while waiting for various asynchronous events. Because of this, a client application can still
1103
+ # respond to user input while waiting on a synchronous transaction, but the application cannot begin a second
1104
+ # synchronous transaction because of the activity associated with the first. DdeClientTransaction fails if any
1105
+ # instance of the same task has a synchronous transaction already in progress.
1106
+ #
1107
+ # During an asynchronous transaction, DdeClientTransaction returns after the transaction has begun,
1108
+ # passing a transaction identifier for reference. When the server's DDE callback function finishes
1109
+ # processing an asynchronous transaction, the system sends an XTYP_XACT_COMPLETE transaction to the
1110
+ # client. This transaction provides the client with the results of the asynchronous transaction that it
1111
+ # initiated by calling DdeClientTransaction. A client application can choose to abandon an asynchronous
1112
+ # transaction by calling the DdeAbandonTransaction function.
1113
+ # ---
1114
+ # <b>Enhanced (snake_case) API: </b>
1115
+ #
1116
+ # :call-seq:
1117
+ # data_handle = dde_client_transaction(data_pointer, size, conv, item, format, type, timeout, result)
1118
+ #
1119
+ function :DdeClientTransaction, [:pointer, :uint32, :ulong, :ulong, :uint, :uint, :uint32, :pointer],
1120
+ :HDDEDATA, zeronil: true
1121
+
1122
+ ##
1123
+ # The DdeGetData function copies data from the specified Dynamic Data Exchange (DDE) object to the specified
1124
+ # local buffer.
1125
+ #
1126
+ # [*Syntax*] DWORD DdeGetData( HDDEDATA hData, LPBYTE pDst, DWORD cbMax, DWORD cbOff );
1127
+ #
1128
+ # hData:: [in] Handle to the DDE object that contains the data to copy.
1129
+ # pDst:: [out] Pointer to the buffer that receives the data. If this parameter is NULL, the DdeGetData
1130
+ # function returns the amount of data, in bytes, that would be copied to the buffer.
1131
+ # cbMax:: [in] Specifies the maximum amount of data, in bytes, to copy to the buffer pointed to by the pDst
1132
+ # parameter. Typically, this parameter specifies the length of the buffer pointed to by pDst.
1133
+ # cbOff:: [in] Specifies an offset within the DDE object. Data is copied from the object beginning at this offset.
1134
+ #
1135
+ # *Returns*:: If the pDst parameter points to a buffer, return value is the size, in bytes, of the memory object
1136
+ # associated with the data handle or the size specified in the cbMax parameter, whichever is lower.
1137
+ # If the pDst parameter is NULL, the return value is the size, in bytes, of the memory object
1138
+ # associated with the data handle.
1139
+ # The DdeGetLastError function can be used to get the error code, which can be one of the following:
1140
+ # - DMLERR_DLL_NOT_INITIALIZED
1141
+ # - DMLERR_INVALIDPARAMETER
1142
+ # - DMLERR_NO_ERROR
1143
+ # ---
1144
+ # <b> Enhanced (snake_case) API accepts data handle, and optionally max and offset (no need to pre-allocate
1145
+ # buffer). It returns pointer to copied DDE data (FFI::MemoryPointer) and size of copied data in bytes.
1146
+ # In case of failure, it returns [nil, 0]. This API is the same as for enhanced dde_access_data.
1147
+ # No need to call function twice (first time with nil buffer just to determine length).</b>
1148
+ # ---
1149
+ #
1150
+ # :call-seq:
1151
+ # buffer, size = dde_get_data( data_handle, [max = infinite, offset = 0] )
1152
+ #
1153
+ function :DdeGetData, [:ulong, :pointer, :uint32, :uint32], :uint,
1154
+ &->(api, data_handle, max=1073741823, offset=0){ # max is maximum DWORD Fixnum
1155
+ size = api.call(data_handle, nil, 0, 0) # determining data set length
1156
+ if size == 0
1157
+ [nil, 0]
1158
+ else
1159
+ copy_size = size < max ? size : max
1160
+ buffer = FFI::MemoryPointer.new(:char, offset + copy_size)
1161
+ size = api.call(data_handle, buffer, copy_size, offset)
1162
+ [buffer, size]
1163
+ end }
1164
+ # weird lambda literal instead of block is needed because RDoc goes crazy if block is attached to meta-definition
1165
+
1166
+
1167
+ ##
1168
+ # The DdeAccessData function provides access to the data in the specified Dynamic Data Exchange (DDE)
1169
+ # object. An application must call the DdeUnaccessData function when it has finished accessing the data
1170
+ # in the object.
1171
+ #
1172
+ # [*Syntax*] LPBYTE DdeAccessData( HDDEDATA hData, LPDWORD pcbDataSize );
1173
+ #
1174
+ # hData:: [in] Handle to the DDE object to access.
1175
+ # pcbDataSize:: [out] Pointer to a variable that receives the size, in bytes, of the DDE object
1176
+ # identified by the hData parameter. If this parameter is NULL, no size information is
1177
+ # returned.
1178
+ #
1179
+ # *Returns*:: If the function succeeds, the return value is a pointer to the first byte of data in the
1180
+ # DDE object.
1181
+ # If the function fails, the return value is NULL.
1182
+ # The DdeGetLastError function can be used to get the error code, which can be one of the following
1183
+ # values:
1184
+ # DMLERR_DLL_NOT_INITIALIZED
1185
+ # DMLERR_INVALIDPARAMETER
1186
+ # DMLERR_NO_ERROR
1187
+ # ---
1188
+ # *Remarks*:
1189
+ # If the hData parameter has not been passed to a Dynamic Data Exchange Management Library (DDEML)
1190
+ # function, an application can use the pointer returned by DdeAccessData for read-write access to the
1191
+ # DDE object. If hData has already been passed to a DDEML function, the pointer should be used only for
1192
+ # read access to the memory object.
1193
+ #
1194
+ # ---
1195
+ # <b>Enhanced (snake_case) API accepts DDE data handle and returns FFI::MemoryPointer to raw data and
1196
+ # size of data set in bytes (same API as enhanced dde_get_data). Returns [nil, 0] in case of failure. </b>
1197
+ #
1198
+ # :call-seq:
1199
+ # data_pointer, size = dde_access_data( data_handle )
1200
+ #
1201
+ function :DdeAccessData, [:HDDEDATA, :pointer], :pointer,
1202
+ &->(api, data_handle){
1203
+ size_buffer = FFI::MemoryPointer.new(:uint32)
1204
+ buffer = api.call(data_handle, size_buffer)
1205
+ size = size_buffer.get_uint32(0)
1206
+ size == 0 ? [nil, 0] : [buffer, size] }
1207
+ # weird lambda literal instead of block is needed because RDoc goes crazy if block is attached to meta-definition
1208
+
1209
+ ##
1210
+ # The DdeUnaccessData function unaccesses a Dynamic Data Exchange (DDE) object. An application must call
1211
+ # this function after it has finished accessing the object.
1212
+ #
1213
+ # [*Syntax*] BOOL DdeUnaccessData( HDDEDATA hData );
1214
+ #
1215
+ # hData:: [in] Handle to the DDE object.
1216
+ #
1217
+ # *Returns*:: If the function succeeds, the return value is nonzero.
1218
+ # If the function fails, the return value is zero.
1219
+ # The DdeGetLastError function can be used to get the error code, which can be one of the following
1220
+ # values:
1221
+ # DMLERR_DLL_NOT_INITIALIZED
1222
+ # DMLERR_INVALIDPARAMETER
1223
+ # DMLERR_NO_ERROR
1224
+ #
1225
+ # ---
1226
+ # <b>Enhanced (snake_case) API returns true/false instead of nonzero/zero: </b>
1227
+ #
1228
+ # :call-seq:
1229
+ # success = dde_unaccess_data(data_handle)
1230
+ #
1231
+ function :DdeUnaccessData, [:HDDEDATA], :int8, boolean: true
1232
+
1233
+ end
1234
+ end