#include "StdAfx.h" #include ".\configfile.h" #include #include using namespace std; ConfigFile::ConfigFile(void) { } ConfigFile::~ConfigFile(void) { } void ConfigFile::Read() { ifstream file("Udlaan.ini"); if (!file.is_open()) throw("Could not open file"); char buf[200]; while (!file.eof() ) { file.getline(buf,200); CString tmp(buf); if (tmp.GetAt(0) == '#') continue; int pos = tmp.Find('='); if (pos>0) { CString key = tmp.Left(pos).Trim().MakeLower();; CString value = tmp.Right(tmp.GetLength()-pos-1).Trim(); if (key == "driver") driver = value; else if (key == "host") host = value; else if (key == "username") username = value; else if (key == "password") password = value; else if (key == "database") database = value; } } file.close(); }