This source file includes following definitions.
- DdeCallback
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #define DEFER_MS_W32_H
20 #include <config.h>
21
22 #include <windows.h>
23 #include <ddeml.h>
24 #include <stdlib.h>
25 #include <stdio.h>
26
27 HDDEDATA CALLBACK DdeCallback (UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, DWORD_PTR,
28 DWORD_PTR);
29
30 HDDEDATA CALLBACK
31 DdeCallback (UINT uType, UINT uFmt, HCONV hconv,
32 HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
33 DWORD_PTR dwData1, DWORD_PTR dwData2)
34 {
35 return ((HDDEDATA) NULL);
36 }
37
38 #define DdeCommand(str) \
39 DdeClientTransaction (str, strlen (str)+1, HConversation, (HSZ)NULL, \
40 CF_TEXT, XTYP_EXECUTE, 30000, NULL)
41
42 int
43 main (int argc, char *argv[])
44 {
45 DWORD idDde = 0;
46 HCONV HConversation;
47 HSZ Server;
48 HSZ Topic = 0;
49 char command[1024];
50
51 if (argc < 2)
52 {
53 fprintf (stderr, "usage: ddeclient server [topic]\n");
54 exit (1);
55 }
56
57 DdeInitialize (&idDde, (PFNCALLBACK)DdeCallback, APPCMD_CLIENTONLY, 0);
58
59 Server = DdeCreateStringHandle (idDde, argv[1], CP_WINANSI);
60 if (argc > 2)
61 Topic = DdeCreateStringHandle (idDde, argv[2], CP_WINANSI);
62
63 HConversation = DdeConnect (idDde, Server, Topic, NULL);
64 if (HConversation != 0)
65 {
66 while (fgets (command, sizeof(command), stdin) != NULL)
67 DdeCommand (command);
68
69 DdeDisconnect (HConversation);
70 }
71
72 DdeFreeStringHandle (idDde, Server);
73 if (Topic)
74 DdeFreeStringHandle (idDde, Topic);
75 DdeUninitialize (idDde);
76
77 return (0);
78 }