English 中文(简体)
利用CeGetFileNotificationInfo
原标题:Using CeGetFileNotificationInfo

我有一个Windows Mobile 6.5应用程序,试图监测一个更改档案。 如果我操作以下法典,那么我只收到关于临时档案变更的通知。

参考,Im 采用Windows Mobile 6.5 专业CEOS 5.2.23090.5.3.0。 而且,我与Windows Mobile 6.1专业 CEOS 5.2.21051.1.6.4有着同样的问题。

#include <vector>

int _tmain( int argc, _TCHAR* argv[] )
{
    HANDLE change = ::FindFirstChangeNotification( 
        argv[ 1 ],
        FALSE,
        FILE_NOTIFY_CHANGE_CEGETINFO |
        FILE_NOTIFY_CHANGE_LAST_WRITE |
        FILE_NOTIFY_CHANGE_LAST_ACCESS |
        FILE_NOTIFY_CHANGE_CREATION |
        FILE_NOTIFY_CHANGE_ATTRIBUTES |
        FILE_NOTIFY_CHANGE_SIZE );

    if( INVALID_HANDLE_VALUE != change )
    {
        while( WAIT_OBJECT_0 == ::WaitForSingleObject( change, INFINITE ) )
        {
            NKDbgPrintfW( L"Change detected
" );
            DWORD returned = 0;
            DWORD available = 0;
            if( ::CeGetFileNotificationInfo( change,
                                             0,
                                             NULL,
                                             0,
                                             &returned,
                                             &available ) )
            {
                std::vector< BYTE > buffer( available );
                if( ::CeGetFileNotificationInfo( change,
                                                 0,
                                                 &buffer.front(),
                                                 buffer.size(),
                                                 &returned,
                                                 &available ) )
                {
                    BYTE* current = &buffer.front();

                    const FILE_NOTIFY_INFORMATION* info =
                    reinterpret_cast< const FILE_NOTIFY_INFORMATION* >( current );

                    for( current;
                         NULL != current && info->NextEntryOffset > 0;
                         current += info->NextEntryOffset )
                    {
                        info = reinterpret_cast< const FILE_NOTIFY_INFORMATION* >( current );  
                        NKDbgPrintfW( L"	%s: %#08x
", info->FileName, info->Action );
                    }

                }
            }      
            ::FindNextChangeNotification( change );
        }
        ::FindCloseChangeNotification( change );
    }
    return 0;
}

上文举例说明的产出是:

Change detected
    667F.tmp: 0x00000003
    667F.tmp: 0x00000003
    667F.tmp: 0x00000003
    667F.tmp: 0x00010000

如果我期望:

Change detected
    Foo.txt: 0x00000003
    Foo.txt: 0x00000003
    Foo.txt: 0x00000003
    Foo.txt: 0x00010000

我需要做些什么来改变这一功能?

Thanks, PaulH

问题回答

来自MSDN:

For an OS that uses extensive caching, detection occurs only when the cache is sufficiently flushed.

More info: https://msdn.microsoft.com/en-US/library/ee490599(v=winendo.60).aspx





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签