home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "modMain"
- ' Adds an entry to VB.INI that will add an addin to
- ' VB's Addins dialog box when VB is started.
- Option Explicit
-
- #If Win16 Then
- Declare Function WritePrivateProfileString _
- Lib "KERNEL" (ByVal AppName$, _
- ByVal KeyName$, ByVal keydefault$, _
- ByVal FileName$) As Integer
- Declare Function GetPrivateProfileString _
- Lib "KERNEL" (ByVal AppName$, _
- ByVal KeyName$, ByVal keydefault$, _
- ByVal ReturnString$, _
- ByVal NumBytes As Integer, _
- ByVal FileName$) As Integer
- #Else
- Declare Function WritePrivateProfileString _
- Lib "KERNEL32" Alias _
- "WritePrivateProfileStringA" _
- (ByVal AppName$, ByVal KeyName$, _
- ByVal keydefault$, ByVal FileName$) _
- As Integer
- Declare Function GetPrivateProfileString _
- Lib "KERNEL32" Alias _
- "GetPrivateProfileStringA" (ByVal AppName$, _
- ByVal KeyName$, ByVal keydefault$, _
- ByVal ReturnString$, ByVal NumBytes As Integer, _
- ByVal FileName$) As Integer
- #End If
-
- Dim strAddIn As String, strSetting As String
-
- Sub main()
- ' Install the add-in
- ' Name of addin = applicationname.classname
- strAddIn = "RegEditAddin.Application"
- ' 1 loads addin, 0 does not load
- strSetting = "1"
- ' Add entry to VB.INI.
- Dim sSection As String
- #If Win16 Then
- sSection = "Add-Ins16"
- #Else
- sSection = "Add-Ins32"
- #End If
- If WritePrivateProfileString(sSection, strAddIn, _
- strSetting, "vb.ini") Then
- ' Success.
- Else
- ' Notify user that add-in couldn't be registered.
- MsgBox "Addin could not be registered in VB.INI. " & _
- "Add these lines to VB.INI and restart Visual Basic: " & _
- Chr(13) & _
- "[" & sSection & "]" & _
- Chr(13) & _
- strAddIn, vbExclamation, "Install Addin"
- End If
- End Sub
-
-