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
[16821] Re:[질문]탐색기 같은 프로그램으로 짜려면
새더군 [] 2003 읽음    2002-03-26 17:10
안녕하세요 ^^;

윈도우에는 이런 목적으로 사용되는 Notification Object 란게 있습니다.

FindFirstChangeNotification()
FindNextChangeNotification()
FindCloseChangeNotification()

자세한 사항은 MSDN 이나 기타 도움말 찾아보시구요..
MSDN 에 있는 예제 올려 드립니다.

그럼 좋은 하루 되세요..

---------------------------------------------------------------

DWORD dwWaitStatus;
HANDLE dwChangeHandles[2];

// Watch the C:\WINDOWS directory for file creation and
// deletion.

dwChangeHandles[0] = FindFirstChangeNotification(
    "C:\\WINDOWS",                 // directory to watch
    FALSE,                         // do not watch the subtree
    FILE_NOTIFY_CHANGE_FILE_NAME); // watch file name changes

if (dwChangeHandles[0] == INVALID_HANDLE_VALUE)
    ExitProcess(GetLastError());

// Watch the C:\ subtree for directory creation and
// deletion.

dwChangeHandles[1] = FindFirstChangeNotification(
    "C:\\",                        // directory to watch
    TRUE,                          // watch the subtree
    FILE_NOTIFY_CHANGE_DIR_NAME);  // watch dir. name changes

if (dwChangeHandles[1] == INVALID_HANDLE_VALUE)
    ExitProcess(GetLastError());

// Change notification is set. Now wait on both notification
// handles and refresh accordingly.

while (TRUE)
{

    // Wait for notification.

    dwWaitStatus = WaitForMultipleObjects(2, dwChangeHandles,
        FALSE, INFINITE);

    switch (dwWaitStatus)
    {
        case WAIT_OBJECT_0:

        // A file was created or deleted in C:\WINDOWS.
        // Refresh this directory and restart the
        // change notification. RefreshDirectory is an
        // application-defined function.

            RefreshDirectory("C:\\WINDOWS")
            if ( FindNextChangeNotification(
                    dwChangeHandles[0]) == FALSE )
                ExitProcess(GetLastError());
            break;

        case WAIT_OBJECT_0 + 1:

        // A directory was created or deleted in C:\.
        // Refresh the directory tree and restart the
        // change notification. RefreshTree is an
        // application-defined function.

            RefreshTree("C:\\");
            if (FindNextChangeNotification(
                    dwChangeHandles[1]) == FALSE)
                ExitProcess(GetLastError());
            break;

        default:
            ExitProcess(GetLastError());
    }
}

+ -

관련 글 리스트
16814 [질문]탐색기 같은 프로그램으로 짜려면 공부중 1039 2002/03/26
16821     Re:[질문]탐색기 같은 프로그램으로 짜려면 새더군 2003 2002/03/26
16817     Re:[질문]탐색기 같은 프로그램으로 짜려면 만해 1129 2002/03/26
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.