$IFNDEF TRUE
$DEFINE True 1
$ENDIF
$IFNDEF FALSE
$DEFINE False 0
$ENDIF
$IFNDEF boolean
$DEFINE boolean INTEGER
$ENDIF
$IFNDEF __WIN32API
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
$ENDIF
TYPE QINI EXTENDS QOBJECT
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
PROPERTY SET SetWinDir(name AS STRING)
END PROPERTY
PROPERTY SET SetSystemDir(name AS STRING)
END PROPERTY
PROPERTY SET SetTempDir(name AS STRING)
END PROPERTY
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
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
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
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
|