Hello,
I am trying to connect to three legacy programs supporting DDE, and are designed to connect with Excel as a client. I can connect directly with excel for all programs and be able to get data.
However, when trying to use the sample clientwin app, and connecting to those programs, I am using the below NDde format id when calling the client.StartAdvise(myItem, xltableFormat, true, 60000) fuction.
When I use 1 in the function instead of xltableFormat (see below), i receive no errors but the textbox in the client sample app shows nothing and the client_Advise(object sender, DdeAdviseEventArgs args) function will never be executed.
//Get the xlTable format id to be used in the advise
int xltableFormat = System.Convert.ToInt32(System.Windows.Forms.DataFormats.GetFormat("XlTable").Id);
So, calling the StartAdvise function, because the legacy apps supports Excel, I have to use xlTable as without it the client won't be able to connect to the DDE server of the legacy programs.
ddeClientCompany = new DdeClient(myService, myTopic, this);
ddeClientCompany.Advise += clientAllCompanies_Advise;
ddeClientCompany.Connect();
ddeClientCompany.StartAdvise(myItem, xltableFormat, true, 60000);
In summary:
Program 1 succeeded to connect and got the data from the legacy app, but with the programs 2 & 3, I received an error in DdemlClient.cs Line 845 as below message with Exception Thrown. "NDde.Internal.DdemlException: 'The client failed to initiate an advise loop for "MRegionalDdeServer|STTDWL�1010�TDWL!HIGH".'" But as mentioned above, receive no updates when using 1 for the format id.
I am not sure what's the root cause of the issue. The only difference that I noticed between Program 1 and 2 is that the string for Item in Program 2 has a text (LOW) instead of a number (22). Also, there is as well the use of FS (File Separator) special character (�) or the hex value (0x1C) in the string instead of the character ~.
For Program 3, I was not sure how to break the string into the Topic and Item parts. Some suggestions are truly appreciated.
I have attached an image of the code. Your help is truly appreciated. Thanks in advance!
Program 1 (successful connection): MRegionalDdeServer|'BOTDWL~1010~0'!'22'*1
// Program 1
// = MRegionalDdeServer | 'BOTDWL~1010~0'!'10' * 1
myService = "MRegionalDdeServer";
myTopic = "BOTDWL~1010~0";
myItem = "22";
Program 2 (Failed connection): MRegionalDdeServer|'STTDWL�1010�TDWL'!HIGH
NDde.Foundation.DdemlException: 'The client failed to initiate an advise loop for "MRegionalDdeServer|'STTDWL�1010�TDWL'!HIGH".'
// Program 2
// =TickerChart|Live!'QO.1010.TAD$HIGH'
myService = "TickerChart";
myTopic = "Live";
myItem = "'QO.1010.TAD$low'";
Program 3 (Failed connection): TickerChart|Live!'QO.1010.TAD$High'
NDde.Foundation.DdemlException: 'The client failed to initiate an advise loop for "TickerChart|Live!'QO.1010.TAD$High'".'
// Program 3
// = MRegionalDdeServer|'STTDWL�1010�TDWL'!High
myService = "MRegionalDdeServer";
myTopic = "STTDWL�1010�TDWL";
myItem = "LOW";