DDE.c File Reference

#include "DDE.h"
#include "ddeml.h"

Include dependency graph for DDE.c:

Go to the source code of this file.

Functions

HDDEDATA CALLBACK DdeCallback (UINT uType, UINT uFmt, HCONV hconv, HSZ hsz1, HSZ hsz2, HDDEDATA hdata, DWORD dwData1, DWORD dwData2)
BOOL DDEIsOpen (void)
BOOL DDEOpenConnection (char *strServeur, char *strTopic)
BOOL DDECloseConnection (void)
BOOL DDEExecute (char *szCommand, int TimeOut)
BOOL DDERequest (char *szItem, int TimeOut, char *Result)
BOOL DDEPoke (char *szItem, char *szData, int TimeOut)

Variables

static DWORD idInst = 0
static HCONV hConv = NULL
static BOOL DDEInUse = FALSE


Function Documentation

HDDEDATA CALLBACK DdeCallback ( UINT  uType,
UINT  uFmt,
HCONV  hconv,
HSZ  hsz1,
HSZ  hsz2,
HDDEDATA  hdata,
DWORD  dwData1,
DWORD  dwData2 
)

Definition at line 12 of file DDE.c.

Referenced by DDEOpenConnection().

00021 {
00022     return 0;
00023 }

Here is the caller graph for this function:

BOOL DDECloseConnection ( void   ) 

Definition at line 66 of file DDE.c.

References DDEInUse, FALSE, hConv, idInst, NULL, and TRUE.

Referenced by _PARAMS().

00067 {
00068         BOOL bOK=FALSE;
00069 
00070         if (DDEInUse)
00071         {
00072                 DDEInUse=FALSE;
00073                 DdeDisconnect(hConv);
00074                 DdeUninitialize(idInst);
00075                 idInst=0;
00076                 hConv=NULL;
00077                 bOK=TRUE;
00078         }
00079         else
00080         {
00081                 bOK=FALSE;
00082         }
00083         return bOK;
00084 }

Here is the caller graph for this function:

BOOL DDEExecute ( char *  szCommand,
int  TimeOut 
)

Definition at line 86 of file DDE.c.

References FALSE, hConv, idInst, L, NULL, and TRUE.

00087 {
00088         BOOL bOK=TRUE;
00089 
00090     HDDEDATA hData = DdeCreateDataHandle(idInst, (LPBYTE)szCommand,
00091                                lstrlen(szCommand)+1, 0, NULL, CF_TEXT, 0);
00092     if (hData==NULL)
00093         {
00094                 bOK=FALSE;        
00095     }
00096     else    
00097         {
00098                 HDDEDATA ReturnValue=NULL;
00099                 bOK=TRUE;
00100                 if (TimeOut>0)
00101                 {
00102                         TimeOut=TIMEOUT_ASYNC;
00103                 }
00104 
00105                 ReturnValue=DdeClientTransaction((LPBYTE)hData, 0xFFFFFFFF, hConv, 0L, 0,
00106                              XTYP_EXECUTE, TimeOut, NULL);
00107                 
00108                 if (!ReturnValue) bOK=FALSE;
00109     }
00110         return bOK;
00111 }

BOOL DDEIsOpen ( void   ) 

Definition at line 25 of file DDE.c.

References DDEInUse.

00026 {
00027         return DDEInUse;
00028 }

BOOL DDEOpenConnection ( char *  strServeur,
char *  strTopic 
)

Definition at line 30 of file DDE.c.

References DdeCallback(), DDEInUse, FALSE, hConv, idInst, NULL, TRUE, and UINT.

Referenced by _PARAMS().

00031 {
00032         UINT iReturn=DMLERR_NO_ERROR;
00033         BOOL bOK=TRUE;
00034         
00035         if (DDEInUse)
00036         {
00037                 bOK=FALSE;
00038         }
00039         else
00040         {
00041                 iReturn = DdeInitialize(&idInst, (PFNCALLBACK)DdeCallback, 
00042                             APPCLASS_STANDARD | APPCMD_CLIENTONLY, 0 );
00043                 if (iReturn!=DMLERR_NO_ERROR)
00044                 {
00045                         bOK=FALSE;
00046                 }
00047                 else
00048                 {
00049                         HSZ hszApp, hszTopic;
00050                         hszApp = DdeCreateStringHandle(idInst, strServeur, 0);
00051                         hszTopic = DdeCreateStringHandle(idInst, strTopic, 0);
00052                         hConv = DdeConnect(idInst, hszApp, hszTopic, NULL);
00053                         DdeFreeStringHandle(idInst, hszApp);
00054                         DdeFreeStringHandle(idInst, hszTopic);
00055                         if (hConv == NULL)
00056                         {
00057                                 DdeUninitialize(idInst);
00058                                 bOK=FALSE;
00059                         }
00060                         DDEInUse=TRUE;
00061                 }
00062         }
00063     return bOK;
00064 }

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL DDEPoke ( char *  szItem,
char *  szData,
int  TimeOut 
)

Definition at line 140 of file DDE.c.

References FALSE, hConv, idInst, NULL, and TRUE.

00141 {
00142         BOOL bOK=TRUE;
00143         HDDEDATA ReturnValue=NULL;
00144 
00145     HSZ hszItem = DdeCreateStringHandle(idInst, szItem, 0);
00146         if ( TimeOut < 0 )
00147         {
00148                 TimeOut=3000;
00149         }
00150         
00151         ReturnValue=DdeClientTransaction((LPBYTE)szData, (DWORD)(lstrlen(szData)+1),
00152                                                         hConv, hszItem, CF_TEXT,
00153                                                         XTYP_POKE, TimeOut, NULL);
00154 
00155         if (!ReturnValue) bOK=FALSE;
00156     if (!DdeFreeStringHandle(idInst, hszItem)) bOK=FALSE;
00157 
00158         return bOK;
00159 }

BOOL DDERequest ( char *  szItem,
int  TimeOut,
char *  Result 
)

Definition at line 113 of file DDE.c.

References FALSE, hConv, idInst, NULL, and TRUE.

00114 {
00115         BOOL bOK=FALSE;
00116         HDDEDATA hData =NULL;
00117 
00118     HSZ hszItem = DdeCreateStringHandle(idInst, szItem, 0);
00119 
00120         if ( TimeOut < 0 )
00121         {
00122                 TimeOut=3000;
00123         }
00124         
00125         hData = DdeClientTransaction(NULL,0,hConv,hszItem,CF_TEXT, 
00126                                  XTYP_REQUEST,TimeOut, NULL);
00127     if (hData==NULL)
00128     {
00129         bOK=FALSE;
00130     }
00131     else
00132     {
00133         DdeGetData(hData, (unsigned char *)Result, (DWORD)strlen(Result), 0);
00134                 if ( DdeGetLastError(idInst) == DMLERR_NO_ERROR ) bOK=TRUE;
00135     }
00136 
00137         return bOK;
00138 }


Variable Documentation

BOOL DDEInUse = FALSE [static]

Definition at line 10 of file DDE.c.

Referenced by DDECloseConnection(), DDEIsOpen(), and DDEOpenConnection().

HCONV hConv = NULL [static]

Definition at line 9 of file DDE.c.

Referenced by DDECloseConnection(), DDEExecute(), DDEOpenConnection(), DDEPoke(), and DDERequest().

DWORD idInst = 0 [static]

Definition at line 8 of file DDE.c.

Referenced by DDECloseConnection(), DDEExecute(), DDEOpenConnection(), DDEPoke(), and DDERequest().


Generated on Sun Mar 4 16:14:15 2007 for Scilab [trunk] by  doxygen 1.5.1