Programmatically check computer management - public folders - open files for file

We have client server software that needs to be updated. I need to check if the file is currently available. Is this possible, if that is the way Delphi code does it. The only place I can see if a file is open is to open open public folder files. I tried this code but just shows that the file is not opening.

function TfrmMain.FileInUse(FileName: string): Boolean;

var H_File : HFILE;
begin
  Result := False;

  if not FileExists(FileName) then
    begin
    showmessage ('Doesnt Exist');
    exit;
    end;
  H_File := CreateFile(PChar(FileName), GENERIC_READ or GENERIC_WRITE, 0,
    nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);

  Result := (H_File = INVALID_HANDLE_VALUE);
  showmessage('Opened');
  if not Result then
    CloseHandle(H_File);
end;
+1
source share
3 answers

, WBEM, Windows. , WBEM, COM- "Microsoft WMI Scripting" ( , , ).

Win32_ServerConnection, , , , , " " ' .

0

, - - , , , , .

0

I found this similar element , someone suggests using the NetFileEnum function

0
source

Source: https://habr.com/ru/post/1729125/


All Articles