home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Pier Shareware 6
/
The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso
/
035
/
cenvi29.zip
/
PROFILE.LIB
< prev
next >
Wrap
Text File
|
1994-05-19
|
8KB
|
209 lines
// Profile.lib - Interface to PM's Profile functions: the routines that
// ver.2 deal with /INI files.
//
//
//***** PrfGetApplicationNames(): Get list of app names in an INI file
// SYNTAX: bool PrfGetApplicationNames(int hini,string[] NameList)
// WHERE: hini: Ini file handle, or one of the pre-defined HINI handles
// NameList: will be created with list of ApplicationNames
// RETURN: 0 for failure, else non-zero for success
//
//
//***** PrfGetKeyNames(): Get list of key name for application
// SYNTAX: bool PrfGetApplicationNames(int hini,string ApplName,string[] NameList)
// WHERE: hini: Ini file handle, or one of the pre-defined HINI handles
// ApplName: Name of the application these keys are stored under
// NameList: will be created with list of KeyNames
// RETURN: 0 for failure, else non-zero for success
//
//
//**** PrfOpenProfile(): Open INI file
// SYNTAX: int PrfOpenProfile(int hab,string FileName)
// WHERE: hab: handle anchor block, such as Info().hab
// FileName: name of ascii .INI file
// RETURN: Return INI handle, or NULL for Failure
// NOTE: the OS2system and user profiles are always open and available
// as predefined values, and so don't need calls to PrfOpenProfile()
//
//
//**** PrfCloseProfile(): Close INI file
// SYNTAX: bool PrfCloseProfile(int hini)
// WHERE: hini: Ini file handle, or one of the pre-defined HINI handles
// RETURN: False for failure, else TRUE
//
//
//**** PrfQueryProfileSize(): Get size of binary profile data
// SYNTAX: PrfQueryProfileData(int hini,string AppName,string Key,int BufferLen)
// WHERE: hini: Ini file handle, or one of the pre-defined HINI handles
// AppName: Name of the application these keys are stored under
// Key: name of key
// BufferLen: on output is data size
// RETURN: TRUE for success and FALSE for error
// MODIFY: Sets BufferLen to size of data
//
//
//**** PrfQueryProfileData(): Get binary profile data
// SYNTAX: PrfQueryProfileData(int hini,string AppName,string Key,
// byte[] Buffer,int BufferLen)
// WHERE: hini: Ini file handle, or one of the pre-defined HINI handles
// AppName: Name of the application these keys are stored under
// Key: name of key
// Buffer: storage for data, must be at least BufferLen big
// BufferLen: on input is max size of Buffer, on output is data size
// RETURN: TRUE for success and FALSE for error
// MODIFY: Sets BufferLen to size of data
//
//
//**** PrfWriteProfileData(): Write binary profile data
// SYNTAX: PrfWriteProfileData(int hini,string AppName,string KeyName,
// byte[] Data,int DataLen)
// WHERE: hini: Ini file handle, or one of the pre-defined HINI handles
// AppName: Name of the application these keys are stored under
// KeyName: name of key
// Data: byte array or BLOb of data to write
// DataLen: size of data to write
// RETURN: TRUE for success and FALSE for error
//
//
//**** PrfQueryProfileString(): Read string data
// SYNTAX: PrfQueryProfileString(int hini,string AppName,string KeyName,
// string DefaultRet,byte[] Buffer,int MaxBuffer)
// WHERE: hini: Ini file handle, or one of the pre-defined HINI handles
// AppName: Name of the application these keys are stored under
// KeyName: name of key
// DefaultRet: String to return if KeyName is not found
// Buffer: storage for data, must be at least MaxBuffer big
// MaxBuffer: size of Buffer
// RETURN: Return string length including the null termination character
// MODIFY: Fill buffer with the string
//
//
//**** PrfWriteProfileString(): Write string data
// SYNTAX: PrfQueryProfileString(int hini,string AppName,string Key,string String)
// WHERE: hini: Ini file handle, or one of the pre-defined HINI handles
// AppName: Name of the application these keys are stored under
// Key: name of key
// String: string to write to profile key
// RETURN: TRUE for success and FALSE for error
//
//
//*** PrfQueryProfileInt(): Query profile as an integer
// SYNTAX: PrfQueryProfileInt(int hini,string AppName,string Key,int DefaultRet)
// WHERE: hini: Ini file handle, or one of the pre-defined HINI handles
// AppName: Name of the application these keys are stored under
// Key: name of key
// DefaultRet: value to return if Key not found or not an integer
// RETURN: Integer value of KeyName, or DefaultRet
//
//
#define HINI_PROFILE NULL // the USER and the SYSTEM profile
#define HINI_USERPROFILE (-1)
#define HINI_SYSTEMPROFILE (-2)
#define HINI_USER HINI_USERPROFILE
#define HINI_SYSTEM HINI_SYSTEMPROFILE
/*******************************************************************
********* END OF DESCRIPTION FOR WINSET.LIB *********
*******************************************************************/
PrfGetApplicationNames(hini,NameList)
{
for ( _TryBufSize = 5000; ;_TryBufSize += 5000 ) {
BLObSize(_Buf,_BufSize = _TryBufSize);
if ( !PrfQueryProfileData(hini,NULL,NULL,_Buf,_BufSize) )
return 0;
if ( _BufSize < (_TryBufSize - 1) )
break;
}
// Put all the names found into the namelist array
for ( _i = 0; _Buf[0]; _i++ ) {
strcpy(NameList[_i],_Buf);
_Buf += strlen(_Buf) + 1;
}
return(_i);
}
PrfGetKeyNames(hini,ApplicationName,NameList)
{
for ( _TryBufSize = 5000; ;_TryBufSize += 5000 ) {
BLObSize(_Buf,_BufSize = _TryBufSize);
if ( !PrfQueryProfileData(hini,ApplicationName,NULL,_Buf,_BufSize) )
return(0);
if ( _BufSize < (_TryBufSize - 1) )
break;
}
// Put all the names found into the namelist array
for ( _i = 0; _Buf[0]; _i++ ) {
strcpy(NameList[_i],_Buf);
_Buf += strlen(_Buf) + 1;
}
return(_i);
}
PrfQueryProfileData(hini,AppName,Key,Buffer,BufferLen)
{
#define ORD_PRF32QUERYPROFILEDATA 117
BLObPut(_BufferLen,BufferLen,UWORD32);
_ret = DynamicLink("PMSHAPI",ORD_PRF32QUERYPROFILEDATA,BIT32,CDECL,
hini,AppName,Key,Buffer,_BufferLen);
BufferLen = BLObGet(_BufferLen,0,UWORD32);
return(_ret);
}
PrfQueryProfileInt(hini,AppName,Key,DefaultRet)
{
#define ORD_PRF32QUERYPROFILEINT 114
return DynamicLink("PMSHAPI",ORD_PRF32QUERYPROFILEINT,BIT32,CDECL,
hini,AppName,Key,DefaultRet);
}
PrfQueryProfileSize(hini,AppName,KeyName,DataLen)
{
#define ORD_PRF32QUERYPROFILESIZE 101
BLObPut(_DataLen,0,UWORD32);
_ret = DynamicLink("PMSHAPI",ORD_PRF32QUERYPROFILESIZE,BIT32,CDECL,
hini,AppName,KeyName,_DataLen);
DataLen = BLObGet(_DataLen,0,UWORD32);
return(_ret);
}
PrfQueryProfileString(hini,AppName,KeyName,DefaultRet,Buffer,MaxBuffer)
{
// if Buffer is not big enough then make it bigger
if ( !defined(Buffer) || MaxBuffer < BLObSize(Buffer) )
BLObSize(Buffer,MaxBuffer);
#define ORD_PRF32QUERYPROFILESTRING 115
return DynamicLink("PMSHAPI",ORD_PRF32QUERYPROFILESTRING,BIT32,CDECL,
hini,AppName,KeyName,DefaultRet,Buffer,MaxBuffer);
}
PrfWriteProfileData(hini,AppName,KeyName,Data,DataLen)
{
#define ORD_PRF32WRITEPROFILEDATA 118
return DynamicLink("PMSHAPI",ORD_PRF32WRITEPROFILEDATA,BIT32,CDECL,
hini,AppName,KeyName,Data,DataLen);
}
PrfWriteProfileString(hini,AppName,KeyName,String)
{
#define ORD_PRF32WRITEPROFILESTRING 116
return DynamicLink("PMSHAPI",ORD_PRF32WRITEPROFILESTRING,BIT32,CDECL,
hini,AppName,KeyName,String);
}
PrfOpenProfile(hab,FileName)
{
#define ORD_PRF32OPENPROFILE 102
return DynamicLink("PMSHAPI",ORD_PRF32OPENPROFILE,BIT32,CDECL,hab,FileName);
}
PrfCloseProfile(hini)
{
#define ORD_PRF32CLOSEPROFILE 103
return DynamicLink("PMSHAPI",ORD_PRF32CLOSEPROFILE,BIT32,CDECL,hini);
}