2012年6月6日

1、StopWatch(秒表)类

提供一组方法和属性,可用于准确地测量运行时间。

Provides a set of methods and properties that you can use to accurately measure elapsed time.

在典型的 Stopwatch 方案中,先调用 Start 方法,然后调用 Stop 方法,最后使用 Elapsed 属性检查运行时间。Stopwatch 实例或者在运行,或者已停止;使用 IsRunning 可以确定 Stopwatch 的当前状态。

   

另外,一个提供在线秒表的网站:http://www.online-stopwatch.com/
 

2、C#执行SQL脚本---SMO(SQL Mangagement Objects)

与之相对应的是ADO.Net用于查询数据,这个用于管理。

引用:

   

   

using Microsoft.SqlServer.Management.Smo;//server

using Microsoft.SqlServer.Management.Common;//ServerConnection

   

   

   

代码:

string sqlConnectionString = @"Data Source=(local)\SqlExpress;Initial Catalog=master;Integrated Security=True";

string path = @"C:\xxx\SqlBulkCop\ConsoleAppInsertTest\SQL.sql";

   

FileInfo file = new FileInfo(path);

   

string script = file.OpenText().ReadToEnd();

   

SqlConnection conn = new SqlConnection(sqlConnectionString);

   

Server server = new Server(new ServerConnection(conn));

   

server.ConnectionContext.ExecuteNonQuery(script);

   

MSDN的SMO搜索内容

   

3、TRUNCATE TABLE与DELETE

1.DELETE

 DML语言

 ・可以回退

 ・可以有条件的删除

   

DELETE FROM 表名

  WHERE 条件

   

2.TRUNCATE TABLE

 DDL语言

 ・无法回退

 ・默认所有的表内容都删除

 删除速度比delete快。

   

TRUNCATE TABLE 表名

   

 4、扫雷外挂

 

 

代码:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Diagnostics;

using System.Runtime.InteropServices;

 

namespace WindowsFormsApplication3

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)

{

}

private const uint PROCESS_ALL_ACCESS = 0x1f0fff;

[DllImport("kernel32.dll")]

public extern static IntPtr OpenProcess(UInt32 dwdesiredaccess, int binherithandle, Int32 dwprocessid);

[DllImport("kernel32.dll")]

public extern static bool ReadProcessMemory(IntPtr hprocess, UInt32 lpbaseaddress, int[] plbuffer, UInt32 nsize, Int32[] lpnbr);

private void button1_Click(object sender, EventArgs e)

{

try

{

Process[] p = Process.GetProcessesByName("扫雷winmine");

IntPtr handle = OpenProcess(0x1F0FFF, 0, p[0].Id);

int[] result = new int[1];

int[] lpdw = new int[1];

bool b = ReadProcessMemory(handle, 0x1005194, result, 4, lpdw);

this.label1.Text = result[0].ToString();

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

}

}

}

原文地址:https://www.cnblogs.com/gmth/p/2538080.html