1、我没有装VS.NET
2、This.Quit();
2、This.Quit();
解决方案 »
- Excel导入到SQL Server的问题
- 为何使用Vlc.DotNet + WPF,无法设置宽高比?
- System.Threading.ThreadAbortException: 正在中止线程
- vs2008正式版以及中文版什么时候发布?
- 如何用C#读取XLS文件的工作簿名字?英文时可以读,但中文就无法读,取到是空的
- 各位帮忙解决一下这个问题吧!!!(急!!!!!!!!!!!!!!)
- 读取u盘盘符
- 怎样把一动态的采集到屏幕的图像放到自己做的窗体里也能动态显示
- 求一个拆分数字的算法。。。谢谢
- 求助mission planner源码开发
- 字
- 请问大家程序代码是写在.cs里,还是写在.aspx.cs里?
2、this第一个字母是小写。
应该是this.Close();吧
2.this.Close();
Form1 frm=new Form1();
frm.textBox1.Text="gdgd";
Form1是窗体的缺省类。
2. this.Close()是可以的,检查一下大小写
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net.Sockets;
using System.Threading;namespace PortScan
{
public class frmScan : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtAddr;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
public System.Windows.Forms.ListBox lstPutout;
private System.Windows.Forms.Button btnScan;
private System.Windows.Forms.Button btnStop;
private System.Windows.Forms.TextBox txtStart;
private System.Windows.Forms.TextBox txtEnd; private System.ComponentModel.Container components = null; public class clPortScan
{
public int port;
public string Addr;
public bool[] done=new bool[65536];
public void Scan()
{
int portnow=port;
done[portnow]=false;
TcpClient objTCP=new TcpClient();
frmScan objFrm=new frmScan();
try
{
objTCP.Connect(Addr,portnow);
objFrm.lstPutout.Items.Add("port"+portnow.ToString()+"is open!");
}
catch(SocketException)
{
objFrm.lstPutout.Items.Add("port"+portnow.ToString()+"isn't open!");
done[portnow]=true;
}
objFrm.Close();
}
} public frmScan()
{ InitializeComponent(); } protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
private void InitializeComponent()
{
......
}
#endregion [STAThread]
static void Main()
{
Application.Run(new frmScan());
} private void btnScan_Click(object sender, System.EventArgs e)
{
lstPutout.Items.Add("PortScanner v0.1");
lstPutout.Items.Add(" ");
int start=Convert.ToInt32(txtStart.Text.Trim());
int end=Convert.ToInt32(txtEnd.Text.Trim());
if((start>=0 && start<=65536) && (end>=0 && end<=65536))
{
int i;
lstPutout.Items.Add(("Starting scan...(this may take a few minutes)"));
clPortScan objPortscan=new clPortScan();
objPortscan.Addr=txtAddr.Text.Trim();
for (i=start;i<=end;i++)
{
objPortscan.port=i;
Thread scanThread=new Thread(new ThreadStart(objPortscan.Scan));
scanThread.Start();
System.Threading.Thread.Sleep(1000);
}
lstPutout.Items.Add("Scan complete.");
}
else
{
lstPutout.Items.Add("start/end scan range is out of range[0-65536]");
}
} private void btnStop_Click_1(object sender, System.EventArgs e)
{
this.Close();
}
}
}
多谢大家了!但是运行过程中还有些问题,类clPortScan中的 objFrm.lstPutout.Items.Add("port"+portnow.ToString()+"isopen!"); ————向窗体中的listbox控件中添加字符串
检测到该语句已经运行,但是在窗体中的listbox控件中并没有任何反应。
窗体类中相似的语句却可以,不知道是什么原因?