Microsoft KB Archive/112384

= Retrieving Groups & Items from Program Manager Using DDE in VB =

Article ID: 112384

Article Last Modified on 12/9/2003

-

APPLIES TO


 * Microsoft Visual Basic 1.0 Standard Edition
 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q112384



SUMMARY
Program Manager (Progman) has a DDE command-string interface that allows other applications to view the groups and items that currently exist within Progman.



MORE INFORMATION
Perform the following steps to produce an application that will retrieve the group and items from Progman by using DDE:

 Start a new project in Visual Basic. Form1 is created by default. Add two Text box controls (tGroups and tItems) to Form1. Set the visible property on both to false. The DDE link needs these controls. Add two Combo box controls (ComGroups and ComItems) to Form1. Add a Command button (cGroups) to Form1 and change the caption property to Groups.  Add the following code to the cGroups_Click event: Sub cGroups_Click Dim sGroups As String Dim pos As Integer On Error GoTo GError tGroups.LinkMode = 0 tGroups.LinkTopic = "Progman|Progman" tGroups.LinkMode = 2 tGroups.LinkItem = "groups" tGroups.LinkRequest

' Parse groups that come back: sGroups = tGroups.Text pos = InStr(1, sGroups, Chr(13)) While pos ComGroups.AddItem RTrim$(Mid$(sGroups, 1, pos - 1)) sGroups = LTrim$(Mid$(sGroups, pos + 2)) ' The + 2 on the previous line gets past the line feed chr(10) pos = InStr(1, sGroups, Chr(13)) Wend

' Select first member in combo box: ComGroups.ListIndex = 1 GDone: tGroups.LinkMode = 0 Exit Sub GError: MsgBox "Error in getting groups" Resume GDone End Sub  Add another Command button (cItems) to Form1, and change the caption to Items.  Add the following code to the cItems_Click event: Sub cItems_Click Dim sItems As String On Error GoTo IError

' Clear the combo box: ComItems.Clear If (Len(ComGroups.Text)) Then tItems.LinkMode = 0 tItems.LinkTopic = "Progman|Progman" tItems.LinkMode = 2 tItems.LinkItem = ComGroups.Text tItems.LinkRequest

' Parse items that come back: sItems = tItems.Text pos = InStr(1, sItems, Chr(13)) While pos ComItems.AddItem RTrim$(Mid$(sItems, 1, pos - 1)) sItems = LTrim$(Mid$(sItems, pos + 2)) ' The + 2 on the previous line gets past the line feed chr(10) pos = InStr(1, sItems, Chr(13)) Wend End If

' Select first member in combo box: ComItems.ListIndex = 1 IDone: tItems.LinkMode = 0 Exit Sub IError: MsgBox "Error in getting items" Resume IDone End Sub </li> From the Run menu, choose Start (ALT, R, S) or press the F5 key to run the program. Press the Groups button and all the groups on Progman will be loaded into the ComGroups Combo box. Then press the Items button and all the items in the group selected in the ComGroups Combo box will be put into the ComItems Combo box.</li></ol>

<div class="references_section">