''Create a shortcut to the Start Menu
Option Explicit
Private Sub commandementclick ()
CreateProgManGroup Me, "test", "test. grp"
CreateProgManItem Me, "d:/ghost.exe", "Ghost"
CreateProgManItem Me, "d:/setupQQ.exe", "QQ"
End Sub
Sub CreateProgManGroup (X As Form, GroupName $, GroupPath $)
Dim I As Integer
X. Label1.LinkTopic = "ProgMan | Progman"
X. Label1.LinkMode = 2
The Rem null loop gives DDE time to execute
For I = 1 To 10
DoEvents
Next
X. Label1.LinkTimeout = 100
Rem LinkExecute transmits such a command in the DDE Channel
'── Create a program group named GroupName $.
X. Label1.LinkExecute "[CreateGroup (" + GroupName $ + Chr $ (44) + GroupPath $ + ")]"
X. Label1.LinkTimeout = 50' restore the attribute value of Label1
X. Label1.LinkMode = 0
End Sub
Sub CreateProgManItem (X As Form, using line $, IconTitle $)
Dim I As Integer
X. Label1.LinkTopic = "ProgMan | Progman"
X. Label1.LinkMode = 2
For I = 1 To 10
DoEvents
Next
X. Label1.LinkTimeout = 100
X. Label1.LinkExecute "[AddItem (" + CmdLine $ + Chr $ (44) + IconTitle $ + Chr $ (44) + ",)]"
X. Label1.LinkTimeout = 50' restore the attribute value of Label1
X. Label1.LinkMode = 0
Screen. MousePointer = 0
End Sub
'The shortcut to setting up a program as a Startup Folder
Text1.LinkTopic = "Progman | Progman"
Text1.LinkMode = 2' Manual
Text1.LinkExecute "[ShowGroup (START, 4)]"
Text1.LinkExecute "[AddItem (full path of the executable file, shortcut name)]"
'Suppose we want to set "c:/vb5db/myprog.exe" to a shortcut named "my programs" in the "Start" folder, then the LinkExecute of the last line should be as follows:
Text1.LinkExecute "[AddItem (c:/vb5db/myprog.exe, my program)]"
'Add shortcuts to programs on the desktop
'If the Program is C:/Program Files/MyProg/Prog.exe, add the parameter/Para.
'New key is a project, add a command button and a tag, add the following code, and you will get it!
'
Option Explicit
Private Sub commandementclick ()
CreateGroup "MyProg", "", "", 2, True
CreateGroup "MyProg", "C:/ProgramFiles/MyProg/Prog.exe/Para ",_
"Para", 3, True
End Sub
Sub CreateGroup (ByVal strGroup As String, ByVal strCmd As String, ByVal _
StrTitle As String, ByVal intDDE As Integer, ByVal fLog As Boolean)
Const strCOMMA $ = ","
Const strRESTORE $ = ", 1)]"
Const strACTIVATE $ = ", 5)]"
Const strENDCMD $ = ")]"
Const strSHOWGRP $ = "[ShowGroup ("
Const strADDGRP $ = "[CreateGroup ("
Const strREPLITEM $ = "[ReplaceItem ("
Const strADDITEM $ = "[AddItem ("
Dim I As Integer
Dim Sourcefile As String, Destinationfile As String
Form1.Label1. LinkMode = 0
For I % = 1 To 20
On Error Resume Next
Form1.Label1. LinkTopic = "PROGMAN | PROGMAN" 'sets the sender application and topic
If Err = 0 Then Exit
DoEvents
Next
Form1.Label1. LinkMode = 2' establish a connection manually
For I % = 1 To 10
DoEvents
Next
Form1.Label1. LinkTimeout = 100 'sets the time to wait for the DDE to respond to the message.
If Err = 0 Then
Select Case intDDE
Case 1 'create a program item
Form1.Label1. LinkExecute strADDGRP & strGroup & strENDCMD
Form1.Label1. LinkExecute strADDITEM & strCmd & strCOMMA &_
StrTitle & String $ (3, strCOMMA) & strENDCMD
Case 2 'create a Program Group
Form1.Label1. LinkExecute strADDGRP & strGroup & strENDCMD
Form1.Label1. LinkExecute strSHOWGRP & strGroup & strRESTORE
Case 3 'create a program item and copy it to the desktop.
Form1.Label1. LinkExecute strADDGRP & strGroup & strENDCMD
Form1.Label1. LinkExecute strADDITEM & strCmd & strCOMMA &_
StrTitle & String $ (3, strCOMMA) & strENDCMD
Sourcefile = "C:/WINDOWS/Start Menu/Programs/" & strGroup &_
"/" & StrTitle & ". lnk" 'specifies the source file name.
Destinationfile = "C:/WINDOWS/DESKTOP/" & strTitle & ". lnk"
'Specifies the destination file name.
FileCopy Sourcefile, Destinationfile
End Select
End If
'Disconnect the DDE connection
Form1.Label1. LinkMode = 0
Form1.Label1. LinkTopic = ""
End Sub