Article ID: 109394
Article Last Modified on 5/6/2003
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
? CreatePROGMANIcon("C:\WINDOWS\NOTEPAD.EXE C:\AUTOEXEC.BAT", _
"AUTOEXEC", "MAIN")
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
CreatePROGMANIcon2("C:\TEST\TEST.EXE ","My App","My Group",_
"C:\WINDOWS\MOREICONS.DLL","4")
CreatePROGMANIcon2("C:\TEST\TEST.EXE ","My App","My Group",_
"C:\ICONS\MY.ICO","")
Keywords: kbhowto kbinterop KB109394