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

📄 frmmain.cs

📁 一个VC完整程序~NET SHARE 使网络用户可以使用某一服务器上的资源。 当不带选项使用本命令 时
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// 
			this.gbCommand.Controls.Add(this.btnClear);
			this.gbCommand.Controls.Add(this.txtNetshare);
			this.gbCommand.Controls.Add(this.txtCommand);
			this.gbCommand.Location = new System.Drawing.Point(8, 136);
			this.gbCommand.Name = "gbCommand";
			this.gbCommand.Size = new System.Drawing.Size(496, 48);
			this.gbCommand.TabIndex = 1;
			this.gbCommand.TabStop = false;
			this.gbCommand.Text = "&Command";
			// 
			// btnClear
			// 
			this.btnClear.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.btnClear.Location = new System.Drawing.Point(416, 16);
			this.btnClear.Name = "btnClear";
			this.btnClear.Size = new System.Drawing.Size(64, 23);
			this.btnClear.TabIndex = 2;
			this.btnClear.Text = "C&lear";
			this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
			// 
			// txtNetshare
			// 
			this.txtNetshare.BackColor = System.Drawing.Color.Black;
			this.txtNetshare.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txtNetshare.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));
			this.txtNetshare.Location = new System.Drawing.Point(16, 16);
			this.txtNetshare.Name = "txtNetshare";
			this.txtNetshare.ReadOnly = true;
			this.txtNetshare.Size = new System.Drawing.Size(64, 21);
			this.txtNetshare.TabIndex = 0;
			this.txtNetshare.TabStop = false;
			this.txtNetshare.Text = "net share";
			// 
			// txtCommand
			// 
			this.txtCommand.BackColor = System.Drawing.Color.Black;
			this.txtCommand.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txtCommand.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));
			this.txtCommand.Location = new System.Drawing.Point(80, 16);
			this.txtCommand.Name = "txtCommand";
			this.txtCommand.Size = new System.Drawing.Size(320, 21);
			this.txtCommand.TabIndex = 1;
			this.txtCommand.Text = "";
			// 
			// btnExit
			// 
			this.btnExit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.btnExit.Location = new System.Drawing.Point(408, 328);
			this.btnExit.Name = "btnExit";
			this.btnExit.Size = new System.Drawing.Size(80, 24);
			this.btnExit.TabIndex = 5;
			this.btnExit.Text = "E&xit";
			this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
			// 
			// btnAbout
			// 
			this.btnAbout.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.btnAbout.Location = new System.Drawing.Point(320, 328);
			this.btnAbout.Name = "btnAbout";
			this.btnAbout.Size = new System.Drawing.Size(80, 24);
			this.btnAbout.TabIndex = 4;
			this.btnAbout.Text = "&About";
			this.btnAbout.Click += new System.EventHandler(this.btnAbout_Click);
			// 
			// btnRun
			// 
			this.btnRun.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.btnRun.Location = new System.Drawing.Point(232, 328);
			this.btnRun.Name = "btnRun";
			this.btnRun.Size = new System.Drawing.Size(80, 24);
			this.btnRun.TabIndex = 3;
			this.btnRun.Text = "R&un";
			this.btnRun.Click += new System.EventHandler(this.btnRun_Click);
			// 
			// txtHelp
			// 
			this.txtHelp.BackColor = System.Drawing.SystemColors.Info;
			this.txtHelp.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txtHelp.Location = new System.Drawing.Point(8, 192);
			this.txtHelp.Multiline = true;
			this.txtHelp.Name = "txtHelp";
			this.txtHelp.ReadOnly = true;
			this.txtHelp.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.txtHelp.Size = new System.Drawing.Size(496, 128);
			this.txtHelp.TabIndex = 2;
			this.txtHelp.Text = @"NET SHARE 帮助
========================================================================
sharename
sharename=drive:path [/GRANT:user,[READ | CHANGE | FULL]]
                     [/USERS:number | /UNLIMITED]
                     [/CACHE:Manual | Documents| Programs | None ]
sharename [/USERS:number | /UNLIMITED]
          [/REMARK:""text""]
          [/CACHE:Manual | Documents | Programs | None]
          {sharename | devicename | drive:path} /DELETE

 NET SHARE 使网络用户可以使用某一服务器上的资源。 当不带选项使用本命令
