home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 5205
- ClientLeft = 3735
- ClientTop = 5790
- ClientWidth = 6690
- Height = 5640
- Left = 3675
- LinkTopic = "Form1"
- ScaleHeight = 5205
- ScaleWidth = 6690
- Top = 5415
- Width = 6810
- Begin VB.CommandButton Command2
- Caption = "Command2"
- Height = 495
- Left = 2760
- TabIndex = 1
- Top = 2400
- Width = 1215
- End
- Begin VB.CommandButton Command1
- Caption = "Command1"
- Height = 495
- Left = 2760
- TabIndex = 0
- Top = 2400
- Width = 1215
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- ' Declarations for the API functions used to manipulate
- ' initilization files.
- Private Declare Function WritePrivateProfileString _
- Lib "Kernel32" Alias "WritePrivateProfileStringA" _
- (ByVal AppName$, ByVal KeyName As Any, _
- ByVal KeyDefault As Any, ByVal FileName$) As Long
- Private Declare Function GetPrivateProfileString Lib _
- "Kernel32" Alias "GetPrivateProfileStringA" (ByVal AppName$, _
- ByVal KeyName$, ByVal KeyDefault$, ByVal ReturnString$, _
- ByVal NumBytes As Long, ByVal FileName$) As Long
- ' This method adds a profile string to the VB.INI file. The
- ' instance of VB that is started will see it.
- Private Sub Command1_Click()
- prof$ = String$(255, Chr$(0))
- ' If profile string is not present, return "NotFound" as the
- ' result.
- GetPrivateProfileString "Add-Ins32", "AddIn2.Connector", _
- "NotFound", prof$, Len(prof$) + 1, "VB.INI"
- ' get rid of trailing blanks.
- prof$ = Left(prof$, InStr(prof$, Chr(0)) - 1)
- If prof$ = "NotFound" Then
- WritePrivateProfileString "Add-Ins32", _
- "AddIn2.Connector", "0", "VB.INI"
- End If
- ' Change the directory in the next line to reflect the
- ' the directory in which Visual Basic is installed, if the shell
- ' fails
- Shell "vb32.exe", vbNormalFocus
- End Sub
- Private Sub Command2_Click()
- Unload Form1
- End Sub
- ' Perform some control initialization.
- Private Sub Form_Load()
- With Screen
- Left = (.Width - Width) / 2
- Top = (.Height - Height) / 2
- End With
-
- With Command1
- .Caption = "Start Add-In"
- .Left = 40
- .Top = 15
- End With
- With Command2
- .Left = Command1.Left
- .Top = Command1.Top + Command1.Height + 15
- .Caption = "End Add-In"
- End With
- With Form1
- .Height = (Command1.Height * 3)
- .Width = Command1.Width
- End With
- End Sub
- ' Remove the profile string so that new instances
- ' of VB will not look for it.
- Private Sub Form_Unload(Cancel As Integer)
- WritePrivateProfileString "Add-Ins32", _
- "AddIn2.Connector", "", "VB.INI"
- End
- End Sub
-