Simple(?) DDE problem

Quote
A.J.D...@soton.ac.uk wrote:
>Could somebody please help me on this one.

>I want to list all progman groups in a listbox. According to the winapi
>help you have to read the Groups item. I've tried setting up a
>DDEClientItem but can't get it to work.

        Right. Put a DDEClientConv on the form, set the
DDEService and the DDETopic to Progman. Set the ServiceApplication
to progman.exe.

        Add a memo and a listbox to the form and now do
this:

procedure TForm1.Button1Click(Sender: TObject);
var
  TheData: PChar;
begin
if DDEClientConv1.OpenLink  then
begin
  TheData := DDEClientConv1.RequestData('Groups');
  memo1.settextbuf(TheData);
  listbox1.items.add(Strpas(TheData));
  StrDispose(TheData);
  DDEClientConv1.CloseLink;
end;
end;

        This works for me - if it doesn't work for you I maybe
left out a detail. What you get is a list of group names separated
by carriage returns, which is fine if for some reason you want to
display the names in the memo - if (of course) you want the
listbox instead you need to parse the string into a list.

        IF you have ConnectMode:=ddeAutomatic then you
can omit the OpenLink and the CloseLink. Of course for this
application ddeManual makes more sense.

        Here's a funny thing: This took a few tries, because I
thought that saying

DDEClientItem1.DDEItem:='Groups';
TheData := DDEClientConv1.RequestData(DDEClientItem1.DDEItem);

should work, but it doesn't seem to.

--
David Ullrich
Don't you guys find it tedious typing the same thing
after your signature each time you post something?
I know I do, but when in Rome...