請問如何知道一個文件夾共享?(20分)

  • 主题发起人 主题发起人 edymill
  • 开始时间 开始时间
E

edymill

Unregistered / Unconfirmed
GUEST, unregistred user!
如何知道一個文件夾是否共享及一個文件是不是正在被使用?
 
“如何知道一個文件夾是否共享”:<br>注册表里有,win2000是<br>HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Services/lanmanserver/Shares<br>win98也有类似的键。
 
問的不太好?<br>&nbsp; 我的一個文件夾裡面的子文件夾正好是打開的,可是我要刪除它,就出錯!<br>看過程:<br>procedure ToRecycle(AHandle: THandle; const ADirName: String);<br>var<br>&nbsp; SHFileOpStruct: TSHFileOpStruct;<br>&nbsp; DirName: PChar;<br>&nbsp; BufferSize: Cardinal;<br>begin<br>&nbsp; BufferSize := Length(ADirName) +1 +1;<br>&nbsp; GetMem(DirName, BufferSize);<br>&nbsp; try<br>&nbsp; &nbsp; FillChar(DirName^, BufferSize, 0);<br>&nbsp; &nbsp; StrCopy(DirName, PChar(ADirName));<br><br>&nbsp; &nbsp; with SHFileOpStruct do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Wnd := AHandle;<br>&nbsp; &nbsp; &nbsp; wFunc := FO_DELETE;<br>&nbsp; &nbsp; &nbsp; pFrom := DirName;<br>&nbsp; &nbsp; &nbsp; pTo := nil;<br>&nbsp; &nbsp; &nbsp; fFlags := FOF_NOCONFIRMATION;<br><br>&nbsp; &nbsp; &nbsp; fAnyOperationsAborted := False;<br>&nbsp; &nbsp; &nbsp; hNameMappings := nil;<br>&nbsp; &nbsp; &nbsp; lpszProgressTitle := nil;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; SHFileOperation(SHFileOpStruct)<br>&nbsp; finally<br>&nbsp; &nbsp; FreeMem(DirName, BufferSize);<br>&nbsp; end;<br>end;<br>我不想出Last win32 Error! 如果知道它沒有被使用或共享就call此過程 這樣才會不彈出消息!
 
try...except on...不行吗?
 
&nbsp;SHFileOperation(SHFileOpStruct)<br>這個問題與try... except &nbsp;on 好象沒有關系<br>因為它是winAPI,不過我沒有試,等我試一下再來<br><br>
 
You should disable the directory's share status before you wanna delete it,<br>so just erase the key in the registry corresponding the directory's share status.
 
But if you delete the reg keys to cancel the share,you should reboot you<br>computer before it can become valid.
 
樓上的各位大俠:<br>&nbsp; &nbsp;如果我的文件夾不是共享的,隻是在使用,我的內存中打開了其中的文件。<br>所以不能刪除,於是我想找到這個文件夾裡的文件是不是正在使用,如果是,就關閉它!<br>請問應於何操作?
 
后退
顶部