Solved

windows 3.11 program group creation

Posted on 1997-06-12
1
304 Views
Last Modified: 2006-11-17
I am writing an install app using vc++ 1.52c.
How do I create a program group for the application being installed  after all the files are copied to the hard disk?
0
Comment
Question by:mikeu
1 Comment
 
LVL 4

Accepted Solution

by:
md041797 earned 100 total points
ID: 1163896
You have to start a DDE conversation with progman.exe.

Command-String Interface

Program Manager has a DDE command-string interface that allows other applications to create, display, delete and reload groups; add items to groups; replace items in groups; delete items from groups; and to close Program Manager. The following commands perform these actions:

AddItem      ExitProgman
CreateGroup      Reload (Windows 3.1 only)
DeleteGroup      ReplaceItem (Windows 3.1 only)
DeleteItem (Windows version 3.1 only)      ShowGroup

The setup program for an application can use these commands, for example, to instruct Program Manager to install the application's icon in a group.
Multiple commands may be concatenated; each command must be contained in square brackets, and parameters must be contained in parentheses and separated by commas. Quotation marks must be used to delimit arguments that contain spaces, brackets, or parentheses. For example, the following set of commands adds WINAPP.EXE to the Windows Applications group:

[CreateGroup("Windows Applications")]
[ShowGroup("MYGROUP.GRP",1)]
[AddItem(winapp.exe,Win App,winapp.exe,2)]

To use these commands, an application must first initiate a conversation with Program Manager. The application and topic names for the conversation are both PROGMAN. Then the application sends the WM_DDE_EXECUTE message, specifying the appropriate command and its parameters.

Note:      The user can configure Windows to use a shell other than Program Manager as the default. As a result, you should not design an application assuming that Program Manager will be available for a DDE conversation.

The following sections describe Program Manager DDE command strings in detail. In the syntax blocks in the following sections, brackets enclose optional arguments.

CreateGroup

The syntax for the CreateGroup command has this form:
CreateGroup(GroupName[,GroupPath])
The CreateGroup command instructs Program Manager to create a new group or activate the window of an existing group.
Following are the parameters for this command:

GroupName      Identifies the group to be created. This parameter is a string. If a group already exists with the name specified by GroupName, CreateGroup activates the group window.
GroupPath      Specifies the path of the group file. If your application does not supply this parameter, Windows uses a default filename for the group in the Windows directory.

ShowGroup

The syntax for the ShowGroup command has this form:
ShowGroup(GroupName,ShowCommand)
The ShowGroup command instructs Program Manager to minimize, maximize, or restore the window of an existing group.
Following are the parameters for this command:

GroupName      Identifies the group window to be minimized, maximized, or restored.
ShowCommand      Specifies the action that Program Manager is to perform on the group window. This parameter is an integer. It must have one of the following values:

Value      Meaning

1      Activates and displays the group window. If the window is minimized or maximized, Windows restores it to its original size and position.
2      Activates the group window and displays it as an icon.
3      Activates the group window and displays it as a maximized window.
4      Displays the group window in its most recent size and position. The window that is currently active remains active.
5      Activates the group window and displays it in its current size and position.
6      Minimizes the group window.
7      Displays the group window as an icon. The window that is currently active remains active.
8      Displays the group window in its current state. The window that is currently active remains active.

DeleteGroup

The syntax for the DeleteGroup command has this form:
DeleteGroup(GroupName)
The DeleteGroup command instructs Program Manager to delete an existing group.
Following is the parameter for this command:

GroupName      Identifies the group to be deleted.

Reload

The syntax for the Reload command has this form:
Reload(GroupName)
The ReloadGroup command instructs Program Manager to remove and reload an existing group. An application that modifies group files can use this command to cause Program Manager to update the groups when it has finished making modifications.
Following is the parameter for this command:

GroupName      Identifies the group to be removed and reloaded. If the GroupName parameter is not specified, Program Manager unloads all groups and reloads the [Group] section of PROGMAN.INI. The [Settings] and [Restrictions] sections are not reread.

AddItem

The syntax for the AddItem command has this form:

AddItem(CmdLine[,
    Name[,IconPath[,IconIndex[,xPos, yPos[,DefDir[,
    HotKey,[,fMinimize] ] ] ] ] ] ])

The AddItem command instructs Program Manager to add an icon to an existing group.
Following are the parameters for this command:

