121 lines
2.8 KiB
C++
121 lines
2.8 KiB
C++
#include "StdAfx.h"
|
|
#include ".\servicescriptinfo.h"
|
|
|
|
CServiceScriptInfo::CServiceScriptInfo(void)
|
|
{
|
|
ZeroMemory( m_szBinPath, MAX_PATH );
|
|
ZeroMemory( m_szServiceName, MAX_PATH );
|
|
ZeroMemory( m_szDisplayName, MAX_PATH );
|
|
}
|
|
|
|
CServiceScriptInfo::~CServiceScriptInfo(void)
|
|
{
|
|
|
|
}
|
|
|
|
BOOL CServiceScriptInfo::LoadData(void)
|
|
{
|
|
TCHAR szPath[MAX_PATH];
|
|
if( !GetInfoFilePath( szPath, MAX_PATH ) )
|
|
return FALSE;
|
|
|
|
if( !LoadCommonData( szPath ) )
|
|
return FALSE;
|
|
|
|
if( !LoadAppData( szPath ) )
|
|
return FALSE;
|
|
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CServiceScriptInfo::GetInfoFilePath( TCHAR* pszPath, int nSize )
|
|
{
|
|
TCHAR szPath[MAX_PATH];
|
|
GetCurrentDirectory( MAX_PATH, szPath );
|
|
|
|
if( szPath )
|
|
{
|
|
strcat( szPath, "\\" );
|
|
strcat( szPath, INFOFILE_NAME );
|
|
strncpy( pszPath, szPath, MAX_PATH );
|
|
}
|
|
else
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CServiceScriptInfo::LoadCommonData( TCHAR* pszPath )
|
|
{
|
|
if( !pszPath ) return FALSE;
|
|
|
|
DWORD dwRet = 0;
|
|
m_nServiceCount = GetPrivateProfileInt( "COMMON", "SERVICE_COUNT", 0, pszPath );
|
|
for( int i = 1; i <= m_nServiceCount; i++ )
|
|
{
|
|
TCHAR szNum[10];
|
|
_snprintf( szNum, 10, "%d", i );
|
|
dwRet = GetPrivateProfileString( "COMMON", szNum, NULL, m_szAppName[i-1], MAX_PATH, pszPath );
|
|
if( dwRet <= 0 ) return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CServiceScriptInfo::LoadAppData( TCHAR* pszPath )
|
|
{
|
|
DWORD dwRet = 0;
|
|
|
|
for( int i = 0; i < GetServiceCount(); i++ )
|
|
{
|
|
dwRet = GetPrivateProfileString( m_szAppName[i], "BINPATH", NULL, m_szBinPath[i], MAX_PATH, pszPath );
|
|
if( dwRet <= 0 ) return FALSE;
|
|
dwRet = GetPrivateProfileString( m_szAppName[i], "SERVICENAME", NULL, m_szServiceName[i], MAX_PATH, pszPath );
|
|
if( dwRet <= 0 ) return FALSE;
|
|
dwRet = GetPrivateProfileString( m_szAppName[i], "DISPLAYNAME", NULL, m_szDisplayName[i], MAX_PATH, pszPath );
|
|
if( dwRet <= 0 ) return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
void CServiceScriptInfo::GetBinPath( TCHAR* pszPath, int nSize, int nServiceNum )
|
|
{
|
|
if( nServiceNum <= 0 || nServiceNum > 10 )
|
|
return;
|
|
|
|
if( !m_szBinPath[nServiceNum-1] ) return;
|
|
strncpy( pszPath, m_szBinPath[nServiceNum-1], nSize );
|
|
}
|
|
|
|
|
|
void CServiceScriptInfo::GetServiceName( TCHAR* pszName, int nSize, int nServiceNum )
|
|
{
|
|
if( nServiceNum <= 0 || nServiceNum > 10 )
|
|
return;
|
|
|
|
if( !m_szServiceName[nServiceNum-1] ) return;
|
|
strncpy( pszName, m_szServiceName[nServiceNum-1], nSize );
|
|
}
|
|
|
|
void CServiceScriptInfo::GetDisplayName( TCHAR* pszName, int nSize, int nServiceNum )
|
|
{
|
|
if( nServiceNum <= 0 || nServiceNum > 10 )
|
|
return;
|
|
|
|
if( !m_szDisplayName[nServiceNum-1] ) return;
|
|
strncpy( pszName, m_szDisplayName[nServiceNum-1], nSize );
|
|
}
|
|
|
|
void CServiceScriptInfo::GetAppName( TCHAR* pszName, int nSize, int nServiceNum )
|
|
{
|
|
if( nServiceNum <= 0 || nServiceNum > 10 )
|
|
return;
|
|
|
|
if( !m_szAppName[nServiceNum-1] ) return;
|
|
strncpy( pszName, m_szAppName[nServiceNum-1], nSize );
|
|
}
|
|
|