Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

monitor.c

Go to the documentation of this file.
00001 /****************************** Module Header ******************************\ 00002 * Module Name: monitor.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * DDE Manager client side DDESPY monitoring functions. 00007 * 00008 * Created: 11/20/91 Sanford Staab 00009 \***************************************************************************/ 00010 00011 #include "precomp.h" 00012 #pragma hdrstop 00013 00014 00015 // 00016 // Other monitor events are initiated directly from SetLastDDEMLError() 00017 // and DoCallback(). 00018 // 00019 00020 /***************************************************************************\ 00021 * MonitorStringHandle 00022 * 00023 * Description: 00024 * Launches a string handle monitor event. This function should be 00025 * invoked via the MONHSZ() macro so as not to slow down things much 00026 * when no DDESpy is running. 00027 * 00028 * History: 00029 * 11-26-91 sanfords Created. 00030 \***************************************************************************/ 00031 VOID MonitorStringHandle( 00032 PCL_INSTANCE_INFO pcii, 00033 HSZ hsz, // local atom 00034 DWORD fsAction) 00035 { 00036 WCHAR szT[256]; 00037 PEVENT_PACKET pep; 00038 DWORD cchString; 00039 00040 CheckDDECritIn; 00041 00042 UserAssert(pcii->MonitorFlags & MF_HSZ_INFO); 00043 00044 if (!(cchString = GetAtomName(LATOM_FROM_HSZ(hsz), szT, 00045 sizeof(szT) / sizeof(WCHAR)))) { 00046 SetLastDDEMLError(pcii, DMLERR_INVALIDPARAMETER); 00047 return ; 00048 } 00049 cchString++; 00050 pep = (PEVENT_PACKET)DDEMLAlloc(sizeof(EVENT_PACKET) - sizeof(DWORD) + 00051 sizeof(MONHSZSTRUCT) + cchString * sizeof(WCHAR)); 00052 if (pep == NULL) { 00053 SetLastDDEMLError(pcii, DMLERR_MEMORY_ERROR); 00054 return ; 00055 } 00056 00057 pep->EventType = MF_HSZ_INFO; 00058 pep->fSense = TRUE; 00059 pep->cbEventData = (WORD)(sizeof(MONHSZSTRUCT) + cchString * sizeof(WCHAR)); 00060 00061 #define phszs ((MONHSZSTRUCT *)&pep->Data) 00062 phszs->cb = sizeof(MONHSZSTRUCT); 00063 phszs->fsAction = fsAction; 00064 phszs->dwTime = NtGetTickCount(); 00065 phszs->hsz = hsz; 00066 phszs->hTask = (HANDLE)LongToHandle( pcii->tid ); 00067 // phszs->wReserved = 0; // zero init. 00068 wcscpy(phszs->str, szT); 00069 00070 LeaveDDECrit; 00071 Event(pep); 00072 EnterDDECrit; 00073 #undef phszs 00074 } 00075 00076 00077 00078 00079 /***************************************************************************\ 00080 * MonitorLink 00081 * 00082 * Description: 00083 * Launches a link monitor event. This function should be 00084 * invoked via the MONLINK() macro so as not to slow down things much 00085 * when no DDESpy is running. 00086 * 00087 * History: 00088 * 11-26-91 sanfords Created. 00089 \***************************************************************************/ 00090 VOID MonitorLink( 00091 PCL_INSTANCE_INFO pcii, 00092 BOOL fEstablished, 00093 BOOL fNoData, 00094 LATOM aService, 00095 LATOM aTopic, 00096 GATOM aItem, 00097 WORD wFmt, 00098 BOOL fServer, 00099 HCONV hConvServer, 00100 HCONV hConvClient) 00101 { 00102 PEVENT_PACKET pep; 00103 00104 CheckDDECritIn; 00105 00106 UserAssert(pcii->MonitorFlags & MF_LINKS); 00107 00108 pep = (PEVENT_PACKET)DDEMLAlloc(sizeof(EVENT_PACKET) - sizeof(DWORD) + 00109 sizeof(MONLINKSTRUCT)); 00110 if (pep == NULL) { 00111 SetLastDDEMLError(pcii, DMLERR_MEMORY_ERROR); 00112 return ; 00113 } 00114 00115 pep->EventType = MF_LINKS; 00116 pep->fSense = TRUE; 00117 pep->cbEventData = sizeof(MONLINKSTRUCT); 00118 00119 #define pls ((MONLINKSTRUCT *)&pep->Data) 00120 pls->cb = sizeof(MONLINKSTRUCT); 00121 pls->dwTime = NtGetTickCount(); 00122 pls->hTask = (HANDLE)LongToHandle( pcii->tid ); 00123 pls->fEstablished = fEstablished; 00124 pls->fNoData = fNoData; 00125 00126 // use global atoms here - these need to be changed to local atoms before 00127 // the callbacks to the ddespy apps. 00128 00129 pls->hszSvc = (HSZ)LocalToGlobalAtom(aService); 00130 pls->hszTopic = (HSZ)LocalToGlobalAtom(aTopic); 00131 IncGlobalAtomCount(aItem); 00132 pls->hszItem = (HSZ)aItem; 00133 00134 pls->wFmt = wFmt; 00135 pls->fServer = fServer; 00136 pls->hConvServer = hConvServer; 00137 pls->hConvClient = hConvClient; 00138 00139 LeaveDDECrit; 00140 Event(pep); 00141 EnterDDECrit; 00142 00143 GlobalDeleteAtom((ATOM)(ULONG_PTR)pls->hszSvc); 00144 GlobalDeleteAtom((ATOM)(ULONG_PTR)pls->hszTopic); 00145 GlobalDeleteAtom(aItem); 00146 #undef pls 00147 } 00148 00149 00150 00151 00152 /***************************************************************************\ 00153 * MonitorConv 00154 * 00155 * Description: 00156 * Launches a conversation monitor event. This function should be 00157 * invoked via the MONCONV() macro so as not to slow down things much 00158 * when no DDESpy is running. 00159 * 00160 * History: 00161 * 11-26-91 sanfords Created. 00162 * 5-8-92 sanfords Since the hConv's mean nothing outside this process, 00163 * the hConv fields now hold hwnds. This lets DDESPY 00164 * tie together connect and disconnect events from each 00165 * side. 00166 \***************************************************************************/ 00167 VOID MonitorConv( 00168 PCONV_INFO pcoi, 00169 BOOL fConnect) 00170 { 00171 PEVENT_PACKET pep; 00172 00173 CheckDDECritIn; 00174 00175 UserAssert(pcoi->pcii->MonitorFlags & MF_CONV); 00176 00177 pep = (PEVENT_PACKET)DDEMLAlloc(sizeof(EVENT_PACKET) - sizeof(DWORD) + 00178 sizeof(MONCONVSTRUCT)); 00179 if (pep == NULL) { 00180 SetLastDDEMLError(pcoi->pcii, DMLERR_MEMORY_ERROR); 00181 return ; 00182 } 00183 00184 pep->EventType = MF_CONV; 00185 pep->fSense = TRUE; 00186 pep->cbEventData = sizeof(MONCONVSTRUCT); 00187 00188 #define pcs ((MONCONVSTRUCT *)&pep->Data) 00189 pcs->cb = sizeof(MONCONVSTRUCT); 00190 pcs->fConnect = fConnect; 00191 pcs->dwTime = NtGetTickCount(); 00192 pcs->hTask = (HANDLE)LongToHandle( pcoi->pcii->tid ); 00193 pcs->hszSvc = (HSZ)LocalToGlobalAtom(pcoi->laService); 00194 pcs->hszTopic = (HSZ)LocalToGlobalAtom(pcoi->laTopic); 00195 if (pcoi->state & ST_CLIENT) { 00196 pcs->hConvClient = (HCONV)pcoi->hwndConv; 00197 pcs->hConvServer = (HCONV)pcoi->hwndPartner; 00198 } else { 00199 pcs->hConvClient = (HCONV)pcoi->hwndPartner; 00200 pcs->hConvServer = (HCONV)pcoi->hwndConv; 00201 } 00202 00203 LeaveDDECrit; 00204 Event(pep); 00205 EnterDDECrit; 00206 00207 GlobalDeleteAtom((ATOM)(ULONG_PTR)pcs->hszSvc); 00208 GlobalDeleteAtom((ATOM)(ULONG_PTR)pcs->hszTopic); 00209 #undef pcs 00210 }

Generated on Sat May 15 19:40:52 2004 for test by doxygen 1.3.7