home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Today (BR) Volume 4 #14
/
CDRTODAY.iso
/
SETUP.BAS
< prev
next >
Wrap
BASIC Source File
|
1997-06-27
|
6KB
|
155 lines
'-------------------------------------------------------------
' Procedure: CreateProgManGroup
' Arguments: X The Form where a Label1 exist
' GroupName$ A string that contains the group name
' GroupPath$ A string that contains the group file
' name ie 'myapp.grp'
'-------------------------------------------------------------
Sub CreateProgManGroup (x As Form, GroupName$, GroupPath$)
On Local Error Resume Next
'Screen. = 11
'----------------------------------------------------------------------
' Windows requires DDE in order to create a program group and item.
' Here, a Visual Basic label control is used to generate the DDE messages
'----------------------------------------------------------------------
'On Error Resume Next
'--------------------------------
' Set LinkTopic to PROGRAM MANAGER
'--------------------------------
x.Label1.LinkMode = 0
x.Label1.LinkTopic = "ProgMan|Progman"
x.Label1.LinkMode = 2
For i% = 1 To 100 ' Loop to ensure that there is enough time to
z% = DoEvents() ' process DDE Execute. This is redundant but needed
Next ' for debug windows.
x.Label1.LinkTimeout = 100
'---------------------
' Create program group
'---------------------
x.Label1.LinkExecute "[CreateGroup(" + GroupName$ + Chr$(44) + GroupPath$ + ")]"
'-----------------
' Reset properties
'-----------------
x.Label1.LinkTimeout = 50
x.Label1.LinkMode = 0
' If Err <> 0 Then
' MsgBox "Erro ao criar o grupo de programa." & Chr(10) & "Tente reiniciar o computador para" & Chr(10) & "corrigir este erro.", 16
' End If
'Screen.MousePointer = 1
End Sub
'----------------------------------------------------------
' Procedure: CreateProgManItem
'
' Arguments: X The form where Label1 exists
'
' CmdLine$ A string that contains the command
' line for the item/icon.
' ie 'c:\myapp\setup.exe'
'
' IconTitle$ A string that contains the item's
' caption
'----------------------------------------------------------
Sub CreateProgManItem (x As Form, CmdLine$, IconTitle$, Icone$, dirDefault$)
'Screen.MousePointer = 11
'----------------------------------------------------------------------
' Windows requires DDE in order to create a program group and item.
' Here, a Visual Basic label control is used to generate the DDE messages
'----------------------------------------------------------------------
On Local Error Resume Next
'---------------------------------
' Set LinkTopic to PROGRAM MANAGER
'---------------------------------
x.Label1.LinkTopic = "ProgMan|Progman"
x.Label1.LinkMode = 2
For i% = 1 To 100 ' Loop to ensure that there is enough time to
z% = DoEvents() ' process DDE Execute. This is redundant but needed
Next ' for debug windows.
x.Label1.LinkTimeout = 100
'------------------------------------------------
' Create Program Item, one of the icons to launch
' an application from Program Manager
'------------------------------------------------
'verificando a versπo do windows
TheVerInfo& = GetVersion()
WinVer& = TheVerInfo& And &HFFFF&
If Val(Format$(WinVer& Mod 256) + "." + Format$(WinVer& \ 256)) >= 3.1 Then
gfWin31% = True
End If
If gfWin31% Then
'Criando φcone
x.Label1.LinkExecute "[ReplaceItem(" + IconTitle$ + ")]"
End If
x.Label1.LinkExecute "[AddItem(" + CmdLine$ + "," + IconTitle$ + "," + Icone$ + ",0,,," + dirDefault$ + ")]"
'x.Label1.LinkExecute "[ShowGroup(" + GroupName$ + ", 6)]"
'x.Label1.LinkExecute "[ReplaceItem(" + IconTitle$ + ")]"
'-----------------
' Reset properties
'-----------------
x.Label1.LinkTimeout = 50
x.Label1.LinkMode = 0
' If Err <> 0 Then
' MsgBox "Erro ao criar o item de programa." & Chr(10) & "Tente reiniciar o computador para" & Chr(10) & "corrigir este erro.", 16
' End If
'Screen.MousePointer = 1
End Sub
Sub DeleteGroupItemName (x As Form, GroupName$, ItemName$)
'Screen.MousePointer = 11
On Local Error Resume Next
x.Label1.LinkTopic = "ProgMan|Progman"
x.Label1.LinkMode = 2
For i% = 1 To 100 ' Loop to ensure that there is enough time to
z% = DoEvents() ' process DDE Execute. This is redundant but needed
Next ' for debug windows.
x.Label1.LinkTimeout = 100
'verificando a versπo do windows
TheVerInfo& = GetVersion()
WinVer& = TheVerInfo& And &HFFFF&
If Val(Format$(WinVer& Mod 256) + "." + Format$(WinVer& \ 256)) >= 3.1 Then
gfWin31% = True
End If
x.Label1.LinkExecute "[ShowGroup(" + GroupName$ + ", 1)]"
x.Label1.LinkExecute "[DeleteItem(" + ItemName$ + ")]"
x.Label1.LinkExecute "[ShowGroup(" + GroupName$ + ", 6)]"
'x.Label1.LinkExecute "[ReplaceItem(" + IconTitle$ + ")]"
'-----------------
' Reset properties
'-----------------
x.Label1.LinkTimeout = 50
x.Label1.LinkMode = 0
RestoreProgman
' If Err <> 0 Then
' MsgBox "Erro ao criar o item de programa." & Chr(10) & "Tente reiniciar o computador para" & Chr(10) & "corrigir este erro.", 16
' End If
End Sub
Sub RestoreProgman ()
On Error GoTo RestoreProgManErr
AppActivate "Program Manager" ' Activate Program Manager.
SendKeys "%{ }{Enter}", True ' Send Restore keystrokes.
RestoreProgManErr:
Exit Sub
End Sub