Brian Gideon
8/6/2007 7:15:00 PM
On Aug 5, 4:18 am, manfred_kie...@web.de wrote:
> Hello,
>
> > I didn't see the call in his example, but then again I didn't look
> > very closely. He's probably mixing the DDEML with the raw DDE message
> > protocol which, as I understand, should be perfectly acceptable.
>
> 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
Thanks Manfred. If DDE weren't already nearly defunct and if I
actually had the motivation to keep supporting NDde I'd probably add
that method and publish a new release :)