问答1 问答5 问答50 问答500 问答1000
网友互助专业问答平台

进游戏就弹出"没有找到XXXXX.ini文件"怎么解决啊?

提问网友 发布时间:2024-05-02 05:28
声明:本网页内容为用户发布,旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。
E-MAIL:1656858193@qq.com
2个回答
热心网友 回答时间:2024-05-18 02:44
  除了上面的方法 我告诉你一种方法 呵呵
  自己写!
  ini 文件是文本文件,中间的数据格式一般为:

  [Section1 Name]

  KeyName1=value1

  KeyName2=value2

  ...

  [Section2 Name]

  KeyName1=value1

  KeyName2=value2

  ini 文件可以分为几个 Section,每个 Section 的名称用 [] 括起来,在一个 Section 中,可以有很多的 Key,每一个 Key 可以有一个值并占用一行,格式是 Key=value,Win32 对 ini 文件操作的 api 中,有一部分是对 win.ini 操作的,有一部分是对用户自定义的 ini 文件操作的。Win.in 和 system.ini 是Windows的两个非常重要的初始化文件,Windows将用户所作的选择以及各种变化的系统信息记录在这两个文件中。System.ini 描述了系统硬件的当前状态,Win.ini 文件则包含了Windows 系统运行环境的当前配置。由于 Win.ini 文件的重要性和常用性,Win32 中有专门对 Win.ini 进行操作的 api,它们是:

  GetProfileInt - 从 Win.ini 文件的某个 Section 取得一个 key 的整数值,它的原形是:

  GetProfileInt(

  LPCTSTR lpAppName, // 指向包含 Section 名称的字符串地址

  LPCTSTR lpKeyName, // 指向包含 Key 名称的字符串地址

  INT nDefault // 如果 Key 值没有找到,则返回缺省的值是多少

  );

  如果 Key 值没有找到的话,返回值是 nDefault 指定的缺省值,如果 Key 中的值是负数,则返回 0,如果 Key 指定的是数字和字符串的混合,则返回数字部分的值,比如说 x=1234abcd,则返回 1234

  GetProfileString - 从 Win.ini 文件的某个 Section 取得一个 key 的字符串,它的原形是:

  GetProfileString(

  LPCTSTR lpAppName, // 指向包含 Section 名称的字符串地址

  LPCTSTR lpKeyName, // 指向包含 Key 名称的字符串地址

  LPCTSTR lpDefault, // 如果 Key 值没有找到,则返回缺省的字符串的地址

  LPTSTR lpReturnedString, // 返回字符串的缓冲区地址

  DWORD nSize // 缓冲区的长度

  );

  返回的字符串在缓冲区内,返回的 eax 值是返回的字符串的长度(不包括尾部的0)

  GetProfileSection - 从 Win.ini 文件中读出整个 Section 的内容,它的原形是:

  GetProfileSection(

  LPCTSTR lpAppName, // 指向包含 Section 名称的字符串地址

  LPTSTR lpReturnedString, // 返回数据的缓冲区地址

  DWORD nSize // 返回数据的缓冲区长度

  );

  WriteProfileSection - 将一个整个 Section 的值 写入 Win.ini 文件的指定 Section 中,它的原形是:

  WriteProfileSection(

  LPCTSTR lpAppName, // 指向包含 Section 名称的字符串地址

  LPCTSTR lpString // 要写入的数据的地址

  );

  如果 Win.ini 没有指定的 Section,API 会新建立一个并写入数据,如果已经存在,则先删除原来 Seciton 中所有的 Key 值然后写入新的。

  WriteProfileString - 将一个 Key 值写入 Win.ini 文件的指定 Section 中,它的原形是:

  WriteProfileString(

  LPCTSTR lpAppName, // 指向包含 Section 名称的字符串地址

  LPCTSTR lpKeyName, // 指向包含 Key 名称的字符串地址

  LPCTSTR lpString // 要写的字符串地址

  );

  如果 Win.ini 没有指定的 Section,API 会新建 Section,如果没有指定的 Key 则新建一个 Key 并写入数据,如果已经存在,则用字符串代替原来的值。

  以上的 Api 是对 Win.ini 操作的,当然对于我们来说,用的更多的是在程序运行的目录中建立自己的 ini 文件,如果需要对自己的 ini 文件操作,就要用到另一组 Api,这一组 api 和上面的很象,只要把上面一组的 Profile 换成 PrivateProfile(私有的)就可以了,参数中也相应的多了一个 ini 文件名的参数。例如 GetPrivateProfileInt、GetPrivateProfileSection、WritePrivateProfileString 等等, 下面分别介绍:

  GetPrivateProfileInt - 从 ini 文件的某个 Section 取得一个 key 的整数值,它的原形是:

  GetPrivateProfileInt(

  LPCTSTR lpAppName, // 指向包含 Section 名称的字符串地址

  LPCTSTR lpKeyName, // 指向包含 Key 名称的字符串地址

  INT nDefault // 如果 Key 值没有找到,则返回缺省的值是多少

  LPCTSTR lpFileName // ini 文件的文件名

  );

  中间参数和返回值的定义和 GetProfileInt 是一样的。

  GetPrivateProfileString - 从 ini 文件的某个 Section 取得一个 key 的字符串,它的原形是:

  GetPrivateProfileString(

  LPCTSTR lpAppName, // 指向包含 Section 名称的字符串地址

  LPCTSTR lpKeyName, // 指向包含 Key 名称的字符串地址

  LPCTSTR lpDefault, // 如果 Key 值没有找到,则返回缺省的字符串的地址

  LPTSTR lpReturnedString, // 返回字符串的缓冲区地址

  DWORD nSize // 缓冲区的长度

  LPCTSTR lpFileName // ini 文件的文件名

  );

  GetPrivateProfileSection - 从 ini 文件中读出整个 Section 的内容,它的原形是:

  GetPrivateProfileSection(

  LPCTSTR lpAppName, // 指向包含 Section 名称的字符串地址

  LPTSTR lpReturnedString, // 返回数据的缓冲区地址

  DWORD nSize // 返回数据的缓冲区长度

  LPCTSTR lpFileName // ini 文件的文件名

  );

  这个 api 可以读出整个 section 的内容,当你不知道 section 中有哪些 key 的时候,可以使用这个 api 将整个 section 读出后再处理。

  GetPrivateProfileSectionNames - 从 ini 文件中获得 Section 的名称,它的原形是:

  GetPrivateProfileSectionNames(

  LPTSTR lpszReturnBuffer, // 返回数据的缓冲区地址

  DWORD nSize // 返回数据的缓冲区长度

  LPCTSTR lpFileName // ini 文件的文件名

  );

  如果 ini 中有两个 Section: [sec1] 和 [sec2],则返回的是 'sec1',0,'sec2',0,0 ,当你不知道 ini 中有哪些 section 的时候可以用这个 api 来获取名称

  WritePrivateProfileSection - 将一个整个 Section 的内容入 ini 文件的指定 Section 中,它的原形是:

  WritePrivateProfileSection(

  LPCTSTR lpAppName, // 指向包含 Section 名称的字符串地址

  LPCTSTR lpString // 要写入的数据的地址

  LPCTSTR lpFileName // ini 文件的文件名

  );

  WritePrivateProfileString - 将一个 Key 值写入 ini 文件的指定 Section 中,它的原形是:

  WritePrivateProfileString(

  LPCTSTR lpAppName, // 指向包含 Section 名称的字符串地址

  LPCTSTR lpKeyName, // 指向包含 Key 名称的字符串地址

  LPCTSTR lpString // 要写的字符串地址

  LPCTSTR lpFileName // ini 文件的文件名

  );

  如果 ini 中没有指定的 Section,API 会新建 Section,如果没有指定的 Key 则新建一个 Key 并写入数据,如果已经存在,则用字符串代替原来的值。当指定的 ini 也不存在的时候,API 会自动建立一个新的文件,所以使用 ini 的好处是我们不必为了保存少量的数据涉及到文件操作,就连查找文件是否存在的操作都不必要。

  使用要点:

  在我们实际使用的时候,用的最多的是 GetPrivateProfileString 和 WritePrivateProfileString,但在对自定义 ini 文件操作的时候要注意的是,如果 lpFileName 指定的文件没有路径的话,Api 会去 Windows 的安装目录去找而不会在当前目录找,但是每次用到 ini 函数要获取当前路径显然太麻烦了,这里有一个变通的办法,你只要在 ini 文件名前面加上 .\ 就可以了,比如说要对本目录下的 user.ini 操作,那么文件名就是 '.\user.ini' 这样显然比较方便。另外,当你要把一个 Key 清除的时候,可以使用把 lpString 指向一个空的字符串然后使用 WritePrivateProfileString。当你要把一个 section 的全部内容清空的时候,也不必把 key 一个个的清除,可以使用把 lpString 指向一个空的字符串然后使用 WritePrivateProfileSection。

  一个操作ini文件的类:

  .h

  // IniFile.h: interface for the CIniReader class.

  //

  //////////////////////////////////////////////////////////////////////

  #if !defined(AFX_INIFILE_H__99976B4B_DBA1_4D1E_AA14_CBEB63042FD1__INCLUDED_)

  #define AFX_INIFILE_H__99976B4B_DBA1_4D1E_AA14_CBEB63042FD1__INCLUDED_

  #if _MSC_VER > 1000

  #pragma once

  #endif // _MSC_VER > 1000

  #include <afxcoll.h>

  class CIniReader

  {

  public:

  // method to set INI file name, if not already specified

  void setINIFileName(CString strINIFile);

  // methods to return the lists of section data and section names

  CStringList* getSectionData(CString strSection);

  CStringList* getSectionNames();

  // check if the section exists in the file

  BOOL sectionExists(CString strSection);

  // updates the key value, if key already exists, else creates a key-value pair

  long setKey(CString strValue, CString strKey, CString strSection);

  // give the key value for the specified key of a section

  CString getKeyValue(CString strKey,CString strSection);

  // default constructor

  CIniReader()

  {

  m_sectionList = new CStringList();

  m_sectionDataList = new CStringList();

  }

  CIniReader(CString strFile)

  {

  m_strFileName = strFile;

  m_sectionList = new CStringList();

  m_sectionDataList = new CStringList();

  }

  ~CIniReader()

  {

  delete m_sectionList;

  delete m_sectionDataList;

  }

  private:

  // lists to keep sections and section data

  CStringList *m_sectionDataList;

  CStringList *m_sectionList;

  CString m_strSection;

  long m_lRetValue;

  // ini file name

  CString m_strFileName;

  };

  #endif // !defined(AFX_INIFILE_H__99976B4B_DBA1_4D1E_AA14_CBEB63042FD1__INCLUDED_)

  .cpp

  // IniFile.cpp: implementation of the CIniReader class.

  //

  //////////////////////////////////////////////////////////////////////

  #include "stdafx.h"

  //#include "Readini.h"

  #include "INI.h"

  #include <afxcoll.h>

  #ifdef _DEBUG

  #undef THIS_FILE

  static char THIS_FILE[]=__FILE__;

  #define new DEBUG_NEW

  #endif

  //////////////////////////////////////////////////////////////////////

  // Construction/Destruction

  //////////////////////////////////////////////////////////////////////

  // Used to retrieve a value give the section and key

  CString CIniReader::getKeyValue(CString strKey,CString strSection)

  {

  char ac_Result[255];

  // Get the info from the .ini file

  m_lRetValue = GetPrivateProfileString((LPCTSTR)strSection,(LPCTSTR)strKey,

  "",ac_Result, 255, (LPCTSTR)m_strFileName);

  CString strResult(ac_Result);

  return strResult;

  }

  // Used to add or set a key value pair to a section

  long CIniReader::setKey(CString strValue, CString strKey, CString strSection)

  {

  m_lRetValue = WritePrivateProfileString (strSection, strKey,

  strValue, m_strFileName);

  return m_lRetValue;

  }

  // Used to find out if a given section exists

  BOOL CIniReader::sectionExists(CString strSection)

  {

  char ac_Result[100];

  CString csAux;

  // Get the info from the .ini file

  m_lRetValue = GetPrivateProfileString((LPCTSTR)strSection,NULL,

  "",ac_Result, 90, (LPCTSTR)m_strFileName);

  // Return if we could retrieve any info from that section

  return (m_lRetValue > 0);

  }

  // Used to retrieve all of the section names in the ini file

  CStringList* CIniReader::getSectionNames() //returns collection of section names

  {

  char ac_Result[2000];

  m_sectionList->RemoveAll();

  m_lRetValue = GetPrivateProfileSectionNames(ac_Result,2000,(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;

  }

  // Used to retrieve all key/value pairs of a given section.

  CStringList* CIniReader::getSectionData(CString strSection)

  {

  char ac_Result[2000]; //change size depending on needs

  m_sectionDataList->RemoveAll();

  m_lRetValue = GetPrivateProfileSection((LPCTSTR)strSection, ac_Result, 2000, (LPCTSTR)m_strFileName);

  CString strSectionData;

  for(int i=0; i<m_lRetValue; i++)

  {

  if(ac_Result[i] != '\0') {

  strSectionData = strSectionData + ac_Result[i];

  } else {

  if(strSectionData != "") {

  m_sectionDataList->InsertAfter(m_sectionDataList->GetTailPosition(),strSectionData);

  }

  strSectionData = "";

  }

  }

  return m_sectionDataList;

  }

  void CIniReader::setINIFileName(CString strINIFile)

  {

  m_strFileName = strINIFile;

  }
热心网友 回答时间:2024-05-18 02:44
1、重装游戏
2、上网找到那个文件,复制到游戏目录里
3、找个和你玩同一个游戏的人,让他把那个文件传给你,复制到游戏目录里

本文如未解决您的问题请添加抖音号:51dongshi(抖音搜索懂视),直接咨询即可。

得高血糖,高血脂的人,可有危险啊!平时要怎么保养。 769÷2的竖式计算? ...后面末尾有“战不休”三个字,请问这首歌叫什么名字啊? 求一首歌名,女生唱的!歌词好像有一句什么什么不休的, 是高潮的时候... 生也不休,死也不休是 什么歌曲 求助房颤,心率失常的治疗方法?及治愈后的情况? 驴脚放些黄豆去煲行吗 年轻人会出现手抖吗? 我母亲30几岁就手抖 爱打人 说话不洁 三价铁离子和硝酸根离子共存的条件下,是否显强氧化性 吸过烟的员工怎么管理? ...死亡,肇事司机是无驾驶证者,现老人无儿女无老人现在应赔偿多少... 为什么三价铁离子和硝酸根不会结合形成配离子? 峨山县化念镇最热闹的街道 两台电梯都是3✘11kw的电机,需要配多少平方电缆线? 我眼中的奇台二中,记叙文怎么写啊 奇台县天山社区有多少个小区组成的房子 以前和一个女生说:“你有男朋友一定要告诉我 一个男生在聊天时跟一个女生说:你有了男朋友告诉我一声。然后就不再... 泰拉瑞亚怎么有暗影之魂 泰拉瑞亚暗影之魂怎么得游戏攻略 六安尚百味旋转小火锅哪家好 苏轼与他的弟弟()已经六年不见心情抑郁不欢 一次性纸杯杯口的圈是干什么的 ...304不锈钢热水壶底部一圈跟刮痕一样的东西是什么 烧出的水对身体有... 丹参的功能主治叙述不正确的是什么 桐梓汽车总站到滕冲汽车总站有多少公里 大众途铠倒车影像显示不出来是什么原因? 2024年4月9日是吉日吗 求Did Ya Buddha’s Delight (BoA vs. Haley Bennett)的歌词~ 您好!请问制作proe 工程图模板时,标题栏中的第三视角投影标识的符号是怎... 农历1978年10月初九日子时出生的命运如何? i have already had lunch 就画线部分提问 i have lunch at【12 o’clock】画线提问 海拔1700米左右的山区能种萄陶吗? 我经常有想结束生命的想法,我该怎么办? 砀山到淮南的汽车需要多长时间? 新白娘子传奇人物年龄介绍 从郑州客运总站到省中医院坐几路公交车 如何做出好吃又营养的杂粮煎饼? 怎样做好成品进出仓呢?还有原材料的进出存
Top