Guidance
指路人
g.yi.org
software / rapidq / Examples / QObject / Object / QIni.inc

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'=======================================================
' Type Objet
' Classe QINI
'=======================================================
     $IFNDEF TRUE
      $DEFINE True 1
     $ENDIF

     $IFNDEF FALSE
      $DEFINE False 0
     $ENDIF

     $IFNDEF boolean
      $DEFINE boolean INTEGER
     $ENDIF

     DECLARE FUNCTION GetPrivateProfileString LIB "Kernel32" ALIAS "GetPrivateProfileStringA" _
      (lpApplicationName AS STRING,lpKeyName AS STRING, _
      lpDefault AS STRING,lpReturnedString AS LONG,nSize AS LONG,lpFileName AS STRING) AS LONG

     DECLARE FUNCTION WritePrivateProfileString LIB "Kernel32" ALIAS "WritePrivateProfileStringA" _
      (lpApplicationName AS STRING,lpKeyName AS STRING,lpString AS STRING,lpFileName AS STRING) AS LONG

     DECLARE FUNCTION GetWindowsDirectory LIB "kernel32.dll" ALIAS "GetWindowsDirectoryA" (lpBuffer AS LONG,nSize AS LONG) AS LONG
     DECLARE FUNCTION GetSystemDirectory LIB "kernel32" ALIAS "GetSystemDirectoryA" (lpBuffer AS LONG,nSize AS LONG) AS LONG
     DECLARE FUNCTION GetTempPath LIB "kernel32" ALIAS "GetTempPathA" (nBufferLength AS LONG,lpBuffer AS LONG) AS LONG


     TYPE QINI EXTENDS QOBJECT
  '===========================================
  ' champs et proprietés
  '===========================================
      FileName AS STRING PROPERTY SET SetFileName
      Exist AS boolean
      Section AS STRING
      WinDir AS STRING PROPERTY SET SetWinDir
      SystemDir AS STRING PROPERTY SET SetSystemDir
      TempDir AS STRING PROPERTY SET SetTempDir

  '=========================================
  ' Proprieté WinDir en lecture seule
  '=========================================
      PROPERTY SET SetWinDir(name AS STRING)
      END PROPERTY

  '=========================================
  ' Proprieté SystemDir en lecture seule
  '=========================================
      PROPERTY SET SetSystemDir(name AS STRING)
      END PROPERTY

  '=========================================
  ' Proprieté TempDir en lecture seule
  '=========================================
      PROPERTY SET SetTempDir(name AS STRING)
      END PROPERTY

  '=========================================
  ' Proprieté nom du fichier init
  '=========================================
      PROPERTY SET SetFileName(name AS STRING)
       QINI.FileName=name
       IF FILEEXISTS(QINI.FileName) THEN
        QINI.Exist=true
       ELSE
        QINI.Exist=false
       END IF
      END PROPERTY

  '=========================================
  ' Méthode recevoir valeur du fichier init
  '=========================================
      FUNCTION GET(Key AS STRING,Default AS STRING) AS STRING
       DIM LpBuffer AS STRING
       DIM size AS SHORT

       lpBuffer=SPACE$(260)
       IF QINI.FileName<>"" AND QINI.Section<>"" THEN
        size=GetPrivateProfileString(QINI.Section,Key,Default,VARPTR(lpBuffer),260,QINI.FileName)
        IF size>0 THEN
         QINI.GET=LEFT$(lpBuffer,size)
        ELSE
         QINI.GET=Default
        END IF
       END IF
      END FUNCTION

  '=========================================
  ' Méthode écrire valeur dans fichier init
  '=========================================
      FUNCTION Write(Key AS STRING,Value AS STRING) AS LONG
       IF QINI.FileName<>"" AND QINI.Section<>"" THEN
        QINI.Write=WritePrivateProfileString(QINI.Section,Key,Value,QINI.FileName)
       END IF
      END FUNCTION

  '====================================================
  ' Méthode trouve les repertoires window+systeme+temp
  '====================================================
      SUB GetIniPath()
       DIM lpBuffer AS STRING
       DIM size AS SHORT

       lpBuffer=SPACE$(260)
       size=GetWindowsDirectory(VARPTR(lpBuffer),260)
       QINI.WinDir=LEFT$(lpBuffer,size)
       lpBuffer=SPACE$(260)
       size=GetSystemDirectory(VARPTR(lpBuffer),260)
       QINI.SystemDir=LEFT$(lpBuffer,size)
       lpBuffer=SPACE$(260)
       size=GetTempPath(260,VARPTR(lpBuffer))
       QINI.TempDir=LEFT$(lpBuffer,size)
      END SUB

      CONSTRUCTOR
       FileName = ""
       Section = ""
       Exist=false
       GetIniPath
      END CONSTRUCTOR
     END TYPE

掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Tue 2024-12-10  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2001-12-19 12:31:54