难问题,请高手进来回答,关于SHChangeNotifyRegister(200分)

S

sowen

Unregistered / Unconfirmed
GUEST, unregistred user!
我做了一个component,调用SHChangeNotifyRegister来监视硬盘文件等的变化<br>其中有一个属性path来设置目录,然后注册监视。<br>单独调用的时候非常正常,没有异常。<br><br>可是当我这样调用的时候却有问题了<br><br>&nbsp; shn:Array of TShellNotification;<br><br>begin<br>&nbsp; total:=Drivers.Count;<br>&nbsp; //Drivers保存了所有驱动器 &nbsp; <br><br>&nbsp; If total&gt;0 then begin<br>&nbsp; &nbsp; SetLength(shn,total);<br>&nbsp; &nbsp; for i:=0 to total-1 do begin<br>&nbsp; &nbsp; &nbsp; shn:=TShellNotification.Create(Self);<br>&nbsp; &nbsp; &nbsp; shn.WatchSubTree :=true;<br>&nbsp; &nbsp; &nbsp; shn.Path :=lowercase(Drivers.Strings);<br><br>&nbsp; &nbsp; &nbsp; shn.WatchEvents :=[*];<br><br>&nbsp; &nbsp; &nbsp; shn.Active :=true;<br>//通过watch就在这行出错<br>end;<br><br>而Actvie只是触发注册,而在那个组件里出错在<br><br>&nbsp; &nbsp; SHILCreatefromPath( PChar(fPath), Addr(Pidl), Attributes); <br>&nbsp; &nbsp; NotifyRecord^.pidlPath := Pidl; &nbsp;//出错在这里!<br>&nbsp; &nbsp; NotifyRecord^.bWatchSubtree := fWatch; <br><br>非常奇怪的事情就是,如果这行<br><br>&nbsp; &nbsp; &nbsp; shn.Path :=lowercase(Drivers.Strings);<br><br>改成 <br>&nbsp; &nbsp; &nbsp; shn.Path :='c:/';<br><br>就正常,没有问题!<br><br>其实值都是一摸一样的!<br><br>这是什么道理????<br><br>请高手指教<br><br>我主要是希望能够监视所有驱动器而不只是某一个目录。<br><br>谢谢<br><br>
 
你能确保 Drivers.Strings 是有效路径吗?<br>当i=0时,Drivers.Strings[0] 是否是有效路径?
 
顶部