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
[46905] 파일 작성에 대해..... Handle FFFFFFFF로 나와요...
아야 [comaya79aya] 1141 읽음    2006-10-28 11:23
//---------- Main Form 에서의 조작 --------------
void __fastcall TForm1::OpenFileBtnMouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
    LoadLogForm->ShowModal();          // LoadLogForm을 불러냄
}

//---------  (SUB Form)두번째 LoadLogForm ------------------------

void __fastcall TLoadLogForm::FormShow(TObject *Sender)
{
    char    data[ 64];
    short    cnt;
    HANDLE   S_hcom;

   if( ListBox1->ItemIndex != ( -1)){
    ListBox1->Clear();
   }

S_hcom = CreateFile( S_full_path, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);

   //  ReadFile()를 다른 .CPP 작성해서 공유                       
   do{
      cnt = LogFile_LineInput( S_hcom, data, 64);   //지정파일에서 데이타 불러옴
      if ( cnt > 0){
    ListBox1->Items->Add( data);
    ListBox1->Selected[ ListBox1->Items->Count-1] = TRUE;
    ListBox1->SetFocus();
     }
   }while( cnt != 0);

  CloseHandle( S_hcom);
}

//----------- OpenDialog1를 불러냄 --------

void __fastcall TLoadLogForm::SearchBtnMouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
  short  cnt;
  long    len;
  char    *buf;
                       
  if( OpenDialog1->Execute() == TRUE) {
      Timer1->Enabled = FALSE;
      TStringList *list = new TStringList;
      if( ListBox1->ItemIndex != ( -1)){
        ListBox1->Clear();
       }
    list->LoadFromFile( OpenDialog1->FileName);
    for( cnt = 0; cnt < list->Count; cnt++){
                ListBox1->Items->Append( list->Strings[ cnt ]);
    }
    ListBox1->Selected[ ListBox1->Items->Count - 1] = TRUE;
    ListBox1->SetFocus();

    delete list;
  }
}

FormShow()에서 CreateFile() -> OpenFile() -> CloseHandle() 로 ListBox에 데이타( Default Data임)를 나열해놓고,
OpenDialog1->Execute()로 선택한 다른 데이타를 ListBox에 나열을 했습니다..
그런데 FormClose()해서 다시 FormShow()했는데 Default Data 핸들이 "FFFFFFFF"되어 Data를 불러올수가 없습니다..
파일오픈했으면 반드시 파일을 닫는 식을로 했는데...
다시 파일 오픈하니깐 핸들이 "FFFFFFFF"로 되어 열수가 없습니다...
무슨이유인지 도대체 알수가 없습니다...
아시는 분 설명이라도 좋으니 알려주세요...

+ -

관련 글 리스트
46905 파일 작성에 대해..... Handle FFFFFFFF로 나와요... 아야 1141 2006/10/28
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.