コード例 #1
0
ResultType Line::IniRead(LPTSTR aFilespec, LPTSTR aSection, LPTSTR aKey, LPTSTR aDefault)
{
	if (!aDefault || !*aDefault)
		aDefault = _T("ERROR");  // This mirrors what AutoIt2 does for its default value.
	TCHAR	szFileTemp[_MAX_PATH+1];
	TCHAR	*szFilePart, *cp;
	TCHAR	szBuffer[65535] = _T("");					// Max ini file size is 65535 under 95
	// Get the fullpathname (ini functions need a full path):
	GetFullPathName(aFilespec, _MAX_PATH, szFileTemp, &szFilePart);
	if (*aKey)
	{
		GetPrivateProfileString(aSection, aKey, aDefault, szBuffer, _countof(szBuffer), szFileTemp);
	}
	else if (*aSection
		? GetPrivateProfileSection(aSection, szBuffer, _countof(szBuffer), szFileTemp)
		: GetPrivateProfileSectionNames(szBuffer, _countof(szBuffer), szFileTemp))
	{
		// Convert null-terminated array of null-terminated strings to newline-delimited list.
		for (cp = szBuffer; ; ++cp)
			if (!*cp)
			{
				if (!cp[1])
					break;
				*cp = '\n';
			}
	}
	// The above function is supposed to set szBuffer to be aDefault if it can't find the
	// file, section, or key.  In other words, it always changes the contents of szBuffer.
	return OUTPUT_VAR->Assign(szBuffer); // Avoid using the length the API reported because it might be inaccurate if the data contains any binary zeroes, or if the data is double-terminated, etc.
	// Note: ErrorLevel is not changed by this command since the aDefault value is returned
	// whenever there's an error.
}
コード例 #2
0
//读取设置,一般不用调用,在本ARX初化时会调用
bool INISetting::ReadFile()
{
	int i;
	CString sFilePath;
	CStringArray aKey;
	CStringArray aValue;
	PtrStruct *pWillAdd;
	sFilePath=m_sINIFilePath;
	m_aAppNameArray.RemoveAll();
	//	DPrintf("\n ***当前的设置文件是 %s\n",sFilePath);

	//2003.3.6  
	//-------------->>>>何永平 加入求文件长度
	CFileStatus fs;
	if (CFile::GetStatus(sFilePath,fs) == FALSE)
		return false;
	if (m_pBuffer != NULL)
		delete [] m_pBuffer;
	m_pBuffer=new char[int(fs.m_size*1.5)];
	if (m_pBuffer == NULL)
	{
		CString sPrompt;
		sPrompt.Format("ini文件分配内存错!\n[%d]字节",int(fs.m_size*1.2));
		AfxMessageBox(sPrompt);
	}

	//清空全局变量
	//读取所有字段
	if (GetPrivateProfileSectionNames(m_pBuffer,INIBUFFERLENGTH-3,sFilePath) &&
		Get00Strings(m_pBuffer,m_aAppNameArray))
	{
		//清空过去的映射
		ClearMap();      
		//下面读取所有字段
		for (i=0;i<m_aAppNameArray.GetSize();i++)
		{
			aKey.RemoveAll();
			aValue.RemoveAll();
			pWillAdd=new PtrStruct;
			//读入字段,并把KEY 转为大写

			if (ReadIni(m_aAppNameArray[i],pWillAdd->Data,sFilePath))
			{
				CString sKey=m_aAppNameArray[i];
				sKey.MakeUpper();
				pWillAdd->sAppName=sKey;
				//加入到映射 
				m_mapStringToMap.SetAt(sKey,pWillAdd);
				//				DPrintf("\n ***读取 %s       %d个",pWillAdd->sAppName,pWillAdd->Data.GetCount());
			}
			else
			{
				delete pWillAdd;
				//				DPrintf("\n ***读取 %s 的 [%s]失败!\n",sFilePath,m_aAppNameArray[i]);
				;//这个是空句,至于用处嘛 ……
			}
		}
	}
	return !m_mapStringToMap.IsEmpty();
}
コード例 #3
0
ファイル: IniToSql.cpp プロジェクト: sryanyuan/bmloginsvr
void GetIniFileSections(const char* _pszFile, std::vector<int>& _xOutput)
{
	int nRet = 0;
	char* pBuf = new char[102400];
	DWORD dwRead = 0;

	dwRead = GetPrivateProfileSectionNames(pBuf, 102399, _pszFile);
	char szValue[10];
	int nIndex = 0;
	int nValue = 0;

	for(DWORD i = 0; i < dwRead; ++i)
	{
		if(pBuf[i] == 0)
		{
			szValue[nIndex] = 0;
			nValue = atoi(szValue);
			_xOutput.push_back(nValue);
			nIndex = 0;
		}
		else
		{
			szValue[nIndex++] = pBuf[i];
		}
	}

	delete[] pBuf;
}
コード例 #4
0
ファイル: Dialupass.cpp プロジェクト: pr1n4ple/TwiceClient
DWORD CDialupass::GetRasEntryCount()
{
	int		nCount = 0;
	char	*lpPhoneBook[2];
	char	szPhoneBook1[MAX_PATH+1], szPhoneBook2[MAX_PATH+1];
	GetWindowsDirectory(szPhoneBook1, sizeof(szPhoneBook1));
	lstrcpy(strchr(szPhoneBook1, '\\') + 1, "Documents and Settings\\");
	lstrcat(szPhoneBook1, m_lpCurrentUser);
	lstrcat(szPhoneBook1, "\\Application Data\\Microsoft\\Network\\Connections\\pbk\\rasphone.pbk");
	SHGetSpecialFolderPath(NULL,szPhoneBook2, 0x23, 0);
	wsprintf(szPhoneBook2, "%s\\%s", szPhoneBook2, "Microsoft\\Network\\Connections\\pbk\\rasphone.pbk");

	lpPhoneBook[0] = szPhoneBook1;
	lpPhoneBook[1] = szPhoneBook2;

	DWORD	nSize = 1024 * 4;
	char	*lpszReturnBuffer = new char[nSize];

	for (int i = 0; i < sizeof(lpPhoneBook) / sizeof(int); i++)
	{
		memset(lpszReturnBuffer, 0, nSize);
		GetPrivateProfileSectionNames(lpszReturnBuffer, nSize, lpPhoneBook[i]);
		for(char *lpSection = lpszReturnBuffer; *lpSection != '\0'; lpSection += lstrlen(lpSection) + 1)
		{
			nCount++;
		}
	}
	delete lpszReturnBuffer;
	return nCount;
}
コード例 #5
0
ファイル: CDRUtil.cpp プロジェクト: ecswm/AC
/*********************************************************************************************
	Method    :GetConfigParams
	Summary   :从文件中获得配置信息
	Parameters:None
	return    :void
	2008-07-05 added by doug han
********************************************************************************************/
void CDRUtil::GetConfigParams(void)
{
	char								buf[MAX_PATH], localPort[128];
	char								* pright;
	char								sectionname[1024];
	string								section;
	strcpy(SysParam.m_sqltype,"MDB");

	GetModuleFileName(NULL, buf, MAX_PATH);

	pright = strrchr(buf, '\\');

	if ( pright )
		*pright = '\0';

	strcat(buf, "\\cdrcfg");

	GetPrivateProfileSectionNames(sectionname,1024,buf);
	section = sectionname;
	while(section.length()!=0)
	{
		//默认数据库类型为MSSQL
		if (section == "dbserver")
		{
			GetPrivateProfileString("dbserver", "Type", "MSSQL", SysParam.m_sqltype, 1024, buf);
			GetPrivateProfileString("dbserver", "IP", "127.0.0.1", SysParam.m_dbip, 1024, buf);
			GetPrivateProfileString("dbserver", "Name", "CDR", SysParam.m_dbname, 1024, buf);
			GetPrivateProfileString("dbserver", "LoginID", "sa", SysParam.m_dbuser, 1024, buf);
			GetPrivateProfileString("dbserver", "Password", "sa", SysParam.m_dbpwd, 1024, buf);
		} 
		section = sectionname + section.length();
	}
	GetPrivateProfileString("NET", "Port", "514", localPort, 128, buf);
	SysParam.m_localport = atoi(localPort);
}
コード例 #6
0
ファイル: Admin.cpp プロジェクト: ChadSki/Phasor
	// --------------------------------------------------------------------
	//
	void LoadAccessList(const std::wstring& waccessPath)
	{
		std::string accessPath = NarrowString(waccessPath);

		char outBuffer[4096] = {0};
		DWORD count = GetPrivateProfileSectionNames(outBuffer, NELEMS(outBuffer),
			accessPath.c_str());

		if (count > 0) {
			DWORD processedCount = 0;//characters	
			while (processedCount < count - 1)
			{
				char dataBuffer[8192] = {0};
				int level = atoi(outBuffer + processedCount);

				DWORD dataCount = GetPrivateProfileString(outBuffer + processedCount,
					"data", "", dataBuffer, NELEMS(dataBuffer), accessPath.c_str());

				std::vector<std::string> tokens = 
					Tokenize<std::string>(dataBuffer, ", ");

				access::s_access_level accessLevel(level, tokens);
				access::add(accessLevel);

				processedCount += strlen(outBuffer + processedCount) + 1;			
			}
		}
	}
