首页  编辑  

判断一个文件夹是否被共享

Tags: /超级猛料/Stream.File.流、文件和目录/目录/   Date Created:

判断一个文件夹是否被共享

test if a folder is shared / Shareable

uses   ShellAPI ,   ShlObj ; procedure TForm1 . Button1Click ( Sender : TObject ); var   FileInfo : TSHFileInfo ;   S : string ; begin   S := IncludeTrailingPathDelimiter ( Edit1 . Text );  FillChar ( FileInfo , SizeOf ( FileInfo ), #0 );   FileInfo . dwAttributes := SFGAO_SHARE ;   if SHGetFileInfo ( PChar ( S ), 0 , FileInfo , SizeOf ( TSHFileInfo ),     SHGFI_ATTRIBUTES ) = 0 then RaiseLastOSError ;   if FileInfo . dwAttributes and SFGAO_SHARE <> 0 then    ShowMessage ( 'shared' )   else    ShowMessage ( 'not shared' ); end ;