有注释的 using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Data.OleDb; using System.Net; using System.Diagnostics; namespace DownLoadSoftware { /// <summary> /// Form1 的摘要说明。 /// </summary> public class MainForm : System.Windows.Forms.Form { private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox txtReferURL; private System.Windows.Forms.Label label4; private System.Windows.Forms.TextBox txtTureURL; private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox txtFlahGat; private System.Windows.Forms.TextBox txtAccessAdd; private System.Windows.Forms.Label label5; private System.Windows.Forms.Button btnAccessAdd; private System.Windows.Forms.Label label6; private System.Windows.Forms.TextBox txtFieldName; private System.Windows.Forms.Label label7; private System.Windows.Forms.TextBox txtTableName; private System.Windows.Forms.Button btnStart; private System.Windows.Forms.Button btnFlashGatAdd; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox btnFormUrl; string accessAdd; string tableName; string fieldName; string formUrl;// string referUrl; string flashAdd; string realUrl; string selectSQL; string strConn;  rocess flashGetP = new Process(); /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; public MainForm() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.panel1 = new System.Windows.Forms.Panel(); this.btnFormUrl = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.btnFlashGatAdd = new System.Windows.Forms.Button(); this.txtTableName = new System.Windows.Forms.TextBox(); this.label7 = new System.Windows.Forms.Label(); this.txtFieldName = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); this.btnAccessAdd = new System.Windows.Forms.Button(); this.btnStart = new System.Windows.Forms.Button(); this.label5 = new System.Windows.Forms.Label(); this.txtAccessAdd = new System.Windows.Forms.TextBox(); this.txtFlahGat = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.txtTureURL = new System.Windows.Forms.TextBox(); this.label4 = new System.Windows.Forms.Label(); this.txtReferURL = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.SuspendLayout(); // // panel1 // this.panel1.BackColor = System.Drawing.Color.Gainsboro; this.panel1.Controls.Add(this.btnFormUrl); this.panel1.Controls.Add(this.label2); this.panel1.Controls.Add(this.btnFlashGatAdd); this.panel1.Controls.Add(this.txtTableName); this.panel1.Controls.Add(this.label7); this.panel1.Controls.Add(this.txtFieldName); this.panel1.Controls.Add(this.label6); this.panel1.Controls.Add(this.btnAccessAdd); this.panel1.Controls.Add(this.btnStart); this.panel1.Controls.Add(this.label5); this.panel1.Controls.Add(this.txtAccessAdd); this.panel1.Controls.Add(this.txtFlahGat); this.panel1.Controls.Add(this.label1); this.panel1.Controls.Add(this.txtTureURL); this.panel1.Controls.Add(this.label4); this.panel1.Controls.Add(this.txtReferURL); this.panel1.Controls.Add(this.label3); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(352, 285); this.panel1.TabIndex = 2; this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint); // // btnFormUrl // this.btnFormUrl.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.btnFormUrl.Location = new System.Drawing.Point(8, 112); this.btnFormUrl.Name = "btnFormUrl"; this.btnFormUrl.Size = new System.Drawing.Size(280, 21); this.btnFormUrl.TabIndex = 24; this.btnFormUrl.Text = ""; // // label2 // this.label2.BackColor = System.Drawing.SystemColors.ActiveBorder; this.label2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.label2.Location = new System.Drawing.Point(8, 96); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(128, 17); this.label2.TabIndex = 23; this.label2.Text = "来源地址:"; // // btnFlashGatAdd // this.btnFlashGatAdd.BackColor = System.Drawing.SystemColors.ActiveBorder; this.btnFlashGatAdd.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnFlashGatAdd.Location = new System.Drawing.Point(296, 248); this.btnFlashGatAdd.Name = "btnFlashGatAdd"; this.btnFlashGatAdd.Size = new System.Drawing.Size(40, 23); this.btnFlashGatAdd.TabIndex = 22; this.btnFlashGatAdd.Text = "..."; this.btnFlashGatAdd.Click += new System.EventHandler(this.btnFlashGatAdd_Click); // // txtTableName // this.txtTableName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.txtTableName.Location = new System.Drawing.Point(160, 64); this.txtTableName.Name = "txtTableName"; this.txtTableName.Size = new System.Drawing.Size(128, 21); this.txtTableName.TabIndex = 21; this.txtTableName.Text = ""; // // label7 // this.label7.BackColor = System.Drawing.SystemColors.ActiveBorder; this.label7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.label7.Location = new System.Drawing.Point(160, 48); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(128, 17); this.label7.TabIndex = 20; this.label7.Text = "表明"; // // txtFieldName // this.txtFieldName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.txtFieldName.Location = new System.Drawing.Point(8, 64); this.txtFieldName.Name = "txtFieldName"; this.txtFieldName.Size = new System.Drawing.Size(128, 21); this.txtFieldName.TabIndex = 19; this.txtFieldName.Text = ""; // // label6 // this.label6.BackColor = System.Drawing.SystemColors.ActiveBorder; this.label6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.label6.Location = new System.Drawing.Point(8, 48); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(128, 17); this.label6.TabIndex = 18; this.label6.Text = "字段名字: "; // // btnAccessAdd // this.btnAccessAdd.BackColor = System.Drawing.SystemColors.ActiveBorder; this.btnAccessAdd.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnAccessAdd.Location = new System.Drawing.Point(296, 16); this.btnAccessAdd.Name = "btnAccessAdd"; this.btnAccessAdd.Size = new System.Drawing.Size(40, 21); this.btnAccessAdd.TabIndex = 17; this.btnAccessAdd.Text = "..."; this.btnAccessAdd.Click += new System.EventHandler(this.btnAccessAdd_Click); // // btnStart // this.btnStart.BackColor = System.Drawing.SystemColors.ActiveBorder; this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnStart.Location = new System.Drawing.Point(296, 48); this.btnStart.Name = "btnStart"; this.btnStart.Size = new System.Drawing.Size(40, 184); this.btnStart.TabIndex = 16; this.btnStart.Text = "开始"; this.btnStart.Click += new System.EventHandler(this.btnStart_Click); // // label5 // this.label5.BackColor = System.Drawing.SystemColors.ActiveBorder; this.label5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.label5.Location = new System.Drawing.Point(8, 0); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(128, 17); this.label5.TabIndex = 15; this.label5.Text = "Access数据库地址 :"; // // txtAccessAdd // this.txtAccessAdd.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.txtAccessAdd.Enabled = false; this.txtAccessAdd.Location = new System.Drawing.Point(8, 16); this.txtAccessAdd.Name = "txtAccessAdd"; this.txtAccessAdd.Size = new System.Drawing.Size(280, 21); this.txtAccessAdd.TabIndex = 14; this.txtAccessAdd.Text = ""; // // txtFlahGat // this.txtFlahGat.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.txtFlahGat.Enabled = false; this.txtFlahGat.Location = new System.Drawing.Point(8, 248); this.txtFlahGat.Name = "txtFlahGat"; this.txtFlahGat.Size = new System.Drawing.Size(280, 21); this.txtFlahGat.TabIndex = 13; this.txtFlahGat.Text = ""; // // label1 // this.label1.BackColor = System.Drawing.SystemColors.ActiveBorder; this.label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.label1.Location = new System.Drawing.Point(8, 232); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(128, 17); this.label1.TabIndex = 12; this.label1.Text = "FlahGat程序地址"; // // txtTureURL // this.txtTureURL.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.txtTureURL.Location = new System.Drawing.Point(8, 200); this.txtTureURL.Name = "txtTureURL"; this.txtTureURL.Size = new System.Drawing.Size(280, 21); this.txtTureURL.TabIndex = 11; this.txtTureURL.Text = ""; // // label4 // this.label4.BackColor = System.Drawing.SystemColors.ActiveBorder; this.label4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.label4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134))); this.label4.Location = new System.Drawing.Point(8, 184); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(128, 17); this.label4.TabIndex = 10; this.label4.Text = "真实的网址:"; // // txtReferURL // this.txtReferURL.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.txtReferURL.Location = new System.Drawing.Point(8, 152); this.txtReferURL.Name = "txtReferURL"; this.txtReferURL.Size = new System.Drawing.Size(280, 21); this.txtReferURL.TabIndex = 9; this.txtReferURL.Text = ""; // // label3 // this.label3.BackColor = System.Drawing.SystemColors.ActiveBorder; this.label3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.label3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134))); this.label3.Location = new System.Drawing.Point(8, 136); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(128, 17); this.label3.TabIndex = 8; this.label3.Text = "伪装来源:"; // // MainForm // this.AcceptButton = this.btnStart; this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(352, 285); this.Controls.Add(this.panel1); this.MaximizeBox = false; this.Name = "MainForm"; this.Text = "获取软件真实地址"; this.panel1.ResumeLayout(false); this.ResumeLayout(false); } #endregion /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.Run(new MainForm()); } private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { } private void btnStart_Click(object sender, System.EventArgs e) { flashGetP.StartInfo.FileName = "cmd.exe"; //flashGetP.StartInfo.FileName= flashAdd +" "+realUrl; flashGetP.StartInfo.UseShellExecute = false; flashGetP.StartInfo.RedirectStandardInput = true; flashGetP.StartInfo.CreateNoWindow = true; flashGetP.Start(); accessAdd = txtAccessAdd.Text; tableName = txtTableName.Text; fieldName=txtFieldName.Text; referUrl= txtReferURL.Text; flashAdd = txtFlahGat.Text; selectSQL= "Select * From "+ tableName ; strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + accessAdd; OleDbConnection oleConn = new OleDbConnection(); oleConn.ConnectionString= strConn; OleDbDataAdapter OleDA = new OleDbDataAdapter(); OleDA.SelectCommand = new OleDbCommand(selectSQL, oleConn); OleDbCommandBuilder oleCB = new OleDbCommandBuilder(OleDA); DataSet ds = new DataSet(); try { oleConn.Open(); OleDA.Fill(ds, tableName); } catch { MessageBox.Show("数据源错误!!"); oleConn.Close(); return; }
DataTable dt = ds.Tables[tableName]; int rows = dt.Rows.Count;; for(int i= 0; i<rows; i++) { DataRow dr = dt.Rows; formUrl = (string) dr[fieldName]; //btnFormUrl.Text= formUrl; realUrl = GetRealURL(referUrl,formUrl); if (realUrl !=null) { dr[fieldName]= realUrl; if(txtFlahGat.ToString() != "") flashGetP.StandardInput.WriteLine(flashAdd +" "+realUrl); } //txtTureURL.Text=realUrl; } OleDA.Update(ds, tableName); oleConn.Close(); flashGetP.StandardInput.WriteLine("exit"); btnStart.Text="处理完毕"; } public string GetRealURL(string referURl,string formURL) { if (referURl.Length<10) { //MessageBox.Show("URL不正确吧","URL不正确"); return null; } else { HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(formURL); myReq.Referer=referURl; try { HttpWebResponse myres=(HttpWebResponse)myReq.GetResponse(); } catch { return null; } bool hasChanged = (myReq.RequestUri != myReq.Address); string geturl; if (hasChanged) { geturl=myReq.Address.ToString(); } else { geturl=myReq.RequestUri.ToString(); } return geturl ; } } private void btnAccessAdd_Click(object sender, System.EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter="Access数据库|*.mdb"; if(ofd.ShowDialog() == DialogResult.OK) txtAccessAdd.Text=ofd.FileName.ToString(); btnStart.Focus(); } private void btnFlashGatAdd_Click(object sender, System.EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter="FlashGat|*.exe"; if(ofd.ShowDialog() == DialogResult.OK) txtFlahGat.Text=ofd.FileName.ToString(); btnStart.Focus(); } } }
|