Einzelnen Beitrag anzeigen

shmia

Registriert seit: 2. Mär 2004
5.508 Beiträge
 
Delphi 5 Professional
 
#4

Re: Netzwerkfreigabe überwachen

  Alt 9. Mär 2006, 14:16
Vielleicht hilft dir das weiter.
Allerdings:
[WNetRestoreConnectionW is available for use in the Microsoft Windows 2000 and Windows XP operating systems. It may be altered or unavailable in subsequent versions.]

Delphi-Quellcode:
type
   TWNetRestoreConnectionW = function (hwndParent:HWND; lpDevice:PWideChar):DWORD; stdcall;

function ReconnectDrive(const path:string):DWORD;
var
   libhandle : HMODULE;
   func : TWNetRestoreConnectionW;
   driveW : WideString;
begin
   driveW := ExtractFileDrive(path);
   if driveW='then
      Exit;

   libhandle := LoadLibrary('mpr.dll');
   Result := 0;
   if libhandle=0 then
      Exit;
   try
      func := TWNetRestoreConnectionW(GetProcAddress(libhandle, 'WNetRestoreConnectionW'));
      if Assigned(func) then
         Result := func(0, @driveW[1]);
   finally
      FreeLibrary(libhandle);
   end;
end;
Andreas
  Mit Zitat antworten Zitat