CmdLine      Specifies the full command line required to execute the application. This parameter is a string. At a minimum, this string is the name of the executable file for the application. It can also include the full path of the application and any parameters required by the application.
Name      Specifies the title that is displayed below the icon in the group window.
IconPath      Identifies the filename for the icon to be displayed in the group window. This parameter is a string. This file can be either a Windows executable file or an icon file. If the IconPath parameter is not specified, Program Manager uses the first icon in the file specified by the CmdLine parameter if that file is an executable file. If CmdLine specifies an associated file, Program Manager uses the first icon of the associated executable file. The association is taken from the registration database. (For more information about the registration database, see The Windows Shell Overview.) If CmdLine specifies neither an executable file nor an associated executable file, Program Manager uses a default icon.

IconIndex      Specifies the index of the icon in the file identified by the IconPath parameter. The IconIndex parameter is an integer. PROGMAN.EXE contains five built-in icons that can be used for non-Windows programs.
xPos      Specifies the horizontal position of the icon in the group window. This parameter is an integer. You must use both the xPos and yPos parameters to specify the position of the icon. If you do not specify the position, Program Manager places the icon in the next available space.
yPos      Specifies the vertical position of the icon in the group window. This parameter is an integer. You must use both the xPos and yPos parameters to specify the position of the icon. If you do not specify the position, Program Manager places the icon in the next available space.

DefDir      Specifies the name of the default (or working) directory. This parameter is a string.
HotKey      Identifies a hot (or shortcut) key that is specified by the user.
fMinimize      Specifies whether an application window should be minimized when it is first displayed.

ReplaceItem

The syntax for the ReplaceItem command has this form:
ReplaceItem(ItemName)
The ReplaceItem command instructs Program Manager to delete an item and record the position of the deleted item. Program Manager will add a new item (specified by the next AddItem command) at this recorded position.
Following is the parameter for this command:

ItemName      Specifies the item to be deleted. Its position is recorded by Program Manager.

DeleteItem

The syntax for the DeleteItem command has this form:
DeleteItem(ItemName)
The DeleteItem command instructs Program Manager to delete an item from the currently active group.
Following is the parameter for this command:

ItemName      Specifies the item to be deleted from the currently active group.

ExitProgman

The syntax for the ExitProgman command has this form:
ExitProgman(bSaveGroups)
If Program Manager was started by another application, the ExitProgman command instructs Program Manager to exit and, optionally, save its group information.
Following is the parameter for this command:

bSaveGroups      Specifies a Boolean value that, if nonzero, causes Program Manager to save its group information before closing. If bSaveGroups is zero, Program Manager does not save its group information.

Requesting Group Information

Program Manager can provide information about its groups to an application. Applications can request this information from Program Manager by using the PROGMAN topic.
An application can obtain a list of Program Manager groups by issuing a request for the Group item. Program Manager provides the list in CF_TEXT format. The list consists of group-name strings separated by carriage returns.
An application can use a group name as an item name to request information about the group. Program Manager provides this information in CF_TEXT format. The fields of group information are separated by commas. The first line of the information contains the group name (in quotation marks), the path of the group file, and the number of items in the group. Each subsequent line contains information about an item in the group, including the command line (in quotation marks), the default directory, the icon path, the position in the group, the icon index, the shortcut key (in numeric form), and the minimize flag.

Dynamic Data Exchange Interface for Replacement Shells

You may choose to write an application that replaces the Windows shell. This replacement shell must be able to provide property information to the application that starts non-Windows programs in an MS-DOS window. (This application is known as WinOldApp.) This section discusses how a replacement shell can provide property information for WinOldApp. Applications other than WinOldApp do not need this information. The DDE protocol described in this section may not be supported in future versions of Windows.

Properties

A replacement shell should maintain several pieces of information, called properties, for each application that WinOldApp might start. These are the same properties that appear in the Program Item Properties dialog box of Program Manager. These properties include:

Description (title)

Command line

Working directory

Shortcut key

Icon

The shell must provide a DDE interface that allows WinOldApp to obtain three of these properties: description, working directory, and icon.
To obtain its properties from the shell, WinOldApp must accomplish the following tasks:

1      Establish a DDE conversation with the shell.

2      Request a property from the shell.

3      Receive a property from the shell.

4      Terminate the DDE conversation.

Establishing a DDE Conversation

WinOldApp requests property data from the shell by using the SendMessage function to broadcast the WM_DDE_INITIATE message. The wParam parameter of the SendMessage function is the handle of WinOldApp's DDE window. The low-order word of the lParam parameter is an atom that represents the name of the shell application: "Shell". The high-order word is an atom that represents the name of the properties topic: "AppProperties".
A "Shell" DDE server that supports the "AppProperties" topic responds to the WM_DDE_INITIATE message by sending a WM_DDE_ACK message. The server should send the following parameters with the WM_DDE_ACK message:

