⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 网络驱动器 映射 NetDriver TNetResource
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Inifiles, ShellApi, ComCtrls, Gauges;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Image1: TImage;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  NetSource : TNetResource;
  Ini_: Tinifile;
  ShareLst: TStringList;
  i, j: Integer;
  Remote_ServerName, Windows_Shell,User,Password,Provider: string;
Const Local_Driver: array[0..11] of string=(('o'),('p'),('q'),('r'),('s'),
('t'),('u'),('v'),('w'),('x'),('y'),('z'));
  Con_Status = '正在远程连接%s, 请稍后 ...';
begin
 label1.Caption := Con_Status;
 Show;
 Update;
 ShareLst := TStringList.Create;
 Ini_ := Tinifile.Create(ExtractfilePath(paramstr(0))+'share.ini');
 Remote_ServerName := Ini_.ReadString('Remote','ServerName','');
 User := Ini_.ReadString('Remote','User','');
 Password := Ini_.ReadString('Remote','Password','');
 Provider := Ini_.ReadString('Remote','Provider','');
 Windows_Shell := Ini_.ReadString('Local','ShellExecute','Explorer.exe');
 Ini_.ReadSection('ShareDirectories',ShareLst);
 if (ShareLst.Count=-1) then begin
    Application.MessageBox('在线电影未设置路径','提示',16);
    Application.Terminate;
    exit;
 end;
 j := 0;
 for i:=0 to ShareLst.Count-1 do
 begin
   label1.Caption := format(Con_Status,[ShareLst.Strings[i]]);
   label1.Update;
   with NetSource do
   begin
     try
       dwType := RESOURCETYPE_ANY;
       lpLocalName := Pchar(Local_Driver[j]+':');
       lpRemoteName := Pchar('\\'+Remote_ServerName+'\'+Ini_.ReadString('ShareDirectories',ShareLst.Strings[i],''));
       lpProvider := Pchar(Provider);
       WNetCancelConnection2(Pchar(Local_Driver[i]+':'), CONNECT_UPDATE_PROFILE, True);
       if Ini_.ReadBool('Local','On_Login_ReConnection',False) then
          WnetAddConnection2(NetSource, Pchar(Password), Pchar(User), CONNECT_UPDATE_PROFILE)
       else WnetAddConnection2(NetSource, Pchar(Password), Pchar(User), 0);
       if DirectoryExists(lpLocalName) then
       begin
         ShellExecute(Handle,'open',Pchar(Windows_shell),
         Pchar(lpLocalName),nil,sw_normal);
         inc(j);
       end;
     except
     end;
  end;
 end;
 if (J=0) and (i>=0) then 
    Application.MessageBox('在线电影服务器连接失败!','提示',16);
 Application.Terminate;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -