簡體   English   中英

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_USER\Software\... */
            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>

此致。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM