File directory real-time monitoring method based on Windows API
By setting up a timeline and sliding window in the Windows API environment, and obtaining folder, I/O request, and event management data, a bottleneck index is generated. This solves the problems of event omission and poor compatibility in existing file directory monitoring technologies, and achieves efficient and stable real-time file directory monitoring.
Patent Information
- Application Number
- CN202511658385.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-13
- Publication Date
- 2026-02-17
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing real-time file directory monitoring methods based on Windows API suffer from high event omission rates and poor compatibility and integration. In particular, when using ReadDirectoryChangeW, FindFirstChangeNotification, and SHChangeNotifyRegister, it is difficult to achieve efficient and stable file directory monitoring.
By developing monitoring software, setting a unified timeline and sliding window, acquiring folder, I/O request, and event management data, generating bottleneck indices, and combining message loops and a three-dimensional coordinate system, we can monitor file directory changes in real time and adjust monitoring strategies based on bottleneck indices to ensure timely capture and processing of file directory changes.
It achieves efficient real-time monitoring, reduces event omissions, improves software compatibility and integration, supports retrospective analysis and troubleshooting, and reduces development complexity and resource consumption.
Smart Images

Figure CN121542229A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer system file directory monitoring technology, specifically a real-time file directory monitoring method based on Windows API. Background Technology
[0002] The Windows API (Application Programming Interface) is a collection of predefined functions, protocols, and tools meticulously crafted by Microsoft specifically for the Windows operating system. The Windows API acts as an intermediary between the operating system and applications, enabling developers to perform various low-level operations, such as creating windows, managing memory, and accessing hardware devices, without having to directly deal with complex system kernel code. The Windows API covers many areas, including user interface control, graphics rendering, file management, network communication, and system security. Its thousands of functions follow clear naming conventions, adhering to specific prefix rules, such as "Get" for retrieving information, "Set" for setting parameters, and "Create" for creating new objects. This allows developers to quickly understand the specific functions' functions, thus meeting development needs at different levels, from basic to advanced. The Windows API provides developers with powerful low-level control while, through its layered abstraction design, reducing the difficulty of system-level programming.
[0003] Many software applications developed on the Windows platform frequently require real-time dynamic information about directories and files within the system. Traditional file management systems typically achieve this by traversing all directories and files. However, this method only reflects the current directory or file status; when directories or files change, it cannot detect the changes in a timely manner, requiring a complete re-traversal. In the Windows operating system environment, there are three methods available for file monitoring: the first is a low-level driver-based solution, typically represented by Windows' built-in file system monitoring tool, Filemon; the second is hook technology. However, these two methods are relatively complex, and using them would result in low development efficiency if only basic directory and file monitoring needs are required. In addition, Windows provides a simpler message mechanism, which typically includes three sets of APIs for monitoring: ReadDirectoryChangeW, FindFirstChangeNotification, and SHChangeNotifyRegister.
[0004] Currently, traditional Windows API-based real-time file directory monitoring methods using ReadDirectoryChangeW and FindFirstChangeNotification require recursive monitoring of subdirectories. This results in complex path traversal code and is prone to missing events. On the other hand, when using SHChangeNotifyRegister to monitor file directories, the internally undocumented SHChangeNotifyRegister and SHChangeNotifyDeregister functions are exported as ordinal numbers in the Shell32.dll dynamic link library. When viewing Shell32.dll using the Depends tool included with VC, it is difficult to accurately locate these two functions. The Shell notification interface is easily affected by system version differences, security policy restrictions, and antivirus software blocking, making it difficult to integrate smoothly into various applications that need to capture system directory and file change information in real time, resulting in poor compatibility and integration. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a real-time file directory monitoring method based on Windows API, which has the advantages of high real-time monitoring efficiency and high software compatibility and integration, and solves the problems of high event omission rate and poor compatibility and integration of real-time file directory monitoring methods based on Windows API.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a method for real-time monitoring of file directories based on Windows API, comprising the following steps: Step 1: Develop monitoring software on the computer. After completing the initial setup of the monitoring software, obtain the management data of all folders, the management data of I / O requests, and the management data of triggered events, and classify them into folder datasets, request datasets, and event datasets. Step 2: Based on the requested dataset, evaluate the computer's processing performance and generate the corresponding bottleneck index. ; Step 3: The computer executes a message loop based on the event dataset, determines the file directory change status corresponding to the event triggered at the current time in real time, and synchronously notifies the monitoring software; Step 4: The monitoring software responds to changes in the file directory status, thereby updating the folder UI status or refreshing the folder data content; Step 5: Set a bottleneck threshold with a fixed value. Combined with the bottleneck index It will output corresponding operation suggestions.
[0007] Preferably, in step one, the file dataset includes the path identifier and size of each folder.
[0008] Preferably, in step one, the requested dataset includes the queue length, data block size, page swapping rate, page swapping-in rate, and operation type for each I / O request, wherein the operation type includes write and read.
[0009] Preferably, in step one, the event dataset includes the trigger time and type of each triggering event, wherein the event types include creation, modification, deletion, and renaming.
[0010] Preferably, in step one, the monitoring software initialization setup process is as follows: S11. Set a uniform timeline and divide it into several fixed durations. The sliding windows, each used to focus on the changes in a folder over time; S12. Create a message window It also uses SHChangeNotifyRegister to register message windows with the computer. It is used to obtain folder management data, I / O request management data, and trigger event management data. Each received data corresponds to a distribution on the timeline. S13, based on timeline and message window The system uses file datasets and event datasets to create a 3D coordinate system for visualizing historical change records across multiple folders. The axis is used to display timestamps. The timestamp recording format for computers and monitoring software is Unix epoch seconds. The axis is used to display folder path identifiers. The axis is used to display the size of the folder. The folder size record format for computers and monitoring software is KB. The path identifier of each folder is unique, and each folder corresponds to a historical trigger event baseline.
[0011] Preferably, in step two, the bottleneck index The calculation process is as follows: S21. Based on the requested dataset, extract the first... I / O request management data within the first sliding window, and the first... Within each sliding window, the queue length for each I / O request is marked as... , Indicates the first The total number of requests within the first sliding window will be the first... Within each sliding window, the data block size for each I / O request is marked as... , will the Within a sliding window, the page swapping rate during I / O request processing is marked as... , will the Within a sliding window, the page swapping rate during I / O request processing is marked as... Then, according to the operation type, the statistics are as follows: The total number of write requests within a sliding window is denoted as . Statistics The total number of read requests within a sliding window is denoted as . ; S22, Calculate the first Average queue length within a sliding window ; S23, Calculate the first Average data block size within a sliding window ; S24, Calculate the first Request operation frequency within a sliding window ; S25, Calculate the first Throughput within a sliding window ; S26. Based on S21-S25, calculate the number of... using a weighted method. Bottleneck index within a sliding window .
[0012] Preferably, in step three, the message loop process is as follows: S31. Specify a fixed value of SHCNE_MODIFY as the trigger event filter condition, and set WM_FILEMODIFY_NOTIFY as the message identifier for monitoring software to receive event notifications. S32. Based on the event dataset, extract the event management data triggered at the current time point, and determine the file directory change status corresponding to the event triggered at the current time point. The process is as follows: If the type of the event triggered at the current time is "create folder", the wParam parameter attached to WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. If the type of the event triggered at the current time is "modify folder", the wParam parameter attached to WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. If the type of the event triggered at the current time is "delete folder", the wParam parameter attached to WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. If the type of the event triggered at the current time is renaming a folder, the wParam parameter attached to WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. The wParam parameter attached to WM_FILEMODIFY_NOTIFY is unique; S33. Use PostMessage to send WM_FILEMODIFY_NOTIFY to the message window. .
[0013] Preferably, in step four, the response update process is as follows: If at the current time, the message window The wParam parameter attached to the received WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer of type 1. The path identifier and size of the corresponding folder are obtained through SHGetPathFromIDList, and the UI state of the corresponding folder is updated. If at the current time, the message window The wParam parameter attached to the received WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. The path identifier and size of the corresponding folder are obtained through SHGetPathFromIDList, and the data content of the corresponding folder is refreshed. If at the current time, the message window The wParam parameter attached to the received WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. The path identifier and size of the corresponding folder are obtained through SHGetPathFromIDList, and the data content of the corresponding folder is refreshed. If at the current time, the message window The wParam parameter attached to the received WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. The path identifier and size of the corresponding folder are obtained through SHGetPathFromIDList, and the UI state of the corresponding folder is updated.
[0014] Preferably, in step five, the bottleneck index ≥Bottleneck Threshold When this occurs, it indicates that the computer's processing power is insufficient within the corresponding sliding window, hindering the progress of file directory changes. It is recommended that the user delay I / O request operations and force the monitoring software to continuously update the folder management data, I / O request management data, and triggered event management data.
[0015] Preferably, in step five, the bottleneck index < Bottleneck Threshold When the time is right, it means that the computer's processing power is sufficient and the file directory changes smoothly within the corresponding sliding window. It is recommended that the user close the monitoring software. The procedure for shutting down monitoring software is as follows: S41, User clicks message window The close button; S42. Use SHChangeNotifyDeregister to unregister the message window to the computer. Cancel message window Monitoring permissions for folder management data, I / O request management data, and event triggering management data.
[0016] Compared with existing technologies, this invention provides a real-time file directory monitoring method based on Windows API, which has the following advantages: 1. This invention develops monitoring software, sets a unified timeline, and divides it into several fixed durations. A sliding window, where each sliding window is used to focus on the changes in a folder over time, and a message window is created. It also uses SHChangeNotifyRegister to register message windows with the computer. It is used to obtain folder management data, I / O request management data, and trigger event management data, classifying them into folder datasets, request datasets, and event datasets. Each received data corresponds to a distribution on a timeline, based on the timeline and message window. The system uses file datasets and event datasets to create a 3D coordinate system for visualizing historical change records across multiple folders. The axis is used to display timestamps. The timestamp recording format for computers and monitoring software is Unix epoch seconds. The axis is used to display folder path identifiers. The axis is used to display the size of the folder. The folder size record format for both the computer and the monitoring software is KB. Each folder has a unique path identifier. Each folder corresponds to a historical trigger event baseline, which supports backtracking analysis and helps with troubleshooting and performance optimization. The monitoring software does not need to query repeatedly, and real-time monitoring is highly efficient.
[0017] 2. This invention evaluates computer processing performance by requesting datasets and generates corresponding bottleneck indices. This accurately reflects the load trend of the computer system. The computer executes a message loop based on the event dataset, determining in real-time the file directory change status corresponding to the event triggered at the current time point, and simultaneously notifying the monitoring software. This ensures that any changes to the file directory are captured and processed immediately. The monitoring software responds based on the file directory change status, updating the folder UI status or refreshing the folder data content, thus reducing the bottleneck index. ≥Bottleneck Threshold At times, insufficient computer processing power hinders file directory changes, forcing monitoring software to continuously update folder management data, I / O request management data, and triggered event management data to prevent missing file directory change information, thus reducing the bottleneck index. < Bottleneck Threshold At this time, the computer's processing power is sufficient and the file directory change process is smooth. It is recommended that users close the monitoring software and achieve efficient real-time monitoring by listening to specific messages. The development complexity is low, the amount of code is small, and the software has high compatibility and integration. Attached Figure Description
[0018] Figure 1 This is a diagram illustrating the steps of the method of the present invention; Figure 2 This is a flowchart illustrating the file monitoring process based on the Windows API message mechanism of this invention. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] Example 1 Please see Figure 1 Based on the bottleneck index experimental data in Table 1 and the monitoring software experimental data in Table 2, this invention provides a real-time file directory monitoring method based on Windows API, comprising the following steps: Step 1: Develop monitoring software on the computer. After completing the initial setup of the monitoring software, obtain the management data of all folders, the management data of I / O requests, and the management data of triggered events, and classify them into folder datasets, request datasets, and event datasets. The file dataset includes the path identifier and size of each folder; The request dataset includes the queue length, data block size, page swapping rate, page swapping in rate, and operation type for each I / O request, where the operation type includes write and read. The event dataset includes the trigger time and type of each triggering event, where the event types include creation, modification, deletion, and renaming; Specifically, in a computer system, all actions involving writing or reading data to or from storage devices such as hard drives and solid-state drives are considered I / O operations. Operations such as creating, deleting, and renaming files and directories must be completed by issuing corresponding I / O requests through the operating system. The initial setup process for the monitoring software is as follows: S11. Set a uniform timeline and divide it into several fixed durations. The sliding windows, each used to focus on the changes in a folder over time; S12. Create a message window It also uses SHChangeNotifyRegister to register message windows with the computer. It is used to obtain folder management data, I / O request management data, and trigger event management data. Each received data corresponds to a distribution on the timeline. S13, based on timeline and message window The system uses file datasets and event datasets to create a 3D coordinate system for visualizing historical change records across multiple folders. The axis is used to display timestamps. The timestamp recording format for computers and monitoring software is Unix epoch seconds. The axis is used to display folder path identifiers. The axis is used to display the size of the folder. The folder size record format for computers and monitoring software is KB. The path identifier of each folder is unique. Each folder corresponds to a historical trigger event baseline, which supports backtracking analysis and helps with troubleshooting and performance optimization. Specifically, register the message window through the Windows API (SHChangeNotifyRegister). This enables real-time monitoring of file directory changes, eliminating the need for repeated queries and reducing system resource consumption. Step 2: Based on the requested dataset, evaluate the computer's processing performance and generate the corresponding bottleneck index. This accurately reflects the load trend of the computer system; Bottleneck Index The calculation process is as follows: S21. Based on the requested dataset, extract the first... I / O request management data within the first sliding window, and the first... Within each sliding window, the queue length for each I / O request is marked as... , Indicates the first The total number of requests within the first sliding window will be the first... Within each sliding window, the data block size for each I / O request is marked as... , will the Within a sliding window, the page swapping rate during I / O request processing is marked as... , will the Within a sliding window, the page swapping rate during I / O request processing is marked as... Then, according to the operation type, the statistics are as follows: The total number of write requests within a sliding window is denoted as . Statistics The total number of read requests within a sliding window is denoted as . ; S22, Calculate the first Average queue length within a sliding window Its expression is as follows:
[0021] S23, Calculate the first Average data block size within a sliding window Its expression is as follows:
[0022] S24, Calculate the first Request operation frequency within a sliding window Its expression is as follows:
[0023] S25, Calculate the first Throughput within a sliding window Its expression is as follows:
[0024] S26, Calculate the first Bottleneck index within a sliding window Its expression is as follows:
[0025] In the formula, This represents a standard value used to measure the average queue length. This represents the weight relative to the ratio of the standard value to the average queue length. This represents a standard value used to measure the average data block size. This indicates the weight relative to the ratio of the standard value to the average data block size. This represents a standard value used to measure the frequency of request operations. This indicates the weight relative to the ratio of the standard value to the frequency of requested operations. This represents a standard value used to measure throughput. This indicates the weighting of the ratio of the standard value to the throughput. Indicates the first Within a sliding window, the total page swapping rate when the computer processes I / O requests. This represents a standard value used to measure the total page rate. This indicates the weighting of the ratio of the standard value to the total page rate. , , , and All are constants. ; The following are the experimental data for the bottleneck index, as shown in Table 1:
[0026] In Table 1, the bottleneck index experimental data uses adjacent sliding windows 1 and 2 on the time axis as experimental subjects. The fixed duration of both sliding windows 1 and 2 is 0.005 seconds, which is used as the standard value to measure the average queue length. One, a standard value used to measure the average data block size. KB, a standard value used to measure the frequency of requested operations. Transactions / second, a standard value used to measure throughput. KB / s, a standard value used to measure the total page rate. Pages per second , , , , ; Bottleneck threshold Set to 0.9, based on the analysis, in the bottleneck index experimental data in Table 1, within sliding window 1, the computer's bottleneck index... < Bottleneck Threshold The first sliding window indicates that the computer's processing power is sufficient and file directory changes are proceeding smoothly. It is recommended that the user close the monitoring software. The second sliding window shows the computer's bottleneck index. > Bottleneck Threshold This indicates that within sliding window 2, the computer's processing performance is insufficient, hindering the progress of file directory changes. It is recommended that users delay I / O request operations and force the monitoring software to continuously update the folder management data, I / O request management data, and triggered event management data to avoid missing file directory change information. Step 3: The computer executes a message loop based on the event dataset, determines the file directory change status corresponding to the event triggered at the current time in real time, and synchronously notifies the monitoring software. This event-driven response ensures that any changes to the file directory can be captured and processed in a timely manner. The message loop process is as follows: S31. Specify a fixed value of SHCNE_MODIFY as the trigger event filter condition, and set WM_FILEMODIFY_NOTIFY as the message identifier for monitoring software to receive event notifications. S32. Based on the event dataset, extract the event management data triggered at the current time point, and determine the file directory change status corresponding to the event triggered at the current time point. The process is as follows: If the type of the event triggered at the current time is "create folder", the wParam parameter attached to WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. If the type of the event triggered at the current time is "modify folder", the wParam parameter attached to WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. If the type of the event triggered at the current time is "delete folder", the wParam parameter attached to WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. If the type of the event triggered at the current time is renaming a folder, the wParam parameter attached to WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. The wParam parameter attached to WM_FILEMODIFY_NOTIFY is unique; S33. Use PostMessage to send WM_FILEMODIFY_NOTIFY to the message window. ; Specifically, the main task of the monitoring software is to continuously check the message loop to determine whether the WM_FILEMODIFY_NOTIFY message has been received. Step 4: The monitoring software responds to changes in the file directory status, thereby updating the folder UI status or refreshing the folder data content; The response update process is as follows: If at the current time, the message window The wParam parameter attached to the received WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer of type 1. The path identifier and size of the corresponding folder are obtained through SHGetPathFromIDList, and the UI state of the corresponding folder is updated. If at the current time, the message window The wParam parameter attached to the received WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. The path identifier and size of the corresponding folder are obtained through SHGetPathFromIDList, and the data content of the corresponding folder is refreshed. If at the current time, the message window The wParam parameter attached to the received WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. The path identifier and size of the corresponding folder are obtained through SHGetPathFromIDList, and the data content of the corresponding folder is refreshed. If at the current time, the message window The wParam parameter attached to the received WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer. The path identifier and size of the corresponding folder are obtained through SHGetPathFromIDList, and the UI state of the corresponding folder is updated. Specifically, once the monitoring software starts listening and enters the continuous message loop waiting phase, it will immediately respond upon receiving the WM_FILEMODIFY_NOTIFY message, recognizing it as a notification about folder changes. Through the closed-loop mechanism of "checking the message loop - processing the message - continuing to check", it can ensure that all changes to the file directory are monitored without any omissions. The following is the experimental data of the monitoring software, as shown in Table 2:
[0027] In Table 2, the experimental data of the monitoring software were selected from the events triggered at time point a and time point b as experimental subjects. Step 5: Set a bottleneck threshold with a fixed value. Combined with the bottleneck index It outputs corresponding operation suggestions, improving the intelligence and adaptability of the computer system. Bottleneck Index ≥Bottleneck Threshold When this occurs, it indicates that the computer's processing performance is insufficient within the corresponding sliding window, hindering the progress of file directory changes. It is recommended that the user delay I / O request operations and force the monitoring software to continuously update the folder management data, I / O request management data, and triggered event management data. Bottleneck Index < Bottleneck Threshold When the time is right, it means that the computer's processing power is sufficient and the file directory changes smoothly within the corresponding sliding window. It is recommended that the user close the monitoring software. The procedure for shutting down monitoring software is as follows: S41, User clicks message window The close button; S42. Use SHChangeNotifyDeregister to unregister the message window to the computer. Cancel message window Monitoring permissions for folder management data, I / O request management data, and event triggering management data.
[0028] In this embodiment, the monitoring software is developed based on the Windows API, which has strong compatibility and is suitable for various Windows system environments. It uses system functions such as SHGetPathFromIDList to obtain folder information, ensuring the accuracy and consistency of data acquisition. It also supports starting and stopping monitoring as needed, allowing users to flexibly control monitoring behavior and avoid unnecessary resource consumption.
[0029] Example 2 Please see Figure 2 This invention provides a method for real-time monitoring of file directories based on Windows API, comprising the following steps: Step A: Create a Win32-based application, include the header file shlobj_core.h in the code and load Shell32.dll, importing the SHChangeNotifyRegister and SHChangeNotifyDeregister functions by ordinal import; The prototype of the SHChangeNotifyRegister function is as follows: ULONG SHChangeNotifyRegister(HWND hwnd, int fSource, LONG fEvents, intcEntries, SHChangeNotifyEntry*pfsne); The prototype of the SHChangeNotifyDeregister function is as follows: BOOL SHChangeNotifyDeregister(ULONG ulID); Step B: Call SHChangeNotifyRegister to register file monitoring messages. The SHChangeNotifyRegister function returns the registered message ID. When you no longer need to monitor file change messages, you can unregister using the same ID. Hwnd is used to set the window handle of this program; fEvents is used to represent the events to be captured, and is set to SHCNE_ALLEVENTS; Step C: Define the file modification message macro (WM_FILEMODIFY_NOTIFY), denoted as #define WM_FILEMODIFY_NOTIFY 0x8888; Define a message handling function, denoted as void FileModifyNotify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); In the message loop queue WndProc, listen for #define WM_FILEMODIFY_NOTIFY 0x8888, and then pass the listened message to FileModifyNotify for processing; Step D: Process the FileModifyNotify message. The message value represents the following meaning: SHCNE_MKDIR indicates a newly created folder; SHCNE_RMDIR indicates that the folder has been deleted; SHCNE_CREATE indicates the creation of a new file; SHCNE_DELETE indicates file deletion; The SHGetPathFromIDList function can be used to obtain relevant information about the corresponding file and folder for further processing. If the user closes the message window, the monitoring message is unregistered by calling SHChangeNotifyDeregister, with the parameter value being the ID saved during registration.
[0030] In this embodiment, in the Windows system, there are two implementations of the SHChangeNotifyRegister function with the same name but different parameters. The one specifically designed for file monitoring scenarios on mobile devices has the following function prototype definition: BOOL WINAPI SHChangeNotifyRegister(HWND hwnd, SHCHANGENOTIFYENTRY *pshcne); The real-time file directory monitoring mechanism based on Windows API has significant advantages. Developers only need to specify the target window to receive messages to include that window in the system's operation monitoring chain. When a file change is detected, the system will automatically send a corresponding notification message to the registered window. There is no need to write drivers or set up system-level hooks. Efficient real-time monitoring can be achieved simply by listening to specific messages. It not only has low development complexity and less code, but also perfectly adapts to the Windows environment.
[0031] The threshold is set to facilitate comparison. The size of the threshold depends on the amount of sample data and the number of bases set by those skilled in the art for each set of sample data; as long as it does not affect the ratio between the parameter and the quantized value, it is acceptable.
[0032] The above formulas are all derived from software simulation using a large amount of data and are selected to be close to the actual values. The coefficients in the formulas are set by those skilled in the art according to the actual situation. The above description is only a preferred embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any equivalent substitutions or changes made by those skilled in the art within the technical scope disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the protection scope of the present invention.
Claims
1. A Windows API-based file directory real-time monitoring method, characterized in that, The method comprises the following steps: Step one: developing monitoring software in a computer, obtaining management data of all folders, management data of I / O requests and management data of triggering events after completing initialization setting of the monitoring software, and classifying to form a folder data set, a request data set and an event data set; Step two: According to the request data set, evaluate the processing performance of the computer, and generate the corresponding bottleneck index ; Step three: the computer executes a message loop according to the event data set, and judges a file directory change state corresponding to a triggering event at a current time point in real time, and synchronously notifies the monitoring software; Step four: the monitoring software responds according to the file directory change state, and then updates a folder UI state or refreshes folder data content; Step five: set a fixed-value bottleneck threshold , combined with the bottleneck index , output the corresponding operation suggestion.
2. The Windows API-based file directory real-time monitoring method of claim 1, wherein: In the step one, the file data set comprises a path identifier and a size of each folder.
3. The Windows API-based file directory real-time monitoring method of claim 2, wherein: In the step one, the request data set comprises a queue length, a data block size, a swap-out page rate, a swap-in page rate and an operation type of each I / O request, wherein the operation type comprises writing and reading.
4. The Windows API-based file directory real-time monitoring method of claim 3, wherein: In the step one, the event data set comprises a triggering time point and a type of each triggering event, wherein the event type comprises new folder, modified folder, deleted folder and renamed folder.
5. The Windows API-based file directory real-time monitoring method of claim 4, characterized in that: In the step one, the initialization setting process of the monitoring software is as follows: S11, set a unified timeline, and divide a plurality of fixed time lengths sliding windows, each sliding window is used to focus on the change features of the file folder over time; S12, creating a message window and registering the message window with the computer using SHChangeNotifyRegister for obtaining management data of the folder, management data of I / O requests and management data of triggering events, each of the received data corresponding to a distribution on the timeline; S13, based on timeline, message window , file data set and event data set, draw three-dimensional coordinate system, for visualizing multi-folder history change record, wherein, axis for displaying timestamp, timestamp record format of computer and monitoring software is Unix epoch second, axis for displaying folder path identification, axis for displaying folder size, folder size record format of computer and monitoring software is KB, path identification of each folder has uniqueness, each folder corresponds to a history trigger event baseline.
6. The Windows API-based file directory real-time monitoring method of claim 5, wherein: In the step two, the bottle neck index The calculation process is as follows: S21. Based on the requested dataset, extract the first... I / O request management data within the first sliding window, and the first... Within each sliding window, the queue length for each I / O request is marked as... , Indicates the first The total number of requests within the first sliding window will be the first... Within each sliding window, the data block size for each I / O request is marked as... , will the Within a sliding window, the page swapping rate during I / O request processing is marked as... , will the Within a sliding window, the page swapping rate during I / O request processing is marked as... Then, according to the operation type, the statistics are as follows: The total number of write requests within a sliding window is denoted as . Statistics The total number of read requests within a sliding window is denoted as . ; S22, calculate the average queue length in the first sliding window ; S23, calculate the average data block size within the ; S24, calculate the request operation frequency in the ; S25, calculate the throughput in the ; S26、According to S21-S25, the bottleneck index in the first sliding window is calculated by a weighted manner .
7. The Windows API-based file directory real-time monitoring method of claim 6, wherein: In the step three, the message loop process is as follows: S31, setting SHCNE_MODIFY with a fixed numerical value as a triggering event filtering condition, and setting WM_FILEMODIFY_NOTIFY as a message identifier, which is used for the monitoring software to receive event notification; S32, extracting event management data triggered at a current time point according to the event data set, and judging a file directory change state corresponding to a triggering event at the current time point, and the process is as follows: if the type of the triggering event at the current time point is new folder, the wParam parameter in the WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer one; if the type of the triggering event at the current time point is modified folder, the wParam parameter in the WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer two; if the type of the triggering event at the current time point is deleted folder, the wParam parameter in the WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer three; if the type of the triggering event at the current time point is renamed folder, the wParam parameter in the WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer four; the wParam parameter in the WM_FILEMODIFY_NOTIFY is unique; S33, use PostMessage to deliver WM_FILEMODIFY_NOTIFY to message window .
8. The Windows API-based file directory real-time monitoring method of claim 7, wherein: In the step four, the response update process is as follows: If the current time point, the message window The wParam parameter in the received WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer, and the path identifier and size of the corresponding folder are obtained by SHGetPathFromIDList to update the UI state of the corresponding folder. If the current time point, the message window The wParam parameter in the received WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer two, the path identifier and size of the corresponding folder are obtained by SHGetPathFromIDList, and the data content of the corresponding folder is refreshed. If the current time point, the message window The wParam parameter in the received WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer three, the path identifier and size of the corresponding folder are obtained by SHGetPathFromIDList, and the data content of the corresponding folder is refreshed. If the current time point, the message window The wParam parameter in the received WM_FILEMODIFY_NOTIFY is a 32-bit unsigned integer four, the path identifier and size of the corresponding folder are obtained by SHGetPathFromIDList, and the UI state of the corresponding folder is updated.
9. The Windows API-based file directory real-time monitoring method of claim 8, wherein: The step five, the bottle neck index ≥ the bottle neck threshold value When the bottle neck index is greater than the bottle neck threshold value, it indicates that the processing performance of the computer is insufficient within the corresponding sliding window, the file directory change progress is blocked, the user is suggested to delay the I / O request operation, and the monitoring software is forced to continuously update the management data of the folder, the management data of the I / O request and the management data of the trigger event.
10. The Windows API-based file directory real-time monitoring method of claim 9, wherein: The step five, the bottle neck index <Bottleneck threshold When the file directory change progress is smooth, the computer processing performance is sufficient in the corresponding sliding window, and the user is suggested to close the monitoring software. The process of closing the monitoring software is as follows: S41, the user clicks the message window of the closing button; S42, de-registering the message window from the computer using SHChangeNotifyDeregister de-registering the message window monitoring permissions for management data of the folder, management data of I / O requests, and management data of trigger events.