MORE INFORMATION
To set up the CreatePROGMANIcon() function, create a new module and enter
the code below.
NOTE: In the following sample code, an underscore (_) is used as a line-
continuation character. Remove the underscore from the end of the line when
re-creating this code in Access Basic.
Option Explicit
'**************************************************
' FUNCTION: CreatePROGMANIcon
'
' PURPOSE:
' To create an icon in the Windows Program Manager.
'
' ARGUMENTS:
' CommandLine - The command line argument to execute
' when the icon is double-clicked.
' IconText - The text to appear under the icon.
' GroupName - The name of the group to place the
' icon in.
' RESULT:
' An icon is placed in the specified group. If the
' group does not exist, a new group is created.
'
' *************************************************
Function CreatePROGMANIcon (CommandLine$, IconText$, GroupName$)
Dim ChanNum As Integer
Dim Groups As String
Dim Exe As String
' Begin a DDE conversation with Program Manager.
ChanNum = DDEInitiate("PROGMAN", "PROGMAN")
' Request a tab delimited list of Program Manager groups.
Groups = DDERequest(ChanNum, "Progman")
' See if the requested group exists in the list.
' If not, create the group.
If Not InStr(1, Groups, GroupName) Then
DDEExecute ChanNum, "[CreateGroup(" & GroupName & ")]"
End If
' Add an icon to the group with the specified text underneath.
Exe = "[AddItem(" & CommandLine & ", " & IconText & ",,)]"
DDEExecute ChanNum, Exe
DDETerminate ChanNum
End Function
How to Use the CreatePROGMANIcon() Function
Type the command below in an Immediate window and then press ENTER.
NOTE: In the following example, an underscore (_) is used as a line-
continuation character. Remove the underscore when re-creating this
example.
? CreatePROGMANIcon("C:\WINDOWS\NOTEPAD.EXE C:\AUTOEXEC.BAT", _
"AUTOEXEC", "MAIN")
The sample command above uses the CreatePROGMANIcon() function to add an
icon to the Main group in Program Manager. The icon will open the Windows
Notepad text editor and load the C:\AUTOEXEC.BAT file into Notepad.
Note that when the icon is created, Program Manager uses the default icon
supplied with the application specified in the command line. The following
function is a modified version of the CreatePROGMANIcon() function with two
additional arguments. These arguments are IconFile, which specifies the
name of a file containing custom icons, and IconNum, which specifies which
icon in the IconFile to use. Note that if you specify "", or null, for both
of these arguments, the default icon will be used.
Function CreatePROGMANIcon2 (CommandLine$, IconText$, GroupName$, _
IconFile$, IconNum$)
Dim ChanNum As Integer
Dim Groups As String
Dim Exe As String
' Begin a DDE conversation with Program Manager.
ChanNum = DDEInitiate("PROGMAN", "PROGMAN")
' Request a tab delimited list of Program Manager groups.
Groups = DDERequest(ChanNum, "Progman")
' See if the requested group exists in the list.
' If not, create the group.
If Not InStr(1, Groups, GroupName) Then
DDEExecute ChanNum, "[CreateGroup(" & GroupName & ")]"
End If
' Add an icon to the group with the specified text underneath.
Exe$ = "[AddItem(" & CommandLine & ", " & IconText & ", _
" & IconFile & ", " & IconNum & ")]"
DDEExecute ChanNum, Exe
DDETerminate ChanNum
End Function
The following sample command uses the fourth icon in the MORICONS.DLL file
that is supplied with Windows. This file contains multiple custom icons:
CreatePROGMANIcon2("C:\TEST\TEST.EXE ","My App","My Group",_
"C:\WINDOWS\MOREICONS.DLL","4")
The next sample command uses an icon in an .ICO file. Since there is only
one icon in each .ICO file, leave the IconNum argument empty:
CreatePROGMANIcon2("C:\TEST\TEST.EXE ","My App","My Group",_
"C:\ICONS\MY.ICO","")