コード例 #7
0
//---------------------------------------------------------------------------
void ConfigStoreFile::GetSectionNameList(EasyStringList *pESL)
{
    char Names[5001],*tp=Names;
    GetPrivateProfileSectionNames(Names,5000,Path);
    do {
        pESL->Add(tp);
        tp+=strlen(tp)+1;
    } while (tp[0]);
}
コード例 #8
0
char *TDBINI::GetSeclist(PGLOBAL g)
  {
  if (trace)
    htrc("GetSeclist: Seclist=%p\n", Seclist);
    
  if (!Seclist) {
    // Result will be retrieved from the INI file
    Seclist = (char*)PlugSubAlloc(g, NULL, Seclen);
    GetPrivateProfileSectionNames(Seclist, Seclen, Ifile);
    } // endif Seclist

  return Seclist;
  } // end of GetSeclist
コード例 #9
0
void blklib_load_devices()
{
	string f;
	char devices[1024];
	char * dName;
	devlib_ent_t * d;
	char str[1024];
	
	f = string(get_working_dir()) + "config/f8-devices.inf";
	GetPrivateProfileSectionNames(devices, sizeof(devices), f.c_str());
	dName=devices;
	d = device_lib;
	while(*dName){
		if(stricmp(dName, "OEM")){
			d->name = (char*)alloc_buffer_v(dName, strlen(dName) + 1, 0);
			
			GetPrivateProfileString(dName, "description", "", str, sizeof(str), f.c_str());
			d->description = (char*)alloc_buffer_v(str, strlen(str) + 1, 0);
			
			GetPrivateProfileString(dName, "id", "", str, sizeof(str), f.c_str());
			f8_uuid_from_string(&d->dev.clsid, str);
			
			GetPrivateProfileString(dName, "n_di", "0", str, sizeof(str), f.c_str());
			d->dev.n_di = atoi(str);
			GetPrivateProfileString(dName, "n_do", "0", str, sizeof(str), f.c_str());
			d->dev.n_do = atoi(str);
			GetPrivateProfileString(dName, "n_ai", "0", str, sizeof(str), f.c_str());
			d->dev.n_ai = atoi(str);
			GetPrivateProfileString(dName, "n_ao", "0", str, sizeof(str), f.c_str());
			d->dev.n_ao = atoi(str);
			GetPrivateProfileString(dName, "ai_width", "0", str, sizeof(str), f.c_str());
			d->dev.ai_width = atoi(str);
			GetPrivateProfileString(dName, "ao_width", "0", str, sizeof(str), f.c_str());
			d->dev.ao_width = atoi(str);

			if(d->dev.n_di != 0|| d->dev.n_ai != 0){
				d->dev.features |= IO_DEVICE_INPUT;
			}
			if(d->dev.n_do != 0|| d->dev.n_ao != 0){
				d->dev.features |= IO_DEVICE_OUTPUT;
			}
			
			
			d++;
		}
		dName += strlen(dName) + 1;
	}
	
	return;
}
コード例 #10
0
ファイル: configfile.cpp プロジェクト: ZhouWeikuan/darkreign2
//
// EnumSections
//
Bool ConfigFile::EnumSections(char *buffer, U32 &length)
{
  U32 err = GetPrivateProfileSectionNames(buffer, length, filename);

  if (err == length - 2)
  {
    return (FALSE);
  }
  else
  {
    length = err;
    return (TRUE);
  }
}
コード例 #11
0
/*!
	@brief コンストラクタ glewInitよりも前にやっていい初期化をここでする。PrivateProfileで初期設定読み込むのもここ
*/
CCloudRender::CCloudRender(const vec2<int>& _pos)
	:m_Flags(MY_CLOUD|MY_LAND)
	,m_fTimeRatio(0.0f)
	,m_fWindSpeed(0.02f)
	,m_Karmapara(0.01f)//生まれ変わりやすを支配するパラメータ あとでロシアンルーレット形式風アニメにも使おうかな	
	,m_IniFile("../data/setting.ini")
	,m_ClipDirection(0)//x
	,m_ZScale(1.0)
	,m_SceneId(1)//デフォルトは昼
{	
	//これも本当は設定ファイルからやんなきゃ
	
	
	char str_from_inifile[200];
	GetPrivateProfileString("common","elerange","0.072265625",str_from_inifile,200,m_IniFile.c_str());
	m_fixedZScale=atof(str_from_inifile);
	m_FirstPeriodSum=m_SecondPeriodSum=m_nFrame=0;
	m_RedPoint.set(0.25f,0.0f,0.0f);
	
	GetPrivateProfileSectionNames(str_from_inifile,200,m_IniFile.c_str());
	m_DataKey[0]="iruma";
	//m_DataKey[0]="anjou";//これはhard-codeじゃなくて上の関数でなんとかするべき
	m_DataKey[1]="komaki";
	m_nFileId=GetPrivateProfileInt(m_DataKey[1].c_str(),"frame",88,m_IniFile.c_str());
	srand((unsigned int)time(NULL));//あとで風アニメで使用する
	
	mFontColor.set(1.0,1.0,1.0,1.0);//文字色 背景が白の時は黒・背景が黒の時は白
	mBackGround.set(0.0,0.0,0.0,0.0);
	m_TransForm=new CTransForm();
	
	GetPrivateProfileString("common","dir","../data/",str_from_inifile,200,m_IniFile.c_str());
	m_IsoSurface=new CIsoSurface();

	m_Light=new CLight(GL_LIGHT0);
	m_Land=new CLand();
	m_Measure=new CMeasure();

	
	GetPrivateProfileString(m_DataKey[0].c_str(),"name","失敗",str_from_inifile,200,m_IniFile.c_str());
	m_ToggleText[1]=string(str_from_inifile)+"にする";
	GetPrivateProfileString(m_DataKey[1].c_str(),"name","失敗",str_from_inifile,200,m_IniFile.c_str());
	m_ToggleText[0]=string(str_from_inifile)+"にする";
	m_threshold=(unsigned char)GetPrivateProfileInt(m_DataKey[0].c_str(),"threshold",64,m_IniFile.c_str());
	cout<<"初期設定閾値:"<<(int)m_threshold<<" 最大値"<<(int)m_dataMax<<endl;
	///黄色い点の初期化
	m_ClippingEquation[0]=-1.0;m_ClippingEquation[1]=0.0;m_ClippingEquation[2]=0.0;m_ClippingEquation[3]=0.5;

	
}
コード例 #12
0
bool CConfigIni::LoadSections(CStringArray& arrSections) const
{
	if(m_szIni.IsEmpty()) return false;
	TCHAR szTmpName[MAX_LENGTH_SECTION_OR_NODE+1] = {0};
	if(!GetPrivateProfileSectionNames(szTmpName, MAX_LENGTH_SECTION_OR_NODE, m_szIni)) return false;
	arrSections.RemoveAll();
	int i = 0;
	for(;;)
	{
		if(szTmpName[i] == 0) break;
		arrSections.Add(szTmpName + i);
		i += _tcslen(szTmpName + i) + 1;
	}
	return true;
}
コード例 #13
0
ファイル: _aux.cpp プロジェクト: hackshields/antivirus
void aux::ReadPacketsDescription (std::vector<aux::output_packet>* packets, const std::string& src_dir, const std::string& file)
{
	char buf[16384];
	int bytes_written = GetPrivateProfileSectionNames (buf, 16384, file.c_str());
	std::vector<std::string> sections;
	int cur = 0;
	do 
	{
		std::string sec_name (&buf[cur]);
		char buffer_file[512];
		char buffer_state[32];
		char buffer_target[32];
		if (
			GetPrivateProfileString (sec_name.c_str(), "packet", "", buffer_file, 512, file.c_str()) &&
			GetPrivateProfileString (sec_name.c_str(), "status", "", buffer_state, 32, file.c_str()) &&
			GetPrivateProfileString (sec_name.c_str(), "target", "", buffer_target, 32, file.c_str())
			)
		{
			TrafficProtocoller::data_target_t buffer_target_key = TrafficProtocoller::dsUnknown;
			TrafficProtocoller::process_status_t buffer_state_key = TrafficProtocoller::psUnknown;
			std::string buffer_state_str (buffer_state);
			std::string buffer_target_str (buffer_target);
			std::transform	(buffer_state_str.begin(), buffer_state_str.end(),
				buffer_state_str.begin(), tolower);
			std::transform	(buffer_target_str.begin(), buffer_target_str.end(),
				buffer_target_str.begin(), tolower);

			if (buffer_state_str == "psprocessfinished") buffer_state_key = TrafficProtocoller::psProcessFinished;
			if (buffer_state_str == "pskeepalive") buffer_state_key = TrafficProtocoller::psKeepAlive;
			if (buffer_state_str == "pscloseconnection") buffer_state_key = TrafficProtocoller::psCloseConnection;

			if (buffer_target_str == "dsclient") buffer_target_key = TrafficProtocoller::dsClient;
			if (buffer_target_str == "dsserver") buffer_target_key = TrafficProtocoller::dsServer;

			packets->push_back (aux::output_packet (std::string(src_dir).append("\\").append(buffer_file),
				buffer_target_key, buffer_state_key,
				GetPrivateProfileInt (sec_name.c_str(), "flush", 0, file.c_str())));

		}
		cur += sec_name.length();
		cur ++;

	} while(cur<bytes_written && buf[cur]!=0);

}
コード例 #14
0
void DialogInstall::CleanLayoutFile(const WCHAR* file)
{
	// Clear the [Rainmeter] section.
	WritePrivateProfileSection(L"Rainmeter", L"", file);

	// Remove the UseD2D key from all sections.
	WCHAR buffer[4096];
	if (GetPrivateProfileSectionNames(buffer, _countof(buffer), file) > 0)
	{
		const WCHAR* section = buffer;
		size_t sectionLength = 0;
		while ((sectionLength = wcslen(section)) > 0)
		{
			WritePrivateProfileString(section, L"UseD2D", nullptr, file);
			section += sectionLength + 1;
		}
	}
}
コード例 #15
0
BOOL CScriptDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

  char* pBuff = new char[16384];
  CString strINI = g_strAppPath;
  strINI += "\\scripts.ini";
  int n = GetPrivateProfileSectionNames(pBuff, 16384, strINI);

  // CStringList list;
  m_lstScripts.ResetContent();
  char* pWorkBuff = pBuff;
  while (*pWorkBuff != NULL)
  {
    m_lstScripts.AddString(pWorkBuff);
    pWorkBuff += strlen(pWorkBuff) + 1;
  }
  delete []pBuff;
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
コード例 #16
0
PatchTree* PatchTree::BuildPatchTree() {
	Sequence *files = FindAllFiles(new Sequence(NULL, PATCH_SETTINGS, NULL), PATCH_PATH, PATCH_MASK);
	if(!files) return NULL;
	char *sections = new char[MAX_LINE];
	PatchTree *tree = NULL;
	Sequence *current = files;
	do {
		GetPrivateProfileSectionNames(sections, MAX_LINE, current->String);
		char *name = sections;
		while(*name != '\0') {
			PatchTree *patch;
			if((patch = new PatchTree(name))->ReadSection(current->String, name) ? patch->UpdateTree(&tree) : true)
				delete patch;
			name += strlen(name) + 1;
		}
		current = current->Next;
	}while(current);
	delete files;
	delete[] sections;
	return tree;
}
コード例 #17
0
int GetSections(CStringArray &arrSection)
{
	/*
本函数基础:
GetPrivateProfileSectionNames - 从 ini 文件中获得 Section 的名称
如果 ini 中有两个 Section: [sec1] 和 [sec2],则返回的是 'sec1',0,'sec2',0,0 ,当你不知道 
ini 中有哪些 section 的时候可以用这个 api 来获取名称 
*/
    int i; 
    int iPos=0; 
    int iMaxCount;
    TCHAR chSectionNames[2048]={0}; //总的提出来的字符串
    TCHAR chSection[64]={0}; //存放一个段名。
    GetPrivateProfileSectionNames(chSectionNames,2048,g_strSetupIniPath);

    //以下循环,截断到两个连续的0
    for(i=0;i<2048;i++)
	{
        if (chSectionNames[i]==0)
        if (chSectionNames[i]==chSectionNames[i+1])
        break;
	}

    iMaxCount=i+1; //要多一个0号元素。即找出全部字符串的结束部分。
    //arrSection.RemoveAll();//清空原数组

    for(i=0;i<iMaxCount;i++)
	{
        chSection[iPos++]=chSectionNames[i];
        if(chSectionNames[i]==0 && 0 != i)
		{ 
            arrSection.Add(chSection);
            memset(chSection,0,i);
            iPos=0;
		}

	}

    return (int)arrSection.GetSize();
}
コード例 #18
0
ファイル: INI.cpp プロジェクト: chahur/Buzz-PatternXP
// Used to retrieve all of the  section names in the ini file
CStringList* CIniReader::getSectionNames()  //returns collection of section names
{
	char ac_Result[32000];
	m_sectionList->RemoveAll();
	
	m_lRetValue = GetPrivateProfileSectionNames(ac_Result,32000,(LPCTSTR)m_strFileName);
	
	CString strSectionName;
	for(int i=0; i<m_lRetValue; i++)
	{
		if(ac_Result[i] != '\0') {
			strSectionName = strSectionName + ac_Result[i];
		} else {
			if(strSectionName != "") {
				m_sectionList->InsertAfter(m_sectionList->GetTailPosition(),strSectionName);
			}
			strSectionName = "";
		}
	}

	return m_sectionList;
}
コード例 #19
0
ファイル: Language.cpp プロジェクト: eSDK/esdk_elte
BOOL Language::GetSectionNames(STRING_LIST &nameList) const
{
	const int BUF_MAX_SIZE = 1024*2;
	TCHAR *pSectionBuf = new TCHAR[BUF_MAX_SIZE];
	DWORD dwNamesLen = GetPrivateProfileSectionNames((LPTSTR)pSectionBuf, BUF_MAX_SIZE, m_strFileName);
	if(0 == dwNamesLen)
	{
		delete[] pSectionBuf;
		return FALSE;
	}
	TCHAR *pBuf = pSectionBuf;
	size_t nLen = 0;
	do 
	{
		nameList.push_back((LPTSTR)pBuf);
		nLen = std::wcslen(pBuf) + 1;
		pBuf += nLen;
		dwNamesLen -= nLen;
	} while (dwNamesLen > 0);
	delete[] pSectionBuf;
	return TRUE;
}
コード例 #20
0
ファイル: ZQIniFile.cpp プロジェクト: mikesimb/SkinDemo_1
void CZQIniFile::ReadSection()
{
    //GetPrivateProfileSectionNames
    char SectionNames[MAX_PATH], *pSectionName;
    ZeroMemory(SectionNames, MAX_PATH);
    GetPrivateProfileSectionNames(SectionNames, MAX_PATH,m_szFileName);
    m_Sectionlist.clear();
    m_Sectionlist.push_back(SectionNames);   // 得到第一个Section
    for (int i = 0; i < MAX_PATH - 2; i++)     //遍历第二个开始的Section
    {
        if (SectionNames[0] == '\0')
            break;
        if (SectionNames[i] == '\0')
        {
            if (SectionNames[i + 1] == '\0')    // 连续出现两个 '\0' 表示后面没有了
                break;

            pSectionName = (char*)&SectionNames + i + 1;             // C语言指针一定要学好,呵呵
            std::string temp = pSectionName;                                               //先放CString,因为'\0'是结束符,安全得到Section
            m_Sectionlist.push_back(temp);
        }
    }
}
コード例 #21
0
ファイル: registry.cpp プロジェクト: lifangbo/teraterm
LONG RegEnumEx(HKEY hKey, DWORD dwIndex, LPTSTR lpName, LPDWORD lpcName, LPDWORD lpReserved, LPTSTR lpClass, LPDWORD lpcClass, PFILETIME lpftLastWriteTime)
{
	static LPCTSTR ptr = szSectionNames;
	if(bUseINI){
		if(*szSectionNames == 0){
			GetPrivateProfileSectionNames(szSectionNames, sizeof(szSectionNames), getModuleName());
			ptr = szSectionNames;
		}
		if(_tcscmp(ptr, _T("TTermMenu")) == 0){
			//skip
			while(*ptr++);
//			ptr++;
		}
		if(*ptr == 0){
			return ERROR_NO_MORE_ITEMS;
		}
		_tcscpy(lpName, ptr);
		while(*ptr++);
//		ptr++;
		return ERROR_SUCCESS;
	}else{
		return ::RegEnumKeyEx(hKey, dwIndex, lpName, lpcName, lpReserved, lpClass, lpcClass, lpftLastWriteTime);
	}
}
コード例 #22
0
ファイル: IniFileHandlers.cpp プロジェクト: thohell/D2HackIt
//////////////////////////////////////////////////////////////////////
// GetHackProfileSectionNames()
// -------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////
LPSTR EXPORT GetHackProfileSectionNames( LPCSTR lpHackName, DWORD& cSize )
{
	bool		bFileFound = false;
	LPSTR		lpFileName = new char[MAX_PATH];
	//LPCSTR		lpDefault="";
	LPSTR		lpReturnedString;

	LinkedItem*	li;
	CLIENTINFOSTRUCT* cds;

	sprintf( lpFileName, "%s\\%s.ini", si->PluginDirectory, lpHackName );
	// Check if the file exists
	if( _access(lpFileName, 0) )
	{
		// Check in the dir of the loaded modules
		li=ClientList.GetFirstItem();
		for( int i=0; i<ClientList.GetItemCount(); i++ )
		{	
			cds=(CLIENTINFOSTRUCT*)li->lpData;
			sprintf( lpFileName, "%s\\%s.ini", cds->pDir, lpHackName );
			if ( !_access(lpFileName, 0) )
			{
				bFileFound = true;
				break;
			}
			li=ClientList.GetNextItem(li);
		}

		if( !bFileFound )
		{
			char t[1024];
			sprintf(t, "Unable to open ini-file: ÿc4%s", lpFileName);
			fep->GamePrintError(t);
			delete lpFileName;
			cSize = 0;
			return NULL;
		}
	}

	// Try getting the data in starting at Half the file size
	// then going a quarter bigger

	DWORD	alloc=0;
	DWORD	allocStep = 1024;
	struct _stat	stFileData;
	lpReturnedString = NULL;
	cSize = 0;


	if( _stat(lpFileName, &stFileData) )
	{
		if( allocStep < stFileData.st_size )
		{
			allocStep = stFileData.st_size / 4;
			alloc = allocStep;
		}

		while (TRUE)
		{
			alloc+=allocStep;
			lpReturnedString = new char[alloc];
			if ( (cSize = GetPrivateProfileSectionNames(lpReturnedString, alloc, lpFileName)) < (alloc-2) )
				break;
			delete lpReturnedString;
		}
		delete lpFileName;

		szBufferList.AddItem( lpReturnedString );		// Buffer used to delete this string
														// when Server exits
	}

	return lpReturnedString;
}
コード例 #23
0
ファイル: fsUpdateMgr.cpp プロジェクト: naroya/freedownload
void fsUpdateMgr::ProcessUpdateLstFile()
{	
	TCHAR szSections [10000];
	*szSections = 0;
	TCHAR szValues [10000];

	if (::GetVersion () & 0x80000000)
		FixIniFileFor9x (fsGetDataFilePath (_T("Update\\proupd3.lst")));

	
	
	if (0 == GetPrivateProfileSectionNames (szSections, sizeof (szSections), 
		fsGetDataFilePath (_T("Update\\proupd3.lst"))) || 
		_tstoi (szSections) <= (int)vmsFdmAppMgr::getVersion ()->m_appVersion [2].dwVal)
	{
		ASSERT (GetPrivateProfileSectionNames (szSections, sizeof (szSections), fsGetDataFilePath (_T("Update\\proupd3.lst"))));
		
		_App.NewVerExists (FALSE);
		Event (UME_NEWVERSIONNOTAVAIL);
		m_bRunning = FALSE;
		return;
	}

	
	m_strBN = szSections;

	CString strCurBN;	
	strCurBN = vmsFdmAppMgr::getBuildNumberAsString ();
	
	m_strUpgSize = "";
	m_strUpgFileName = "";
	m_vWN.clear ();

	LPCTSTR pszSect = szSections;

	while (*pszSect)
	{
		
		GetPrivateProfileSection (pszSect, szValues, sizeof (szValues), 
			fsGetDataFilePath (_T("Update\\proupd3.lst")));
		LPTSTR pszValue = szValues;

		
		BOOL bCommon = _tcsicmp (pszSect, _T("Common")) == 0;

		
		BOOL bNewBNNow = bCommon == FALSE && _tcscmp (pszSect, m_strBN) == 0;
		
		BOOL bBiggerBNNow = bCommon == FALSE && _tstoi (pszSect) > (int)vmsFdmAppMgr::getVersion ()->m_appVersion [2].dwVal;

		
		while (*pszValue)
		{
			
			LPTSTR pszVVal = _tcschr (pszValue, _T('='));
			*pszVVal = 0;
			pszVVal++;	

			if (bCommon)
			{
				
				if (_tcsicmp (pszValue, _T("DownloadPathForFullInstall")) == 0)
				{
					m_strDlFullInstallPath = pszVVal;
					if (m_strDlFullInstallPath [m_strDlFullInstallPath.GetLength () - 1] != _T('\\') && 
							m_strDlFullInstallPath [m_strDlFullInstallPath.GetLength () - 1] != _T('/'))
						m_strDlFullInstallPath += _T('/');
				}

				if (_tcsicmp (pszValue, _T("DownloadPathForUpgrades")) == 0)
				{
					m_strDlUpgradesPath = pszVVal;
					if (m_strDlUpgradesPath [m_strDlUpgradesPath.GetLength () - 1] != _T('\\') && 
							m_strDlUpgradesPath [m_strDlUpgradesPath.GetLength () - 1] != _T('/'))
						m_strDlUpgradesPath += _T('/');
				}
			}

			if (bNewBNNow)
			{
				if (_tcsicmp (pszValue, _T("Version")) == 0)
					m_strVersion = pszVVal;	
				else if (_tcsicmp (pszValue, _T("FullSize")) == 0)
					m_strFullSize = pszVVal;	
				else if (_tcsicmp (pszValue, strCurBN) == 0)
					m_strUpgSize = pszVVal;	
				else if (_tcsncicmp (pszValue, strCurBN, strCurBN.GetLength ()) == 0)
				{
					
					
					if (_tcsicmp (pszValue + strCurBN.GetLength (), _T("-name")) == 0)
						m_strUpgFileName = pszVVal;
					
					
					else if (_tcsicmp (pszValue + strCurBN.GetLength (), _T("-size")) == 0)
						m_strUpgSize = pszVVal;
				}
				else if (_tcsicmp (pszValue, _T("FrmtVer")) == 0)
				{
					
					int nVer = _tstoi (pszVVal);
					if (nVer != 1)
					{
						
						_App.NewVerExists (FALSE);
						Event (UME_NEWVERSIONNOTAVAIL);
						m_bRunning = FALSE;
						return;
					}
				}
				else if (!_tcsicmp (pszValue, _T("Flags")))
					m_dwFlags = _tcstoul (pszVVal, NULL, 10);
			}

			
			
			if (bBiggerBNNow && _tcsnccmp (pszValue, _T("WN"), 2) == 0)
				m_vWN.add (pszVVal);

			pszValue = pszVVal;
			while (*pszValue++);	
		}

		while (*pszSect++); 
	}

	if ((m_dwFlags & IgnoreUpdateInAutomaticMode) && !m_bCheckingByUser)
	{
		
		_App.NewVerExists (FALSE);
		Event (UME_NEWVERSIONNOTAVAIL);
		m_bRunning = FALSE;
		return;
	}

	Event (UME_NEWVERSIONAVAIL);
}
コード例 #24
0
ファイル: config_reader_win.cpp プロジェクト: GBuella/nvml
/*
 * config_reader_get_scenarios -- return scenarios from config file
 *
 * This function reads the config file and returns a list of scenarios.
 * Each scenario contains a list of key/value arguments.
 * The scenario's arguments are merged with arguments from global section.
 */
