home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / tool / prg_sup / pwrtbl / autoini.bas next >
BASIC Source File  |  1994-08-21  |  4KB  |  124 lines

  1. '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-'
  2. '                                                          '
  3. '                         AUTOINI                          '
  4. '               ( a part of PowerTABLE 1.1 )               '
  5. '                                                          '
  6. '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-'
  7. '                                                          '
  8. '           copyright (C) 1994 bytes & letters             '
  9. '                 written by dirk hilger                   '
  10. '                    66716 saarlouis                       '
  11. '                        germany                           '
  12. '                                                          '
  13. '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-'
  14.  
  15.  
  16. Option Explicit
  17. Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lplFileName As String) As Integer
  18. Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
  19. Declare Function GetWindowsDirectory Lib "Kernel" (ByVal p$, ByVal s%) As Integer
  20. Declare Function GetSystemDirectory Lib "kernel" (ByVal p$, ByVal s%) As Integer
  21.  
  22.  
  23. Dim privateIniFile$, intLine$
  24. Dim retval As String * 255
  25.  
  26. Function getSystemDir$ ()
  27.     Dim winpath As String * 145, l%
  28.     l% = GetSystemDirectory(winpath, 145)
  29.     If l Then
  30.        If Mid$(winpath, l, 1) <> "\" Then
  31.           Mid$(winpath, l + 1) = "\"
  32.           l = l + 1
  33.        End If
  34.        getSystemDir$ = UCase$(Left$(winpath, l%))
  35.     End If
  36. End Function
  37.  
  38. Function getWindowsDir$ ()
  39.     Dim winpath As String * 145, l%
  40.     l% = GetWindowsDirectory(winpath, 145)
  41.     If l Then
  42.        If Mid$(winpath, l, 1) <> "\" Then
  43.           Mid$(winpath, l + 1) = "\"
  44.           l = l + 1
  45.        End If
  46.        getWindowsDir$ = UCase$(Left$(winpath, l%))
  47.     End If
  48. End Function
  49.  
  50.  
  51. Sub ini_do (section$, key$, v, ByVal flag%)
  52.     Static sec$
  53.     Dim r%
  54.     If Len(privateIniFile$) = 0 Then
  55.        privateIniFile$ = app.Path & "\" & app.EXEName & ".INI"
  56.     End If
  57.  
  58.     If Len(section) Then sec = section
  59.     If flag% Then
  60.        r% = WritePrivateProfileString(sec, key$, v, privateIniFile$)
  61.     Else
  62.        r% = GetPrivateProfileString(sec, key, "", retval, 255, privateIniFile$)
  63.        If r% = 0 Then
  64.           v = ""
  65.        Else
  66.           v = Left(retval, r%)
  67.        End If
  68.     End If
  69. End Sub
  70.  
  71.  
  72. Sub ini_initDataAccess ()
  73.     Dim sysdir$, windir$, result$, old$
  74.     
  75.     sysdir = getSystemdir() 
  76.     windir = getWindowsDir()
  77.     
  78.     ini_do "Installable ISAMs", "dbase IV", result, False
  79.     
  80.   ' Write Data-Acess Informations to the INI-File
  81.   ' ---------------------------------------------
  82.     
  83.     If result <> sysdir & "xbs110.dll" Then
  84.        
  85.      ' Installable ISAMs
  86.        ini_do "", "Btrieve", sysdir & "btrv110.dll", True
  87.        ini_do "", "Foxpro 2.0", sysdir & "xbs110.dll", True
  88.        ini_do "", "Foxpro 2.5", sysdir & "xbs110.dll", True
  89.        ini_do "", "dbase III", sysdir & "xbs110.dll", True
  90.        ini_do "", "dbase IV", sysdir & "xbs110.dll", True
  91.        ini_do "", "Paradox 3.X", sysdir & "pdx110.dll", True
  92.        
  93.      ' Installable ISAMs - options
  94.        ini_do "ISAM", "PageTimeOut", 5, True
  95.        ini_do "", "MaxBufferSize", 128, True
  96.        ini_do "", "LockRetry", 20, True
  97.        ini_do "", "CommitLockRetry", 20, True
  98.        ini_do "", "ReadAheadPages", 16, True
  99.      
  100.      ' dBase ISAM
  101.        ini_do "dBASE ISAM", "Deleted", "ON", True
  102.        ini_do "", "PageTimeOut", 600, True
  103.        ini_do "", "CollatingSequence", "International", True
  104.        
  105.      ' Paradox ISAM
  106.        ini_do "Paradox ISAM", "CollatingSequence", "International", True
  107.        ini_do "", "PageTimeOut", 600, True
  108.        
  109.      ' Btrieve ISAM
  110.        ini_do "Btrieve ISAM", "PageTimeOut", 600, True
  111.        
  112.        old = privateIniFile
  113.        privateIniFile = windir & "WIN.INI"
  114.        ini_do "BTRIEVE", "Options", "/m:64 /p:4096 /b:16 /f:20 /l:40 /n:12 /t:" & windir & "BTRIEVE.TRN", True
  115.  
  116.        privateIniFile = old
  117.  
  118.     End If
  119.  
  120.     SetDataAccessOption 1, privateIniFile
  121.  
  122. End Sub
  123.  
  124.