home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / source / chap16 / dlgrun4 / mainmodu.bas < prev    next >
Encoding:
BASIC Source File  |  1995-07-13  |  1.5 KB  |  30 lines

  1. Attribute VB_Name = "MainModule"
  2. Option Explicit
  3.  
  4. #If Win16 Then
  5.     Declare Function OSWritePrivateProfileString% Lib "KERNEL" Alias "WritePrivateProfileString" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal FileName$)
  6.     Declare Function OSGetPrivateProfileString% Lib "KERNEL" Alias "GetPrivateProfileString" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal ReturnString$, ByVal NumBytes As Integer, ByVal FileName$)
  7. #Else
  8.     Declare Function OSWritePrivateProfileString% Lib "Kernel32" Alias "WritePrivateProfileStringA" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal FileName$)
  9.     Declare Function OSGetPrivateProfileString% Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal ReturnString$, ByVal NumBytes As Integer, ByVal FileName$)
  10. #End If
  11.  
  12. Sub Main()
  13. Dim ReturnString As String
  14. Dim Section As String
  15. Dim ErrCode As Long
  16.  
  17. '--- Check to see if we are in the VB.INI File.  If not, Add ourselves to the INI file
  18.     #If Win16 Then
  19.         Section = "Add-Ins16"
  20.     #Else
  21.         Section = "Add-Ins32"
  22.     #End If
  23.     ReturnString = String$(255, Chr$(0))
  24.     ErrCode = OSGetPrivateProfileString(Section, "Sample.SimpleAlign", "NotFound", ReturnString, Len(ReturnString) + 1, "VB.INI")
  25.     If Left(ReturnString, InStr(ReturnString, Chr(0)) - 1) = "NotFound" Then
  26.         ErrCode = OSWritePrivateProfileString%(Section, "RunIn.RunAddIn", "0", "VB.INI")
  27.     End If
  28. End Sub
  29.  
  30.