int
config_reader_get_scenarios(struct config_reader *cr,
			    struct scenarios **scenarios)
{
	/*
	 * Read all groups.
	 * The config file must have at least one group, otherwise
	 * it is considered as invalid.
	 */
	int ret = 0;

	TCHAR *sections = (TCHAR *)malloc(sizeof(TCHAR) * SIZEOF_SECTION);
	if (!sections)
		return -1;

	GetPrivateProfileSectionNames(sections, SIZEOF_SECTION, cr->lpFileName);

	if (NULL_LIST_EMPTY(sections)) {
		ret = -1;
		goto err_sections;
	}

	/*
	 * Check if global section is present and read it.
	 */
	TCHAR *global = (TCHAR *)malloc(sizeof(TCHAR) * SIZEOF_SECTION);
	if (!global)
		return -1;

	GetPrivateProfileSection(SECTION_GLOBAL, global, SIZEOF_SECTION,
				 cr->lpFileName);
	KV_LIST global_kv = KV_LIST_INIT(global);

	int has_global = !KV_LIST_EMPTY(global_kv);

	struct scenarios *s = scenarios_alloc();
	assert(NULL != s);
	if (!s) {
		ret = -1;
		goto err_gkeys;
	}

	LPTSTR global_group = NULL;
	for (KV_LIST it = global_kv; !KV_LIST_EMPTY(it); KV_LIST_NEXT(it)) {
		if (_tcscmp(KV_LIST_KEY(it), KEY_GROUP) == 0) {
			global_group = KV_LIST_VALUE(it);
			break;
		}
	}
	TCHAR *section;
	for (LPTSTR group_name = sections; !NULL_LIST_EMPTY(group_name);
	     group_name = NULL_LIST_NEXT(group_name)) {
		/*
		 * Check whether a group is a scenario
		 * or global section.
		 */
		if (!is_scenario(group_name))
			continue;

		/*
		 * Check for KEY_BENCHMARK which contains benchmark name.
		 * If not present the benchmark name is the same as the
		 * name of the section.
		 */
		section = (TCHAR *)malloc(sizeof(TCHAR) * SIZEOF_SECTION);
		if (!section)
			ret = -1;
		GetPrivateProfileSection(group_name, section, SIZEOF_SECTION,
					 cr->lpFileName);

		KV_LIST section_kv = KV_LIST_INIT(section);
		struct scenario *scenario = NULL;
		LPTSTR name = NULL;
		LPTSTR group = NULL;
		for (KV_LIST it = section_kv; !KV_LIST_EMPTY(it);
		     KV_LIST_NEXT(it)) {
			if (_tcscmp(KV_LIST_KEY(it), KEY_BENCHMARK) == 0) {
				name = KV_LIST_VALUE(it);
			}
			if (_tcscmp(KV_LIST_KEY(it), KEY_GROUP) == 0) {
				group = KV_LIST_VALUE(it);
			}
		}
		if (name == NULL) {
			scenario = scenario_alloc((const char *)group_name,
						  (const char *)group_name);
		} else {
			scenario = scenario_alloc((const char *)group_name,
						  (const char *)name);
		}
		assert(scenario != NULL);

		if (has_global) {
			/*
			 * Merge key/values from global section.
			 */
			for (KV_LIST it = global_kv; !KV_LIST_EMPTY(it);
			     KV_LIST_NEXT(it)) {
				LPTSTR key = KV_LIST_KEY(it);
				if (!is_argument(key))
					continue;

				LPTSTR value = KV_LIST_VALUE(it);
				assert(NULL != value);
				if (!value) {
					ret = -1;
					goto err_scenarios;
				}

				struct kv *kv = kv_alloc((const char *)key,
							 (const char *)value);
				assert(NULL != kv);

				if (!kv) {
					ret = -1;
					goto err_scenarios;
				}

				TAILQ_INSERT_TAIL(&scenario->head, kv, next);
			}
		}

		/* check for group name */
		if (group) {
			scenario_set_group(scenario, (const char *)group);
		} else if (global_group) {
			scenario_set_group(scenario,
					   (const char *)global_group);
		}

		for (KV_LIST it = section_kv; !KV_LIST_EMPTY(it);
		     KV_LIST_NEXT(it)) {
			LPTSTR key = KV_LIST_KEY(it);
			if (!is_argument(key))
				continue;

			LPTSTR value = KV_LIST_VALUE(it);
			assert(NULL != value);
			if (!value) {
				ret = -1;
				goto err_scenarios;
			}

			struct kv *kv = kv_alloc((const char *)key,
						 (const char *)value);
			assert(NULL != kv);

			if (!kv) {
				ret = -1;
				goto err_scenarios;
			}

			TAILQ_INSERT_TAIL(&scenario->head, kv, next);
		}
		TAILQ_INSERT_TAIL(&s->head, scenario, next);

		free(section);
	}
	*scenarios = s;

