home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / os2sdk / os2sdk12 / ddeml / ddeml.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-22  |  13.3 KB  |  362 lines

  1. /****************************** Module Header ******************************\
  2. * Module Name: DDE.H
  3. *
  4. * Assumes pmwin.h is already included.
  5. *
  6. * Created: 12/15/88 Sanford Staab
  7. *
  8. * Copyright (c) 1988, 1989  Microsoft Corporation
  9. \***************************************************************************/
  10.  
  11. #ifdef INCL_32
  12. #define DdeInitialize Dde32Initialize
  13. #define DdeUninitialize Dde32Uninitialize
  14. #define DdeBeginEnumServers Dde32BeginEnumServers
  15. #define DdeGetNextServer Dde32GetNextServer
  16. #define DdeEndEnumServers Dde32EndEnumServers
  17. #define DdeConnect Dde32Connect
  18. #define DdeDisconnect Dde32Disconnect
  19. #define DdeQueryConvInfo Dde32QueryConvInfo
  20. #define DdeCheckQueue Dde32CheckQueue
  21. #define DdePostAdvise Dde32PostAdvise
  22. #define DdeEnableCallback Dde32EnableCallback
  23. #define DdeAppNameServer Dde32AppNameServer
  24. #define DdeCreateInitPkt Dde32CreateInitPkt
  25. #define DdeProcessPkt Dde32ProcessPkt
  26. #define DdeClientXfer Dde32ClientXfer
  27. #define DdePutData Dde32PutData
  28. #define DdeAddData Dde32AddData
  29. #define DdeGetData Dde32GetData
  30. #define DdeAccessData Dde32AccessData
  31. #define DdeFreeData Dde32FreeData
  32. #define DdeGetLastError Dde32GetLastError
  33. #define DdePostError Dde32PostError
  34. #define DdeGetErrorString Dde32GetErrorString
  35. #define DdeDebugBreak Dde32DebugBreak
  36. #define DdeCopyBlock Dde32CopyBlock
  37. #define DdeGetHsz Dde32GetHsz
  38. #define DdeGetHszString Dde32GetHszString
  39. #define DdeFreeHsz Dde32FreeHsz
  40. #define DdeIncHszCount Dde32IncHszCount
  41. #define DdeCmpHsz Dde32CmpHsz
  42. #define DdeQueryVersion Dde32QueryVersion
  43. #define DdeConverseWithWindow DdeMGr32ConverseWithWindow
  44. #define DdeCreateServerWindow Dde32CreateServerWindow
  45. #define DdeTest Dde32Test
  46. #endif
  47.  
  48. /******** public types ********/
  49.  
  50. typedef HWND HCONVLIST;
  51. typedef HWND HCONV;
  52. typedef LHANDLE HAPP;
  53. typedef LHANDLE HSZ;
  54. typedef HSZ FAR *PHSZ;
  55. typedef LHANDLE HDMGDATA;
  56. typedef HDMGDATA FAR *PHDMGDATA;
  57.  
  58. #ifdef SLOOP
  59. typedef struct _CONVCONTEXT { /* cctxt */
  60.     USHORT cb;        /* sizeof(CONVCONTEXT) */
  61.     USHORT fsContext;
  62.     USHORT idCountry;
  63.     USHORT usCodepage;
  64.     USHORT usLangID;
  65.     USHORT usSubLangID;
  66. } CONVCONTEXT;
  67. typedef CONVCONTEXT FAR *PCONVCONTEXT;
  68. #define DDECTXT_CASESENSITIVE     0x0001
  69.  
  70. typedef struct _NEWDDEINIT { /* ddei */
  71.     USHORT  cb;        /* sizeof(DDEINIT) */
  72.     PSZ        pszAppName;
  73.     PSZ        pszTopic;
  74.     USHORT  offConvContext;
  75. } NEWDDEINIT;
  76. typedef NEWDDEINIT FAR *PNEWDDEINIT;
  77.  
  78. #define DDEINIT NEWDDEINIT
  79. #define PDDEINIT PNEWDDEINIT
  80. #define DDEI_PCONVCONTEXT(pddei)    \
  81.     ((PCONVCONTEXT)((PBYTE)pddei + pddei->offConvContext))
  82.     
  83. #endif /* SLOOP */
  84.  
  85. /* PUBDOC START */
  86.  
  87. /* the following structure is for use with XTYP_WILDINIT processing. */
  88.  
  89. typedef struct _HSZPAIR {
  90.     HSZ hszApp;
  91.     HSZ hszTopic;
  92. } HSZPAIR;
  93. typedef HSZPAIR FAR *PHSZPAIR;
  94.  
  95. /* The following structure is provided for servicing DdeAppNameServer()
  96.  * data handles.
  97.  */
  98.  
  99. typedef struct _HSZHAPP {
  100.     HSZ hsz;
  101.     HAPP hApp;
  102. } HSZHAPP;
  103. typedef HSZHAPP FAR *PHSZHAPP;
  104.  
  105. /* The following structure is used by DdeQueryConvInfo(): */
  106.  
  107. /* PUBDOC START */
  108.  
  109. typedef struct _CONVINFO {
  110.     ULONG   cb;          /* sizeof(CONVINFO) */
  111.     HCONV   hConvPartner;/* hConv on other end or 0 if non-ddeml partner */
  112.     HSZ     hszAppPartner; /* app name of partner if obtainable */
  113.     HSZ     hszAppName;  /* AppName for conversation */
  114.     HSZ     hszTopic;    /* Topic name for conversation */
  115.     HSZ     hszItem;     /* transaction item name or NULL if quiescent */
  116.     ULONG   hAgent;      /* foreign agent handle associated with this conv */
  117.     USHORT  usFmt;       /* transaction format or NULL if quiescent */
  118.     USHORT  usType;      /* XTYP_ for current transaction */
  119.     USHORT  usStatus;    /* ST_ constant for current conversation */
  120.     USHORT  usConvst;    /* CONVST_ constant for current transaction */
  121.     USHORT  LastError;   /* last transaction error. */
  122.     USHORT  fsContext;   /* conversation context flags */
  123.     USHORT  usCodepage;  /* conversation context codepage */
  124.     USHORT  idCountry;   /* conversation context countrycode */
  125.     HAPP    hApp;        /* application handle associated with this hConv */
  126. } CONVINFO;
  127. typedef CONVINFO FAR *PCONVINFO;
  128.  
  129. /***** conversation states (usConvst) *****/
  130.  
  131. #define     CONVST_NULL              0  /* quiescent states */
  132. #define     CONVST_INCOMPLETE        1
  133. #define     CONVST_TERMINATED        2
  134. #define     CONVST_CONNECTED         3
  135. #define     CONVST_INIT1             4  /* mid-initiation state */
  136. #define     CONVST_REQSENT           5  /* active conversation states */
  137. #define     CONVST_DATARCVD          6
  138. #define     CONVST_POKESENT          7
  139. #define     CONVST_POKEACKRCVD       8
  140. #define     CONVST_EXECSENT          9
  141. #define     CONVST_EXECACKRCVD      10
  142. #define     CONVST_ADVSENT          11
  143. #define     CONVST_UNADVSENT        12
  144. #define     CONVST_ADVACKRCVD       13
  145. #define     CONVST_UNADVACKRCVD     14
  146. #define     CONVST_ADVDATASENT      15
  147. #define     CONVST_ADVDATAACKRCVD   16
  148.  
  149. /***** conversation status bits (fsStatus) *****/
  150.  
  151. #define     ST_CONNECTED        0x0001
  152. #define     ST_ADVISE           0x0002
  153. #define     ST_INTRADLL         0x0004    
  154.  
  155. /* PUBDOC END */
  156.  
  157. /****** constants *******/
  158.  
  159. #define     MAX_ERRSTR      50
  160. #define     MAX_MONITORSTR  511
  161.  
  162. /***** modal loop timer IDs *****/
  163.  
  164. #define     TID_TIMEOUT             1
  165. #define     TID_ABORT               2
  166. #define     TID_SELFDESTRUCT        3
  167.  
  168. /***** message filter hook types *****/
  169.  
  170. #define     MSGF_DDE             0x8001
  171.  
  172. /***** transaction types *****/
  173.  
  174. #define     XTYPF_NOBLOCK            0x0002  /* CBR_BLOCK will not work */
  175. #define     XTYPF_NODATA             0x0004  /* DDE_FNODATA */
  176. #define     XTYPF_ACKREQ             0x0008  /* DDE_FACKREQ */
  177.                                     
  178. #define     XCLASS_MASK              0xF000
  179. #define     XCLASS_BOOL              0x1000
  180. #define     XCLASS_DATA              0x2000
  181. #define     XCLASS_FLAGS             0x4000
  182. #define     XCLASS_NOTIFICATION      0x8000
  183. #define     XCLASS_DATAIN            0x0800
  184.                                            
  185. #define     XTYP_ACK                (0x0010 | XCLASS_NOTIFICATION)
  186. #define     XTYP_ADVDATA            (0x0020 | XCLASS_FLAGS | XCLASS_DATAIN )
  187. #define     XTYP_ADVREQ             (0x0030 | XCLASS_DATA          )
  188. #define     XTYP_ADVSTART           (0x0040 | XCLASS_BOOL          )
  189. #define     XTYP_ADVSTOP            (0x0050 | XCLASS_NOTIFICATION)
  190. #define     XTYP_EXEC               (0x0060 | XCLASS_FLAGS | XCLASS_DATAIN )
  191. #define     XTYP_INIT               (0x0070 | XCLASS_BOOL | XTYPF_NOBLOCK)
  192. #define     XTYP_INIT_CONFIRM       (0x0080 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK)
  193. #define     XTYP_MONITOR            (0x0090 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK | XCLASS_DATAIN)
  194. #define     XTYP_PKT                (0x00A0 | XCLASS_DATA          )
  195. #define     XTYP_POKE               (0x00B0 | XCLASS_FLAGS | XCLASS_DATAIN )
  196. #define     XTYP_REGISTER           (0x00C0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK)
  197. #define     XTYP_REQUEST            (0x00D0 | XCLASS_DATA          )
  198. #define     XTYP_RTNPKT             (0x00E0 | XCLASS_NOTIFICATION | XCLASS_DATAIN )
  199. #define     XTYP_TERM               (0x00F0 | XCLASS_NOTIFICATION  )
  200. #define     XTYP_UNREGISTER         (0x0100 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK)
  201. #define     XTYP_WILDINIT           (0x0110 | XCLASS_DATA | XTYPF_NOBLOCK )
  202. #define     XTYP_XFERCOMPLETE       (0x0120 | XCLASS_NOTIFICATION  )
  203.  
  204. /***** Timeout constants *****/
  205.  
  206. #define     TIMEOUT_ASYNC           -1L
  207.  
  208. /***** error codes *****/
  209.  
  210. #define     DMGERR_NO_ERROR                    0       /* must be 0 */
  211. #define     DMGERR_FIRST                       0x4000
  212. #define     DMGERR_POSTMSG_FAILED              0x4000
  213. #define     DMGERR_DLL_NOT_INITIALIZED         0x4001
  214. #define     DMGERR_PMWIN_ERROR                 0x4002
  215. #define     DMGERR_NO_CONV_ESTABLISHED         0x4003
  216. #define     DMGERR_TIMEOUT                     0x4004
  217. #define     DMGERR_REENTRANCY                  0x4005
  218. #define     DMGERR_DLL_USAGE                   0x4006
  219. #define     DMGERR_BAD_APP_NAME                0x4007
  220. #define     DMGERR_DOS_ERROR                   0x4008
  221. #define     DMGERR_SYSTOPIC_NOT_SUPPORTED      0x4009
  222. #define     DMGERR_INVALID_HDMGDATA            0x400A
  223. #define     DMGERR_BUSY                        0x400B
  224. #define     DMGERR_NOTPROCESSED                0x400C
  225. #define     DMGERR_INVALIDPARAMETER            0x400D
  226. #define     DMGERR_MEMORY_ERROR                0x400E
  227. #define     DMGERR_POKEACKTIMEOUT              0x400F
  228. #define     DMGERR_EXECACKTIMEOUT              0x4010
  229. #define     DMGERR_DATAACKTIMEOUT              0x4011
  230. #define     DMGERR_SERVER_DIED                 0x4012
  231. #define     DMGERR_ADVACKTIMEOUT               0x4013
  232. #define     DMGERR_UNADVACKTIMEOUT             0x4014
  233. #define     DMGERR_ACCESS_DENIED               0x4015
  234. #define     DMGERR_UNFOUND_QUEUE_ID            0x4016
  235. #define     DMGERR_NOT_IMPLEMENTED             0x4017 
  236. #define     DMGERR_LAST                        0x4017
  237.  
  238.  
  239. /****** public strings used in DDE ******/
  240.  
  241. #define SZDDESYS_TOPIC "System"
  242. #define SZDDESYS_ITEM_TOPICS "Topics"
  243. #define SZDDESYS_ITEM_SYSITEMS "SysItems"
  244. #define SZDDESYS_ITEM_RTNMSG "ReturnMessage"
  245. #define SZDDESYS_ITEM_STATUS "Status"
  246. #define SZDDESYS_ITEM_FORMATS "Formats"
  247.  
  248.  
  249. /****** API entry points ******/
  250.  
  251. typedef HDMGDATA EXPENTRY FNCALLBACK(HCONV hConv, HSZ hszTopic, HSZ hszItem,
  252.             USHORT usFmt, USHORT usType, HDMGDATA hDmgData);
  253. typedef HDMGDATA (EXPENTRY FAR *PFNCALLBACK)(HCONV hConv, HSZ hszTopic,
  254.             HSZ hszItem, USHORT usFmt, USHORT usType, HDMGDATA hDmgData);
  255.             
  256. #define     CBR_BLOCK                0xffffffffL
  257.  
  258. /* DLL registration functions */
  259.  
  260. USHORT EXPENTRY DdeInitialize(PFNCALLBACK pfnCallback,
  261.         ULONG afCmd, ULONG ulRes);
  262.  
  263. #define     DMGCMD_MONITOR          0x0001L
  264. #define     DMGCMD_CLIENTONLY       0x0002L
  265. #define     DMGCMD_CASEINSENSITIVE  0x0008L
  266. #define     DMGCMD_AGENT            0x0010L
  267. #define     DMGCMD_FILTERINITS      0x0020L
  268.  
  269. BOOL EXPENTRY DdeUninitialize(void);
  270.  
  271. /* conversation enumeration functions */
  272.  
  273. HCONVLIST EXPENTRY DdeBeginEnumServers(HSZ hszAppName, HSZ hszTopic,
  274.         HCONV hConvList, PCONVCONTEXT pCC, HAPP hApp);
  275. HCONV EXPENTRY DdeGetNextServer(HCONVLIST hConvList, HCONV hConvPrev);
  276. BOOL EXPENTRY DdeEndEnumServers(HCONVLIST hConvList);
  277.  
  278. /* conversation control functions */
  279.  
  280. HCONV EXPENTRY DdeConnect(HSZ hszAppName, HSZ hszTopic, PCONVCONTEXT pCC,
  281.         HAPP hApp);
  282. BOOL EXPENTRY DdeDisconnect(HCONV hConv);
  283.  
  284. BOOL EXPENTRY DdeQueryConvInfo(HCONV hConv, PCONVINFO pConvInfo,
  285.         ULONG idXfer);
  286.         
  287. ULONG EXPENTRY DdeCheckQueue(HCONV hConv, PHDMGDATA phDmgData,
  288.         ULONG idXfer, ULONG afCmd);
  289.  
  290. #define     CQ_FLUSH                0x0001L
  291. #define     CQ_NEXT                 0x0002L
  292. #define     CQ_PREV                 0x0004L
  293. #define     CQ_COUNT                0x0008L
  294. #define     CQ_ACTIVEONLY           0x0010L
  295. #define     CQ_INACTIVEONLY         0x0020L
  296. #define     CQ_COMPLETEDONLY        0x0040L
  297. #define     CQ_FAILEDONLY           0x0080L
  298. #define     CQ_REMOVE               0x0100L
  299.  
  300. #define     QID_SYNC                 0L
  301. #define     QID_NEWEST              -1L
  302. #define     QID_OLDEST              -2L
  303.  
  304.  
  305. /* app server interface functions */
  306.  
  307. BOOL EXPENTRY DdePostAdvise(HSZ hszTopic, HSZ hszItem);
  308. BOOL EXPENTRY DdeEnableCallback(HCONV hConv, BOOL fEnable);
  309.  
  310. HDMGDATA EXPENTRY DdeAppNameServer(HSZ hszApp, USHORT afCmd);
  311.  
  312. #define ANS_REGISTER        0x0001
  313. #define ANS_UNREGISTER      0x0002
  314. #define ANS_QUERYALLBUTME   0x0004
  315. #define ANS_QUERYMINE       0x0008
  316. #define ANS_FILTERON        0x8000
  317. #define ANS_FILTEROFF       0x4000
  318.  
  319. /* agent interface functions */
  320.  
  321. HDMGDATA EXPENTRY DdeCreateInitPkt(HSZ hszApp, HSZ hszTopic,
  322.         HDMGDATA hDmgData);
  323. HDMGDATA EXPENTRY DdeProcessPkt(HDMGDATA hPkt, ULONG hAgentFrom);
  324.  
  325. /* app client interface functions */
  326.  
  327. HDMGDATA EXPENTRY DdeClientXfer(PBYTE pSrc, ULONG cb, HCONV hConv,
  328.         HSZ hszItem, USHORT usFmt, USHORT usType, ULONG ulTimeout,
  329.         PULONG pidXfer);
  330.  
  331. /* data transfer functions */
  332.  
  333. HDMGDATA EXPENTRY DdePutData(PBYTE pSrc, ULONG cb, ULONG cbOff, HSZ hszItem,
  334.         USHORT usFmt, USHORT afCmd);
  335.  
  336. #define     HDATA_APPOWNED          0x0001
  337.  
  338. HDMGDATA EXPENTRY DdeAddData(HDMGDATA hDmgData, PBYTE pSrc, ULONG cb,
  339.         ULONG cbOff);
  340. ULONG EXPENTRY DdeGetData(HDMGDATA hDmgData, PBYTE pDst, ULONG cbMax,
  341.         ULONG cbOff);
  342. PBYTE EXPENTRY DdeAccessData(HDMGDATA hDmgData);
  343. BOOL EXPENTRY DdeFreeData(HDMGDATA hDmgData);
  344.  
  345. /* other exported functions */
  346.  
  347. USHORT EXPENTRY DdeGetLastError(void);
  348. void EXPENTRY DdePostError(USHORT err);
  349. USHORT EXPENTRY DdeGetErrorString(USHORT err, USHORT cbMax, PSZ psz);
  350. void EXPENTRY DdeDebugBreak(void);
  351. BOOL EXPENTRY DdeCopyBlock(PBYTE pSrc, PBYTE pDst, ULONG cb);
  352. HSZ EXPENTRY DdeGetHsz(PSZ psz, USHORT country, USHORT codepage);
  353. USHORT EXPENTRY DdeGetHszString(HSZ hsz, PSZ psz, ULONG cchMax);
  354. BOOL EXPENTRY DdeFreeHsz(HSZ hsz);
  355. BOOL EXPENTRY DdeIncHszCount(HSZ hsz);
  356. SHORT EXPENTRY DdeCmpHsz(HSZ hsz1, HSZ hsz2);
  357. ULONG EXPENTRY DdeQueryVersion(void);
  358. HCONV EXPENTRY DdeConverseWithWindow(HWND hwnd, HSZ hszApp,
  359.         HSZ hszTopic, PCONVCONTEXT pCC);
  360. HWND EXPENTRY DdeCreateServerWindow(HSZ hszApp, HSZ hszTopic, PCONVCONTEXT pCC);
  361. void EXPENTRY DdeTest(void);
  362.