|
안녕하세요. heredity입니다.
질문하신 내용중 3번째 줄에 "근데 레지쪽에서..."가 있던데, 레지스트리를 말씀하신는 건가요 ?
Registry라고 가정하고 글을 씁니다. ^_^;;
C++ Builder 도움말을 보시면 아시겠지만 TRegistry의 Method엔
값을 읽기위한 Metohd들과
ReadBinaryData
ReadBool
ReadCurrency
ReadDate
ReadDateTime
ReadFloat
ReadInteger
ReadString
ReadTime
값을 쓰기위한 Method들이 준비되어 있으므로
WriteBinaryData
WriteBool
WriteCurrency
WriteDate
WriteDateTime
WriteExpandString
WriteFloat
WriteInteger
WriteString
WriteTime
수형에 알맞는 Method 사용하시기 바랍니다.
님의 경우엔 TComboBox의 ItemIndex를 저장 했다가
프로그램 실행시 Form의 Constructor에서 저장해둔 값을
읽어와 TComboBox의 ItemIndex에 대입해 주면 문제가 해결 될 것 같군요.
행복하세요.
//---------------------------------------------------------------------------
#include <vcl.h>
#include <registry.hpp>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
AnsiString asMyKey = "\\Software\\Microsoft\\Windows\\MyTest";
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
}
//---------------------------------------------------------------------------
// 기능 : TRegistry에 문자열 및 숫자 쓰기
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TRegistry *pReg = new TRegistry();
try
{
pReg->RootKey = HKEY_CURRENT_USER;
if( pReg->OpenKey( asMyKey, true ) ) {
pReg->WriteString( "TEST1", ParamStr( 0 ) );
pReg->WriteInteger( "TEST2", ComboBox1->ItemIndex );
pReg->CloseKey();
ShowMessage( "자료 저장 성공" );
}
}
__finally
{
delete pReg;
}
}
//---------------------------------------------------------------------------
// 기능 : Button1::OnClick Event에의해 저장된 문자열 및 숫자 읽기
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
TRegistry *pReg = new TRegistry();
try
{
pReg->RootKey = HKEY_CURRENT_USER;
if( pReg->OpenKey( asMyKey, false ) ) {
AnsiString asStr = pReg->ReadString( "TEST1" );
int nValue = pReg->ReadInteger( "TEST2" );
if( (nValue >= -1) & (nValue < ComboBox1->Items->Count) ) {
ComboBox1->ItemIndex = nValue;
}
ShowMessage( asStr + " " + nValue );
pReg->CloseKey();
}
}
__finally
{
delete pReg;
}
}
--------------------------------------
실론티한잔 님이 쓰신 글 :
: Comport와 baudrate 값을 설정해 주는것은 콤보 박스로 만들어서
:
: 창이 없어져도 레지쪽에 저장되게 만들었습니다
:
: 근데 레지쪽에서 받아주는값이 int형인데 baud야 원래 값이 숫자라 별무리가 없는데
:
: Com쪽에서 자꾸 걸리네요 아무리 string형으로 설정해 주긴 했지만 자꾸 Int형만 원하니
:
: 어찌해야 할까요 좋은 의견 있으신 분이나 도움 주실분 답글 남겨 주시면 아주 많이
:
: 복받으실겁니다
|