Parameter      Description

hwnd      Specifies the handle of WinOldApp's DDE window. The shell should use the handle that WinOldApp specified as the wParam parameter in the WM_DDE_INITIATE message.
message      Specifies the WM_DDE_ACK message.
wParam      Specifies the handle of the "Shell" server's DDE window.
HIWORD(lParam)      Specifies an atom that represents the name of the shell application: "Shell".
LOWORD(lParam)      Specifies an atom that represents the name of the properties topic: "AppProperties".

It is not necessary to free the atoms used in a conversation with WinOldApp. It is WinOldApp's responsibility to create and free the atoms.

Providing Property Data

After the DDE server that provides a replacement shell responds with a WM_DDE_ACK message to the WM_DDE_INITIATE from WinOldApp, WinOldApp sends a WM_DDE_REQUEST message to request property data. The server can respond to the WM_DDE_REQUEST message by posting a WM_DDE_DATA message.
The Windows shell associates an item name with each of the application properties that it provides. The item names are described in the following table:

Item name      Description

"GetDescription"      The shell provides an application's description (title) property.
"GetWorkingDIR"      The shell provides an application's working-directory property.
"GetIcon"      The shell provides an application's icon property.

WinOldApp requests properties by obtaining an atom for each of the item-name strings and passing the atoms to the shell in a sequence of WM_DDE_REQUEST messages (one message for each property). WinOldApp also passes the handle of the application's instance as the low-order word of the lParam parameter in the WM_DDE_REQUEST message. The shell should use this instance handle to find the properties associated with the application.
If a "Shell" DDE server does not recognize the application's instance handle, the server does not support properties for the application instance. In this case, the server should respond by sending a negative WM_DDE_ACK message. The parameters passed with the negative WM_DDE_ACK message are as follows:

Parameter      Description

hwnd      Specifies the handle of WinOldApp's DDE window. The shell should use the handle that WinOldApp specified as the wParam parameter in the WM_DDE_REQUEST message.
message      Specifies the WM_DDE_ACK message.
wParam      Specifies the handle of the "Shell" server's DDE window.
LOWORD(lParam)      Specifies zero. The "Shell" DDE server does not support properties for the specified application instance.
HIWORD(lParam)      Specifies an atom that represents the item name of the requested property. Depending on the type of property requested, the atom should identify one of the following strings: "GetDescription", "GetWorkingDIR", or "GetIcon".

When WinOldApp receives a negative WM_DDE_ACK message, it terminates the conversation with the "Shell" DDE server.
If a "Shell" DDE server recognizes the application's instance handle and the requested property is available, it should allocate a global memory object and copy the property data to the object. Then it should post a WM_DDE_DATA message to WinOldApp. The WM_DDE_DATA message should contain the handle of the global memory object.
The contents of the global memory object allocated by the shell depend on the type of property WinOldApp requested. The following three sections describe the description, working-directory, and icon properties.

Providing the Description Property

If the shell is responding to a request for the "GetDescription" property, the shell should pass the following parameters with the WM_DDE_DATA message:

Parameter      Description

hwnd      Specifies the handle of WinOldApp's DDE window. The shell should use the handle that WinOldApp specified as the wParam parameter in the WM_DDE_REQUEST message.
message      Specifies the WM_DDE_DATA message.
wParam      Specifies the handle of the shell's DDE window.
LOWORD(lParam)      Specifies a handle to a global memory object that contains a DDEDATA structure. A description of the contents of the DDEDATA structure follows this table. To report an error, the server should use one of the error values listed with the WinExec function.
HIWORD(lParam)      Specifies an atom that represents the string, "GetDescription".

The low-order word of the lParam parameter should be a handle to a global memory object that contains a DDEDATA structure (defined in the DDE.H header file). The contents of the DDEDATA structure are as follows:

#include <dde.h>

typedef struct tagDDEDATA {   /* ddedat */
    WORD    unused:12,
            fResponse:1,
            fRelease:1,
            reserved:1,
            fAckReq:1;
    short   cfFormat;
    BYTE    Value[1];
} DDEDATA;

The Value member should contain the description property, in the form of a null-terminated string of characters from the Windows character set. The string can be any size but typically contains fewer than 30 characters.
If the server sets the fAckReq bit, WinOldApp responds to the WM_DDE_DATA message by posting a WM_DDE_ACK message after processing the data.
If the server sets the fRelease bit, WinOldApp frees the global memory object after copying the description string. Otherwise, WinOldApp does not free the memory object.

