G
Guest
If anyone can help me it would be greatly appreciated
I am struggling with connection to a DDE server - I have a global variable defined as my conversation handle (newDDE) and the instance defined also as a global variable (dwDDEInst). I get a successful connection, which sits until I want to send a command. When I actually send my command (SendKeystring - which in this case always sends ESC: "^[" through DdeClientTransaction) I get a 16390 error which means Invalid Parameter. If anyone can help me figure out which parameter is invalid it would be greatly appreciated
Thanks in advance
Dal
HCONV newDDE = NULL
DWORD dwDDEInst;
void ConnectNewDDE(
dwDDEInst=0L;
CONVCONTEXT CCFilter = { sizeof (CONVCONTEXT), 0, 0, 0, 0L, 0L };
char msgn[512]
LogFile.Log(1,"[ConnectNewDDE]")
if (DdeInitialize(&dwDDEInst,(PFNCALLBACK)&LWDdeCallback,APPCLASS_STANDARD|APPCMD_CLIENTONLY,0) == DMLERR_NO_ERROR
HSZ szProgMan = DdeCreateStringHandle(dwDDEInst,_T("LCW4"),CP_WINANSI)
HSZ hszTopic = DdeCreateStringHandle(dwDDEInst,"Info",NULL)
newDDE = DdeConnect(dwDDEInst,szProgMan,hszTopic,&CCFilter)
DdeFreeStringHandle(dwDDEInst,szProgMan)
while (newDDE == 0L
newDDE = DdeConnect(dwDDEInst,szProgMan,hszTopic,&CCFilter)
sprintf(msgn,"[ConnectNewDDE] - Failed to connect to Server: Error Code %d",DdeGetLastError(dwDDEInst))
LogFile.Log(1,msgn)
Sleep(1000)
sprintf(msgn,"[ConnectNewDDE] - Connected to DDE!")
LogFile.Log(1,msgn)
els
sprintf(msgn,"[ConnectNewDDE] - Failed to initialize server: Error Code %d",DdeGetLastError(dwDDEInst))
LogFile.Log(1,msgn)
void SendKeystring(char myKeystring[100]
char msgn[512]
char strCmd[256]
HSZ hszItem = DdeCreateStringHandle(dwDDEInst,"Keystring",NULL)
char szText[512]
strcpy(szText,"^[")
int k = strlen(szText)
k++
// int k = strlen(myKeystring)
// k++
HDDEDATA hClientResult
hClientResult = DdeClientTransaction((LPBYTE)"^[", k, newDDE, hszItem, CF_TEXT, XTYP_POKE, 5000, NULL)
if (hClientResult == 0
sprintf(msgn,"[SendKeystring] - Failed to create transaction! Error: %d", DdeGetLastError(dwDDEInst))
LogFile.Log(1,msgn)
els
LogFile.Log(1,"[SendKeystring] - Transaction Sent to LastWord.")
}
I am struggling with connection to a DDE server - I have a global variable defined as my conversation handle (newDDE) and the instance defined also as a global variable (dwDDEInst). I get a successful connection, which sits until I want to send a command. When I actually send my command (SendKeystring - which in this case always sends ESC: "^[" through DdeClientTransaction) I get a 16390 error which means Invalid Parameter. If anyone can help me figure out which parameter is invalid it would be greatly appreciated
Thanks in advance
Dal
HCONV newDDE = NULL
DWORD dwDDEInst;
void ConnectNewDDE(
dwDDEInst=0L;
CONVCONTEXT CCFilter = { sizeof (CONVCONTEXT), 0, 0, 0, 0L, 0L };
char msgn[512]
LogFile.Log(1,"[ConnectNewDDE]")
if (DdeInitialize(&dwDDEInst,(PFNCALLBACK)&LWDdeCallback,APPCLASS_STANDARD|APPCMD_CLIENTONLY,0) == DMLERR_NO_ERROR
HSZ szProgMan = DdeCreateStringHandle(dwDDEInst,_T("LCW4"),CP_WINANSI)
HSZ hszTopic = DdeCreateStringHandle(dwDDEInst,"Info",NULL)
newDDE = DdeConnect(dwDDEInst,szProgMan,hszTopic,&CCFilter)
DdeFreeStringHandle(dwDDEInst,szProgMan)
while (newDDE == 0L
newDDE = DdeConnect(dwDDEInst,szProgMan,hszTopic,&CCFilter)
sprintf(msgn,"[ConnectNewDDE] - Failed to connect to Server: Error Code %d",DdeGetLastError(dwDDEInst))
LogFile.Log(1,msgn)
Sleep(1000)
sprintf(msgn,"[ConnectNewDDE] - Connected to DDE!")
LogFile.Log(1,msgn)
els
sprintf(msgn,"[ConnectNewDDE] - Failed to initialize server: Error Code %d",DdeGetLastError(dwDDEInst))
LogFile.Log(1,msgn)
void SendKeystring(char myKeystring[100]
char msgn[512]
char strCmd[256]
HSZ hszItem = DdeCreateStringHandle(dwDDEInst,"Keystring",NULL)
char szText[512]
strcpy(szText,"^[")
int k = strlen(szText)
k++
// int k = strlen(myKeystring)
// k++
HDDEDATA hClientResult
hClientResult = DdeClientTransaction((LPBYTE)"^[", k, newDDE, hszItem, CF_TEXT, XTYP_POKE, 5000, NULL)
if (hClientResult == 0
sprintf(msgn,"[SendKeystring] - Failed to create transaction! Error: %d", DdeGetLastError(dwDDEInst))
LogFile.Log(1,msgn)
els
LogFile.Log(1,"[SendKeystring] - Transaction Sent to LastWord.")
}