"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" --defaults-file="C:\Program Files\MySQL\MySQL Server 5.5\my.ini" MySQL
//从注册表读取MySQL路径
CRegKey m_hKey;
if (m_hKey.Open(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\MySQL",KEY_READ)!=ERROR_SUCCESS)
{
m_strMYSQLPath="";
return false;
}
DWORD ValueLen=MAX_PATH;
TCHAR Value[MAX_PATH];
memset(Value,0,MAX_PATH);
if (m_hKey.QueryValue(Value,"ImagePath",&ValueLen)!=ERROR_SUCCESS)
{
m_strMYSQLPath="";
return false;
}
m_strMYSQLPath=Value;
int i=m_strMYSQLPath.Find(":");
m_strMYSQLPath=m_strMYSQLPath.Right(m_strMYSQLPath.GetLength()-i+1);
i=m_strMYSQLPath.Find("\"");
m_strMYSQLPath=m_strMYSQLPath.Left(i);
CString strch;
char * pCh = m_strMYSQLPath.GetBuffer();
char * pFindFile = strrchr(pCh, '\\');
strch=(CString)(pFindFile);
m_strMYSQLPath=m_strMYSQLPath.Left(m_strMYSQLPath.GetLength()-strch.GetLength());
m_strMYSQLPath.ReleaseBuffer();
return true;