时,它会列出该计算机上正在被共享的所有资源。对于每一种资源,Windows 都
会报告其设备名或路径名,以及与之相关的描述性注释。

sharename          指共享资源的网络名。输入 NET SHARE 和一个共享名只会
                   显示那个共享的有关信息。
drive:path         指定将被共享的目录的绝对路径。
/GRANT:user,perm   创建有安全性描述符的共享,对指定用户授予要求的权限。
                   此选项可以多次使用,将共享权限赋予多个用户。
/USERS:number      设置可以同时访问共享资源的最大用户数。
/UNLIMITED         指定可以同时访问共享资源的用户数目不受限制。
/REMARK:""text""     添加一个有关资源的描述性注释,应将文本包含在引号中。
devicename         指一个或多个被共享名所共享的打印机 (LPT1: 至 LPT9:)。
                   按共享名共享。
/DELETE            停止共享资源。
/CACHE:Manual      对来自此共享的程序和文档启用手动客户缓存
/CACHE:Documents   对来自此共享的文档启用自动缓存
/CACHE:Programs    对来自此共享的程序和文档启用自动缓存
/CACHE:None        禁用此共享的缓存";
			// 
			// frmMain
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(514, 359);
			this.Controls.Add(this.btnAbout);
			this.Controls.Add(this.gbCommand);
			this.Controls.Add(this.gbInformation);
			this.Controls.Add(this.btnRun);
			this.Controls.Add(this.btnExit);
			this.Controls.Add(this.txtHelp);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.Name = "frmMain";
			this.Text = "AutoShare";
			this.Load += new System.EventHandler(this.frmMain_Load);
			this.gbInformation.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.numMaxUsers)).EndInit();
			this.gbCommand.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new frmMain());
		}
		
		private System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();
		private System.Diagnostics.Process Proc = new System.Diagnostics.Process();
		private string information;
		private string command;

		private void frmMain_Load(object sender, System.EventArgs e)
		{
			Info.FileName = "net";
			Info.Arguments = "share";
		}

		private void btnBrowser_Click(object sender, System.EventArgs e)
		{
			dlgFolder.ShowDialog();
			string result = dlgFolder.SelectedPath;
			txtFolder.Text = result;
			txtShareName.Text = result.Substring(result.LastIndexOf("\\") + 1);
		}

		private void btnClear_Click(object sender, System.EventArgs e)
		{
			txtFolder.Text = "";
			txtShareName.Text = "";
			txtRemark.Text = "";
			txtCommand.Text = "";
		}
		private void btnRun_Click(object sender, System.EventArgs e)
		{
			Info.Arguments = "share " + txtCommand.Text;
			try
			{
				Proc = System.Diagnostics.Process.Start(Info);
			}
			catch(System.ComponentModel.Win32Exception ex)
			{
				MessageBox.Show("Error !\n\n" + ex.Message ,"AutoShare",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}

		private void btnAbout_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show("\nWritten by : Lin Jian\n\nClass 01110407 , Beijing Institute of Technology\n\nCopyright (C) 2004 , All Rights Reserved","AutoShare",MessageBoxButtons.OK,MessageBoxIcon.Information);
		}

		private void btnExit_Click(object sender, System.EventArgs e)
		{
			Application.Exit();
		}

		private void txtFolder_TextChanged(object sender, System.EventArgs e)
		{
			SetCommand();
		}

		private void txtShareName_TextChanged(object sender, System.EventArgs e)
		{
			SetCommand();
		}

		private void txtRemark_TextChanged(object sender, System.EventArgs e)
		{
			SetCommand();
		}

		private void numMaxUsers_ValueChanged(object sender, System.EventArgs e)
		{
			SetCommand();
		}

		private void chkNoLimited_CheckedChanged(object sender, System.EventArgs e)
		{
			numMaxUsers.Enabled = ! chkNoLimited.Checked;
			SetCommand();
		}
		private void SetCommand()
		{
			string limited = " /unlimited";
			if(!chkNoLimited.Checked)
				limited = " /users:" + numMaxUsers.Value.ToString();
			string remark = "";
			if(txtRemark.Text != "")
				remark = " /remark:\"" + txtRemark.Text + "\"";
			information = "\"" + txtShareName.Text + "\"=\"" + txtFolder.Text + "\"";
			command = information + limited + remark;
			txtCommand.Text = command;
		}

	}
}

⌨️ 快捷键说明

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