Asked By manfred_kiene
05-Aug-07 05:18 AM

Hello,
Brian: yes, you are right. At my first message I talked about your
NDDE but
write the linkt to Marc's sample. Sorry
I realized that yesterday.
This solution to get "a list of DDE-Servers" works
(in context with the NDDE-library)
I Changed this definitions in DDEML.CS:
public static extern IntPtr DdeConnectList(int idInst, IntPtr
hszService, IntPtr hszTopic, IntPtr hConvList, ref
NDde.Foundation.Ddeml.CONVCONTEXT pCC/*IntPtr pCC*/);
public static extern int DdeQueryConvInfo(IntPtr hConv, int
idTransaction, ref CONVINFO pConvInfo/*IntPtr pConvInfo*/);
I added this in DDEMLClient.cs
public string[] GetListOfDdeServer()
{
ArrayList DdeServers = new ArrayList();
IntPtr hszSystem =
Ddeml.DdeCreateStringHandle(_InstanceId,"System",Ddeml.CP_WINANSI);
NDde.Foundation.Ddeml.CONVCONTEXT pCC = new
NDde.Foundation.Ddeml.CONVCONTEXT();
pCC.cb = (ushort)Marshal.SizeOf(pCC);
IntPtr hConvList =
Ddeml.DdeConnectList(_InstanceId,IntPtr.Zero,hszSystem,
IntPtr.Zero, // new list
ref pCC); // default context
Ddeml.DdeFreeStringHandle(_InstanceId,hszSystem);
//
// Walk the list adding the server names to our listbox
//
IntPtr hConv = IntPtr.Zero;
Ddeml.CONVINFO pConvInfo = new Ddeml.CONVINFO();
pConvInfo.cb = (ushort)Marshal.SizeOf(pConvInfo);
while((hConv = Ddeml.DdeQueryNextServer(hConvList,hConv)) !
= IntPtr.Zero)
{
int ui =
Ddeml.DdeQueryConvInfo(hConv,Ddeml.QID_SYNC,ref pConvInfo);
StringBuilder psz = new StringBuilder(255);
Ddeml.DdeQueryString(_InstanceId,
(IntPtr)pConvInfo.hszSvcPartner,psz,psz.Capacity,Ddeml.CP_WINANSI);
DdeServers.Add(psz.ToString());
Debug.WriteLine(psz.ToString());
}
//
// Free the list handle
//
Ddeml.DdeDisconnectList(hConvList);
return (string[])DdeServers.ToArray(typeof(string));
}
It was i little "try and error" (e.g. Thread-Handling), but now it
works "good enought"
@Brian, @Marc:
thank you for your help.
regards
Manfred Kiener