Providing the Working-Directory Property

If the shell is responding to WinOldApp's request for the "GetWorkingDIR" property, the shell passes the following parameters with the WM_DDE_DATA message:

Parameter      Description

hwnd      Specifies the handle of WinOldApp's DDE window. The shell should use the handle that WinOldApp specified as the wParam parameter in the WM_DDE_REQUEST message.
message      Specifies the WM_DDE_DATA message.
wParam      Specifies the handle of the shell's DDE window.
LOWORD(lParam)      Specifies a handle to a global memory object that contains a DDEDATA structure. A description of the contents of the DDEDATA structure follows this table. To report an error, the server should use one of the error values listed with the WinExec function.
HIWORD(lParam)      Specifies an atom that represents the string, "GetWorkingDIR".

The low-order word of the lParam parameter is a handle to a global memory object that contains a DDEDATA structure. The contents of the DDEDATA structure are as follows:

#include <dde.h>

typedef struct tagDDEDATA {   /* ddedat */
    WORD    unused:12,
            fResponse:1,
            fRelease:1,
            reserved:1,
            fAckReq:1;
    short   cfFormat;
    BYTE    Value[1];
} DDEDATA;

The Value member should specify the location (drive and path) of the application's executable file, in the form of a null-terminated string of characters from the Windows character set. The character string has a maximum size of 128 characters (including the terminating null character).
If the server sets the fAckReq bit, WinOldApp responds to the WM_DDE_DATA message by posting a WM_DDE_ACK message after processing the working-directory property.
If the server sets the fRelease bit, WinOldApp frees the global memory object after copying the working-directory string. Otherwise, WinOldApp does not free the memory object.

Providing the Icon Property

If the shell is responding to WinOldApp's request for "GetIcon" property, the shell passes the following parameters with the WM_DDE_DATA message:

Parameter      Description

hwnd      Specifies the handle of WinOldApp's DDE window. The shell should use the handle that WinOldApp specified as the wParam parameter in the WM_DDE_REQUEST message.
message      Specifies the WM_DDE_DATA message.
wParam      Specifies the handle of the shell's DDE window.
LOWORD(lParam)      Specifies a handle to a global memory object that contains a DDEDATA structure. A description of the contents of the DDEDATA structure follows this table. To report an error, the server should use one of the error values listed with the WinExec function.
HIWORD(lParam)      Specifies an atom that represents the string, "GetIcon".

The low-order word of the lParam parameter is a handle to a global memory object that contains icon-property data. The icon data should be in the following form:

typedef struct tagICONPROPS { /* ip */

    unsigned reserved:12,   /* reserved                         */
             fResponse:1,   /* always 1                         */
             fRelease:1,    /* 1 if app. frees object, else 0   */
             reserved:1,    /* reserved                         */
             fAckReq:1;     /* 1 if app. should respond, else 0 */
    int      cfFormat;      /* clipboard format (not used)      */
    int      nWidth;        /* width, in pixels, of the icon    */
    int      nHeight;       /* height, in pixels, of the icon   */
    BYTE     nPlanes;       /* number of planes in XOR mask     */

    BYTE     nBitsPixel;    /* number of bits/pixel in XOR mask */
    LPBYTE   lpANDbits;     /* points to AND mask array         */
    LPBYTE   lpXORbits;     /* points to XOR mask array         */
} ICONPROPS;

If the server sets the fAckReq bit, WinOldApp responds to the WM_DDE_DATA message with a WM_DDE_ACK message after processing the data.
If the server sets the fRelease bit, WinOldApp frees the global memory object after copying the working-directory string. Otherwise, WinOldApp does not free the memory object.
The lpANDbits and lpXORbits pointers may be either near or far. If the pointers are near (that is, the segment selector portion of the pointers is zero), the bits are part of the global memory object. The offset portion of the pointers is a near offset from byte zero of the object.
Because the bits are part of the global memory object, they are freed along with the object. The combined size of the ICONPROPS structure together with the bits pointed to by the lpANDbits and lpXORbits members must be no more than 64K.

If the server needs to use far pointers for the lpANDbits and lpXORbits members, the bits must be part of a separate memory object. This object is not freed automatically when the global memory object is freed.

Terminating the DDE Conversation

The shell may terminate the conversation at any time by posting a WM_DDE_TERMINATE message. After WinOldApp has obtained its properties from the shell, it terminates the DDE conversation by posting a WM_DDE_TERMINATE message.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question