C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[76250] C++Builder 개발자 안내서 문의사항
빌더 신참 [] 996 읽음    2022-02-04 18:32
안녕하세요.

C++Builder 6을 가지고 프로그래밍을 시작한 사람입니다.
1280p의 개발자 안내서를 다운로드 받아 소스를 입력하며
공부하고 있는데요.
왜 안될까요!!

1. 폼의 생성자 및 OnClose 이벤트 핸들러의 쓰기 값에 있는 ini 파일로부터 구성 정보를 읽는 예제입니다. (실행)
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
        TIniFile *ini;
        ini = new TIniFile( ChangeFileExt ( Application->ExeName, ".INI" ) );
        Top = ini->ReadInteger( "Form", "Top", 100 );
        Left = ini->ReadInteger( "Form", "Left", 100 );
        Caption = ini->ReadString( "Form", "Caption", Default Caption" );
        ini->ReadBool( "Form", "InitMax", false ) ?
                WindowState = wsMaximized : WindowState = wsNormal;

        delete ini;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
        TIniFile *ini;
        ini = new TIniFile(ChangeFileExt( Appllication->ExeName, ".INI" ) );
        ini->WriteInteger( "Form", "Top", Top );
        ini->WriteInteger( "Form", 'Left", Left );
        ini->WriteString( "Form", "Caption", Caption );
        ini->WriteBool( "Form", "InitMax", WindowState == wsMaximized );

        delete ini;
}
이렇게 작성하고 Alt + F9 눌렀는데 왜 에러가 날까요. (다른 것도 실행)



2. TRegistryIniFile 사용
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
AnsiString GetRegitryValue(AnsiString KeyName)
{
        AnsiString S;
        TRegistry *Registry = new TRegistry(KEY_READ);
        try
        {
                Registry->Rootkey = HKEY_LOCAL_MACHINE;
                Registry->OpenKey(KeyName, false);
                s = Registry->ReadString("VALUE1");
        }
        __finally
        {
                delete Registry;
        }
        return S;
}

이것도 역시 에러가 납니다. 개발자 안내서를 가지고 공부하려고 했는데 뜻대로 안되네요.

에러가 나는 이유와 해결 방법을 알려주시면 감사드리겠습니다.

+ -

관련 글 리스트
76250 C++Builder 개발자 안내서 문의사항 빌더 신참 996 2022/02/04
76251     Re:C++Builder 개발자 안내서 문의사항 김시환 1066 2022/02/07
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.