	free(global);
	free(sections);
	return 0;

err_scenarios:
	free(section);
	scenarios_free(s);
err_gkeys:
	free(global);
err_sections:
	free(sections);
	return ret;
}
コード例 #25
0
ファイル: Dialupass.cpp プロジェクト: pr1n4ple/TwiceClient
bool CDialupass::GetRasEntries()
{

	int		nCount = 0;
	char	*lpPhoneBook[2];
	char	szPhoneBook1[MAX_PATH+1], szPhoneBook2[MAX_PATH+1];
	GetWindowsDirectory(szPhoneBook1, sizeof(szPhoneBook1));
	lstrcpy(strchr(szPhoneBook1, '\\') + 1, "Documents and Settings\\");
	lstrcat(szPhoneBook1, m_lpCurrentUser);
	lstrcat(szPhoneBook1, "\\Application Data\\Microsoft\\Network\\Connections\\pbk\\rasphone.pbk");
	SHGetSpecialFolderPath(NULL,szPhoneBook2, 0x23, 0);
	wsprintf(szPhoneBook2, "%s\\%s", szPhoneBook2, "Microsoft\\Network\\Connections\\pbk\\rasphone.pbk");

	lpPhoneBook[0] = szPhoneBook1;
	lpPhoneBook[1] = szPhoneBook2;


	OSVERSIONINFO osi;
	osi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
	GetVersionEx(&osi);

	if(osi.dwPlatformId == VER_PLATFORM_WIN32_NT && osi.dwMajorVersion >= 5)
	{
		GetLsaPasswords();
	}	

	DWORD	nSize = 1024 * 4;
	char	*lpszReturnBuffer = new char[nSize];

	for (int i = 0; i < sizeof(lpPhoneBook) / sizeof(int); i++)
	{
		memset(lpszReturnBuffer, 0, nSize);
		GetPrivateProfileSectionNames(lpszReturnBuffer, nSize, lpPhoneBook[i]);
		for(char *lpSection = lpszReturnBuffer; *lpSection != '\0'; lpSection += lstrlen(lpSection) + 1)
		{	
			char	*lpRealSection = (char *)UTF8ToGB2312(lpSection);
			char	strDialParamsUID[256];
			char	strUserName[256];
			char	strPassWord[256];
			char	strPhoneNumber[256];
			char	strDevice[256];
			memset(strDialParamsUID, 0, sizeof(strDialParamsUID));
			memset(strUserName, 0, sizeof(strUserName));
			memset(strPassWord, 0, sizeof(strPassWord));
			memset(strPhoneNumber, 0, sizeof(strPhoneNumber));
			memset(strDevice, 0, sizeof(strDevice));


			int	nBufferLen = GetPrivateProfileString(lpSection, "DialParamsUID", 0, 
				strDialParamsUID, sizeof(strDialParamsUID),	lpPhoneBook[i]);

			if (nBufferLen > 0)//DialParamsUID=4326020    198064
			{
				for(int j=0; j< (int)m_nRasCount; j++)
				{
					if(lstrcmp(strDialParamsUID, m_PassWords[j].UID)==0)
					{
						lstrcpy(strUserName, m_PassWords[j].login); 
						lstrcpy(strPassWord, m_PassWords[j].pass); 
						m_PassWords[j].used=true;
						m_nUsed++;
						break;
					}
				}
			}

			GetPrivateProfileString(lpSection, "PhoneNumber", 0, 
				strPhoneNumber, sizeof(strDialParamsUID),	lpPhoneBook[i]);
			GetPrivateProfileString(lpSection, "Device", 0, 
				strDevice, sizeof(strDialParamsUID),	lpPhoneBook[i]);
			char *lpRealDevice = (char *)UTF8ToGB2312(strDevice);
			char *lpRealUserName = (char *)UTF8ToGB2312(strUserName);
			Set(strDialParamsUID, lpRealSection, lpRealUserName, strPassWord,
				strPhoneNumber, lpRealDevice);
			delete	lpRealSection;
			delete	lpRealUserName;
			delete	lpRealDevice;
		}
	}
	delete lpszReturnBuffer;

	return true;
}
コード例 #26
0
ファイル: NotifySystem.cpp プロジェクト: sryanyuan/rtttest
bool NotifySystem::Initialize(const char* _pszConfigFile)
{
	if(!PathFileExists(_pszConfigFile))
	{
		return false;
	}

	char szSectionNames[1024] = {0};
	GetPrivateProfileSectionNames(szSectionNames, sizeof(szSectionNames), _pszConfigFile);

	if(0 == szSectionNames[0])
	{
		return false;
	}

	//	first one
	std::list<const char*> xCCharPtrList;
	xCCharPtrList.push_back(szSectionNames);

	for(int i = 0; i < sizeof(szSectionNames) - 2; ++i)
	{
		if(szSectionNames[i] == 0 &&
			szSectionNames[i + 1] == 0)
		{
			break;
		}

		if(szSectionNames[i] == 0)
		{
			xCCharPtrList.push_back(&szSectionNames[i] + 1);
		}
	}

	if(!xCCharPtrList.empty())
	{
		std::list<const char*>::const_iterator begIter = xCCharPtrList.begin();
		std::list<const char*>::const_iterator endIter = xCCharPtrList.end();

		for(begIter;
			begIter != endIter;
			++begIter)
		{
			const char* pszSection = *begIter;

			if(NULL == pszSection ||
				0 == pszSection[0])
			{
				continue;
			}

			NotifyItem item;
			char szMsgBuf[MAX_PATH] = {0};
			GetPrivateProfileString(pszSection, "message", "", szMsgBuf, sizeof(szMsgBuf), _pszConfigFile);
			if(szMsgBuf[0] == 0)
			{
				continue;
			}

			item.xNotification = szMsgBuf;
			item.dwNotifyInterval = GetPrivateProfileInt(pszSection, "interval", 5000, _pszConfigFile);
			item.bLooped = GetPrivateProfileInt(pszSection, "loop", 0, _pszConfigFile) != 0;
			item.dwColor = GetPrivateProfileInt(pszSection, "color", 0xffffffff, _pszConfigFile);

			m_xNotifyItemVector.push_back(item);
		}
	}

	return true;
}
コード例 #27
0
ファイル: base_ini.cpp プロジェクト: sunnet2007/vHome
int  CBaseIni::GetAllSectionNames( TCHAR * pBuf, int nBuflen )
{
	return GetPrivateProfileSectionNames( pBuf, nBuflen, m_strFileName.c_str() );
}