高分(100分)~~~~~,求api函数SHChangeNotifyRegister在vc中如何声明和使用

freecharry 2003-10-20 02:34:09
我有vb与delphi的例子,但是不知在vc中如何使,别名怎么用,谢谢!
...全文
116 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yaoha2003 2003-10-20
  • 打赏
  • 举报
回复
我的MSDN上面就没有这个函数,它干嘛用的?谢谢了
yifeng_ch 2003-10-20
  • 打赏
  • 举报
回复
关注。
leon_z 2003-10-20
  • 打赏
  • 举报
回复
喔,你们MSDN中有吗,是2002以后的版本吧,呵呵,我用的是2001版,中间没有这个FUNCTION
leon_z 2003-10-20
  • 打赏
  • 举报
回复
你指的是如果在VC6中调用吧

HINSTANCE gDll=NULL; //全局变量

typedef VOID (WINAPI * SHChangeNotifyRegister)(LONG wEventId,UINT uFlags,LPCVOID dwItem1,LPCVOID dwItem2);

SHChangeNotifyRegister pSHChangeNotifyRegister = NULL;



gDll=LoadLibrary("shell32.DLL");

pSHChangeNotifyRegister=(SHChangeNotifyRegister)GetProcAddress(gDll,"SHChangeNotifyRegister");




然后象用一般的函数那样用pSHChangeNotifyRegister,它是一个函数指针



(注:这里我假设SHChangeNotifyRegister的参数是这几个,如是不是的话,你可以从你的VB例子中找到)


freecharry 2003-10-20
  • 打赏
  • 举报
回复
wuxfBrave:

你提供的这个我在msdn中也看到了,但是关于这个函数的使用的例子我搜不到,不知你有没有这方面的资料,谢谢·
wuxfBrave 2003-10-20
  • 打赏
  • 举报
回复
SHChangeNotifyRegister Function

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

Registers a window that receives notifications from the file system or shell.

Syntax

ULONG SHChangeNotifyRegister( HWND hwnd,
int fSources,
LONG fEvents,
UINT wMsg,
int cEntries,
SHChangeNotifyEntry *pfsne
);
Parameters

hwnd
Handle to the window that receives the change or notification messages.
fSources
One or more of the following flags that indicates the type of events for which to receive notifications.
SHCNRF_InterruptLevel
Interrupt level notifications from the file system.
SHCNRF_ShellLevel
Shell level notifications from the shell.
SHCNRF_RecursiveInterrupt
Interrupt events on the whole subtree. This flag must be combined with the SHCNRF_InterruptLevel flag. When using this flag, notifications must also be made recursive by setting the fRecursive member of the corresponding SHChangeNotifyEntry structure referenced by pfsne to TRUE.
SHCNRF_NewDelivery
Messages received use shared memory. Call SHChangeNotification_Lock to access the actual data. Call SHChangeNotification_Unlock to release the memory when done.
fEvents
Change notification events for which to receive notification.
wMsg
Message to be posted to the window procedure.
cEntries
Number of entries in the pfsne array.
pfsne
Array of SHChangeNotifyEntry structures that contain the notifications. This array should always be set to one when calling SHChangeNotifyRegister or SHChangeNotifyDeregister will not work properly.
Return Value

Returns a positive integer registration identifier (ID). Returns zero if out of memory or in response to invalid parameters.

Remarks

When a relevant file system event takes place and the hwnd parameter is not NULL, then the message indicated by wMsg is posted to the specified window. Otherwise, if the pfsne parameter is not NULL, then that notification entry is called.

前言: 最近学Windows shell外壳,偶然发现了SHChangeNotifyRegister这个神奇的函数,于是便用它写了个例程。 本帖不少思想来自帖子:未公开Windows API SHChangeNotifyRegister实现文件监控 基本介绍: 在Windows实现文件监控有三种方法,第一种是“虚拟文件系统驱动”方法,如windows 下的filemon,网上有很多关于他的析。第二种方法是“HOOK API”方法,钩子技术。第三种方法是“消息机制”,从windows的文件通知消息获取系统的文件操作。但是这是文件操作完成以后,才通知的。所以只能进行监视监视,不能进行完全的控制。而消息机制当,也有三种方法,(1)通过使用“未公开API SHChangeNotifyRegister 实现”;(2)通过 FindFirstChangeNotification 实现;(3)通过 ReadDirectoryChangesW 实现。第(2)(3)种方法只能针对一个在指定目录或子目录下发生的更改符合过滤条件时,进行监视。 而现在,易语言 大部消息机制监视文件使用FindFirstChangeNotification或ReadDirectoryChangesW + 线程实现的(例如:文件监控精灵 - 监控目录文件新建删除重命名修改 ),该方法效率较低,而且如果很多文件在短时间内发生变更,则有可能会丢失部通知,且监视的文件信息有限,所以,我写了一份使用SHChangeNotifyRegister来监视文件的例程。 特性: 代码几乎是全注释,清晰明了: 程序很多命令和常量是翻译自MSDN,规范程度高: 监视多种消息(比如USB接口信息),很多问题一个命令即可解决:

16,466

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