Ini 文件类型名称 预期C++
Ini file Type name Expected C++
我希望你能帮助我解决这个编译错误。
我正在尝试测试从Embarcadero的官方文档网站上获取的代码,该网站旨在测试TIniFile
类。
但是我收到此错误:
Unit2.cpp(76): parsing: TCustomIniFile * _fastcall Form2::OpenIniFileInstance().
下面是我的代码:
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
#include <IniFiles.hpp>
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
void __fastcall TForm2::btStoreClickClick(TObject *Sender)
{
//First Edit of the file
/* Open an instance */
TCustomIniFile* SettingsFile = OpenIniFileInstance();
// Store current form properties to be used in later sessions.
try
{
SettingsFile->WriteInteger (Name, "Top", Top);
SettingsFile->WriteInteger (Name, "Left", Left);
SettingsFile->WriteInteger (Name, "Width", Width);
SettingsFile->WriteInteger (Name, "Height", Height);
SettingsFile->WriteString (Name, "Caption", Caption);
SettingsFile->WriteBool (Name, "InitMax", WindowState == wsMaximized );
}
catch(Exception* e)
{
}
delete SettingsFile;
}
void __fastcall TForm2::btLoadClick(TObject *Sender)
{
TCustomIniFile* SettingsFile = OpenIniFileInstance();
try
{
/*
Read all saved values from the last session. The section name
is the name of the form. Also use form's properties as defaults
*/
Top = SettingsFile->ReadInteger(Name, "Top", Top );
Left = SettingsFile->ReadInteger(Name, "Left", Left );
Width = SettingsFile->ReadInteger(Name, "Width", Width );
Height = SettingsFile->ReadInteger(Name, "Height", Height );
Caption = SettingsFile->ReadString (Name, "Caption", Caption);
// Load last window state
if (SettingsFile->ReadBool(Name, "InitMax", WindowState == wsMaximized))
WindowState = wsMaximized;
else
WindowState = wsNormal;
}
catch(Exception* e)
{
}
delete SettingsFile;
}
TCustomIniFile* __fastcall TForm2::OpenIniFileInstance()
{
TCustomIniFile* temp;
switch (RadioGroup1->ItemIndex)
{
case 0: {
/* Registry mode selected: in HKEY_CURRENT_USERSoftware... */
temp = new TRegistryIniFile(String("Software\") + Application->Title);
}
break;
case 1: {
/* Ini file mode selected */
temp = new TIniFile(ChangeFileExt(Application->ExeName, ".INI"));
}
break;
case 2: {
/* Memory based Ini file mode selected */
temp = new TMemIniFile(ChangeFileExt(Application->ExeName, ".INI"));
}
break;
default:
break;
}
return temp;
}
谢谢大家。 我已经找到了解决此问题的解决方案。我想念头文件#include<System.Win.Registry.hpp>
此致敬意。
相关文章:
- 来自 std::list 的迭代器 .end() 按预期返回"0xcdcdcdcdcdcdcdcd"但 .begin()
- 如何修复函数样式强制转换或类型构造的预期"("?
- 为什么我的 std::ref 无法按预期工作?
- '||'之前的预期主要表达
- 标记 '","' 之前的预期主表达式
- 将鼠标悬停在问题上时与预期">"相关的代码错误
- 未获得字符串中的预期输出
- 方法内部但循环仍得到预期的不合格id错误C++
- 为什么stream::忽略未按预期工作
- holeMenuProgram.cpp:38:1 错误:'}'令牌之前的预期主表达式
- C++嵌套的 If 语句中,它无法按预期工作
- Python ctypes:不会按预期加载 dll
- 'val' Arduino 错误代码之前的预期'('
- 错误 C2760:语法错误:映射迭代器上意外的标记"标识符",预期的";"
- 语句错误:"","标记之前有"预期的')'
- 内存错误低于在C++年实现埃拉托色尼筛分时的预期
- 编译 llvm 3.1 时,为什么会出现错误:在">"标记之前预期主表达式
- C++:"("令牌"之前有预期的非限定 id 指向类中成员函数的指针
- 为什么这个程序的输出不如预期
- Arduino 用于语句错误。令牌之前的预期')' ';'。如何解决这个问题?