|
// *********************************************************
// コンストラクタ1
// 現在実行しているプログラムのパスとファイル名を用いる
// *********************************************************
LboxInifile::LboxInifile()
{
LboxInifile::szIniFilePath = NULL;
char *szBuffer = new char[MAX_PATH];
LboxGetProgramPath( szBuffer );
PathRemoveExtension( szBuffer );
lstrcat( szBuffer, ".ini" );
LboxReAlloc(
&(LboxInifile::szIniFilePath),
lstrlen( szBuffer + 10 )
);
if ( LboxInifile::szIniFilePath != NULL ) {
lstrcpy( LboxInifile::szIniFilePath, szBuffer );
}
delete [] szBuffer;
}
// *********************************************************
// コンストラクタ2
// 現在実行しているプログラムのパスと lpName を用いる
// *********************************************************
LboxInifile::LboxInifile( LPTSTR lpName )
{
LboxInifile::szIniFilePath = NULL;
char *szBuffer = new char[MAX_PATH];
LboxGetProgramPath( szBuffer );
PathRemoveFileSpec( szBuffer );
PathAddBackslash( szBuffer );
lstrcat( szBuffer, lpName );
lstrcat( szBuffer, ".ini" );
LboxReAlloc(
&(LboxInifile::szIniFilePath),
lstrlen( szBuffer + 10 )
);
if ( LboxInifile::szIniFilePath != NULL ) {
lstrcpy( LboxInifile::szIniFilePath, szBuffer );
}
delete [] szBuffer;
}
// *********************************************************
// コンストラクタ3
// lpPath が "WINDOWS" の場合はウインドウズディレクトリ
// lpPath が "SYSTEM" の場合はシステムディレクトリ
// それ以外の場合は lpPath をディレクトリに用い、
// ファイル名部分は lpName を用いる
// *********************************************************
LboxInifile::LboxInifile( LPTSTR lpPath, LPTSTR lpName )
{
LboxInifile::szIniFilePath = NULL;
char *szBuffer = new char[MAX_PATH];
if ( lstrcmpi( lpPath, "WINDOWS" ) == 0 ) {
GetWindowsDirectory( szBuffer, MAX_PATH );
}
if ( lstrcmpi( lpPath, "SYSTEM" ) == 0 ) {
GetSystemDirectory( szBuffer, MAX_PATH );
}
if ( lstrcmpi( lpPath, "WINDOWS" ) != 0 &&
lstrcmpi( lpPath, "SYSTEM" ) != 0 ) {
lstrcpy( szBuffer, lpPath );
}
PathAddBackslash( szBuffer );
lstrcat( szBuffer, lpName );
lstrcat( szBuffer, ".ini" );
LboxReAlloc(
&(LboxInifile::szIniFilePath),
lstrlen( szBuffer + 10 )
);
if ( LboxInifile::szIniFilePath != NULL ) {
lstrcpy( LboxInifile::szIniFilePath, szBuffer );
}
delete [] szBuffer;
}
| |