<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="css/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>MK2-风 之谷 - C#</title><link>http://www.mk2leo.com/</link><description>大家来学习编程吧 - </description><generator>RainbowSoft Studio Z-Blog 1.8 Arwen Build 90619</generator><language>zh-CN</language><copyright>MK2-风版权所有.</copyright><pubDate>Tue, 07 Sep 2010 12:37:14 +0800</pubDate><item><title>c# 调用 VC++ DLL文件 </title><author>mk2leo@qq.com (leoling504)</author><link>http://www.mk2leo.com/post/153.html</link><pubDate>Sun, 10 May 2009 21:59:30 +0800</pubDate><guid>http://www.mk2leo.com/post/153.html</guid><description><![CDATA[<p>using System;<br />using System.Collections.Generic;<br />using System.ComponentModel;<br />using System.Data;<br />using System.Drawing;<br />using System.Text;<br />using System.Windows.Forms;<br />using System.Runtime.InteropServices;</p><p>namespace dll<br />{<br />&nbsp;&nbsp;&nbsp; public partial class Form1 : Form<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [DllImport(&quot;textdll.dll&quot;, EntryPoint = &quot;WhoBig&quot;, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] //调用VC DLL文件的宣告<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static extern int WhoBig(int a, int b); // 初始化DLL文件中 要调用的声明<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Form1()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InitializeComponent();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void button1_Click(object sender, EventArgs e)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MessageBox.Show(WhoBig(12,11).ToString()); //调用WhoBig<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; }<br />}</p>]]></description><category>C#</category><comments>http://www.mk2leo.com/post/153.html#comment</comments><wfw:comment>http://www.mk2leo.com/</wfw:comment><wfw:commentRss>http://www.mk2leo.com/feed.asp?cmt=153</wfw:commentRss><trackback:ping>http://www.mk2leo.com/cmd.asp?act=tb&amp;id=153&amp;key=3e29fb36</trackback:ping></item><item><title>C# 自动登录家庭路由修改设置</title><author>mk2leo@qq.com (leoling504)</author><link>http://www.mk2leo.com/post/100.html</link><pubDate>Thu, 05 Feb 2009 02:03:27 +0800</pubDate><guid>http://www.mk2leo.com/post/100.html</guid><description><![CDATA[[CODE=cshap]using System;<br/>using System.Collections.Generic;<br/>using System.ComponentModel;<br/>using System.Data;<br/>using System.Drawing;<br/>using System.Text;<br/>using System.Windows.Forms;<br/>using System.Net;<br/>using System.IO;<br/>using System.Web;<br/><br/>namespace router_login<br/>{<br/>    public partial class Form1 : Form<br/>    {<br/>        public Form1()<br/>        {<br/>            InitializeComponent();<br/>        }<br/><br/>        private void button1_Click(object sender, EventArgs e)<br/>        {<br/>            postrequest();<br/>        }<br/>        public void postrequest()<br/>        {<br/>            string userName = "admin";<br/>            string password = "mcokb";<br/>            CookieContainer webCookieContainer = new CookieContainer();<br/>            String url = "http://192.168.10.221/primary.htm";<br/>            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);<br/>            req.Method = "GET";<br/>            req.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;CIBA)";<br/>            req.CookieContainer = webCookieContainer;<br/>            req.KeepAlive = true;<br/>            req.Accept = "*/*";<br/>            req.PreAuthenticate = true;<br/>            CredentialCache myCache = new CredentialCache();<br/>            myCache.Add(new Uri("http://192.168.10.221/primary.htm"), "Basic", new NetworkCredential(userName, password));//添加Basic认证<br/>            req.Credentials = myCache;<br/>            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();<br/>            resp.Cookies = webCookieContainer.GetCookies(req.RequestUri);<br/>            StreamReader sr = new StreamReader(resp.GetResponseStream(), System.Text.Encoding.Default);<br/>            String line = sr.ReadToEnd();//这里就是网页内容了。<br/>            //webBrowser1.DocumentText = line.ToString();<br/>            //richTextBox1.Text = line.ToString();<br/>            closes();<br/>            sr.Close();<br/>            resp.Close();<br/>        }<br/>        public void closes()<br/>        {<br/><br/><br/>            string b = "wan1_state=1&wan2_state=1&wan1_proto=0&wan2_proto=2&wan1_static_ip=202.175.184.114&wan2_static_ip=0.0.0.0&wan1_static_mask=255.255.255.248&wan2_static_mask=0.0.0.0&wan1_static_gateway=202.175.184.113&wan2_static_gateway=0.0.0.0&pptp_svrip1=0.0.0.0&pptp_svrip2=0.0.0.0&poe1_usr=&poe5_usr=kbcf&poe1_pwd=&poe5_pwd=wdyd6ue5&poe_host1=&poe_host2=&wan1_static_dns1=202.175.3.3&wan2_static_dns1=0.0.0.0&wan1_static_dns2=202.175.3.9&wan2_static_dns2=0.0.0.0&wan1_static_dns3=0.0.0.0&wan2_static_dns3=0.0.0.0&wan1_host=DBG003692&wan2_host=DBG003690&wan1_domain=&wan2_domain=&wan1_mac=00-09-A3-00-36-92&submit=Submit";<br/><br/>            string param = b; <br/>            byte[] bs = Encoding.ASCII.GetBytes(param);<br/><br/>            HttpWebRequest reqe = (HttpWebRequest)WebRequest.Create("http://192.168.10.221/primary.cgi");<br/>            reqe.Method = "POST";<br/>            reqe.ContentType = "application/x-www-form-urlencoded";<br/>            reqe.ContentLength = bs.Length;<br/>            Stream reqstream = reqe.GetRequestStream();<br/><br/>            reqstream.Write(bs, 0, bs.Length);<br/>            reqstream.Close();<br/>           <br/>            HttpWebResponse wr = (HttpWebResponse)reqe.GetResponse();<br/>            StreamReader reader = new StreamReader(wr.GetResponseStream(), Encoding.UTF8);<br/>            string content = reader.ReadToEnd();<br/>            MessageBox.Show(content.ToString());<br/>        }<br/>    }<br/>}[/CODE]]]></description><category>C#</category><comments>http://www.mk2leo.com/post/100.html#comment</comments><wfw:comment>http://www.mk2leo.com/</wfw:comment><wfw:commentRss>http://www.mk2leo.com/feed.asp?cmt=100</wfw:commentRss><trackback:ping>http://www.mk2leo.com/cmd.asp?act=tb&amp;id=100&amp;key=fecde591</trackback:ping></item><item><title>[C#]发送SMS 手机短讯 只限澳门CTM帐号使用 </title><author>mk2leo@qq.com (leoling504)</author><link>http://www.mk2leo.com/post/86.html</link><pubDate>Fri, 12 Dec 2008 20:21:15 +0800</pubDate><guid>http://www.mk2leo.com/post/86.html</guid><description><![CDATA[<p>&nbsp;</p><p><img title="" alt="" src="http://www.mk2leo.com/upload/smss.jpg" onload="ResizeImage(this,450)" /></p><p>这个发送SMS短讯的程式 要使用澳门CTM 上网帐号才能使用的.. 填上你在CTM申请的上网ID和密码..就能发送手机短讯..本地收费是0.25一个..国外全都是1元...想群发的话 只要 66450082,66437786 加一个, 号就可以了....</p><p>这个程序都写了大概半年了..在贴出澳门一些论坛后.老是被人说会盗他的CTM帐号和密码 = ='' 真好心做坏事...</p><p>&nbsp;</p><p><a href="http://www.mk2leo.com/upload/SMS.rar" target="_blank">SMS.rar</a>&nbsp; 下载请安此..因为是用C# 做的.XP要先安装 .NETFRAMWORK 2.0</p>]]></description><category>C#</category><comments>http://www.mk2leo.com/post/86.html#comment</comments><wfw:comment>http://www.mk2leo.com/</wfw:comment><wfw:commentRss>http://www.mk2leo.com/feed.asp?cmt=86</wfw:commentRss><trackback:ping>http://www.mk2leo.com/cmd.asp?act=tb&amp;id=86&amp;key=995f4210</trackback:ping></item><item><title>C# DataGridView 插入数据到ACCESS中</title><author>mk2leo@qq.com (leoling504)</author><link>http://www.mk2leo.com/post/63.html</link><pubDate>Wed, 26 Nov 2008 21:46:53 +0800</pubDate><guid>http://www.mk2leo.com/post/63.html</guid><description><![CDATA[<p><img alt="" src="http://www.mk2leo.com/image/face/Cool.gif" />第一编C#的技术文章呢..</p><p>由於要帮朋友做一个数据库.用来记录一些会员资料.若是用ACCESS来做介面的话..<img alt="" src="http://www.mk2leo.com/image/face/Haha.gif" />不用3天就做完了....</p><p>&nbsp;</p><p>但为了挑战和累积一下C#的经验..决定用C#来做..<img alt="" src="http://www.mk2leo.com/image/face/Effort.gif" /></p><p>第一个难题.就是这个DATAGRIDVIEW了... 在D中写了几笔资料..想新增到ACCESS的表中.但找了很多资料.也无好的答案...最后只好用SQL语句+FOR 来做了....要是数据量大.千万别这样做.一开一关.会死库的</p><p>假设 MDB文件中 有一个 Prize的表 表里有字段 会员编号和获奖记录</p><p>那现在来开始写代码了</p><p>&nbsp;</p>[CODE=csharp]int i=dataGridView1.Rows.Count;<br/>                for (int j = 0; j < i; j++)<br/>                {<br/>                    if (dataGridView1.Rows[j].Cells[1].Value == null)<br/>                    {<br/>                        break;<br/>                    }<br/>                    else<br/>                    {<br/>                        string cmdadd = "INSERT INTO prize(會員編號,獲獎記錄)VALUES('";<br/>                        cmdadd += this.textBox1.Text + "','";<br/>                        cmdadd += dataGridView1.Rows[j].Cells[1].Value + "')";<br/>                       <br/>                        OleDbCommand mycmdadd = new OleDbCommand(cmdadd, con);<br/>                        mycmd.CommandText = cmdadd;<br/>                        mycmd.Connection = con;<br/>                        con.Open();<br/>                        mycmd.ExecuteNonQuery();<br/>                        con.Close();<br/>                    }<br/>                }<br/>[/CODE]<br/><br/>CON是MDB文件的连接字串...<br/>这样.D中的数据.就能插入到表中了...]]></description><category>C#</category><comments>http://www.mk2leo.com/post/63.html#comment</comments><wfw:comment>http://www.mk2leo.com/</wfw:comment><wfw:commentRss>http://www.mk2leo.com/feed.asp?cmt=63</wfw:commentRss><trackback:ping>http://www.mk2leo.com/cmd.asp?act=tb&amp;id=63&amp;key=437124ee</trackback:ping></item><item><title>更改電腦ip設置程式(自家做)</title><author>mk2leo@qq.com (leoling504)</author><link>http://www.mk2leo.com/post/6.html</link><pubDate>Fri, 24 Oct 2008 04:46:15 +0800</pubDate><guid>http://www.mk2leo.com/post/6.html</guid><description><![CDATA[<p><img alt="" src="http://www.mk2leo.com/upload/200810240500361051.jpg" /></p><p><img alt="" src="http://www.mk2leo.com/upload/200810240500370718.jpg" /></p><p>&nbsp;</p><p>為了方便一些經常各辨公室周圍走.或經常要轉換ip設置的朋友.所以做了這個可以保存4組ip位置自動更改的程式.</p><p>使用上好簡單.如圖一.大家可以自己打上各種數值.按change轉換.或按mark ip 保存.以name為記號.在主畫面按一下select ip.就能自動填上..</p><p>這個程式是用c# 寫的..所以需要安裝.net 2.0運行庫..vista則免.已內置</p><p>&nbsp;</p><p>&nbsp;</p><p><a target="_blank" href="http://www.mk2leo.com/upload/IPCHANG080903.rar">IPCHANG080903.rar</a></p>]]></description><category>C#</category><comments>http://www.mk2leo.com/post/6.html#comment</comments><wfw:comment>http://www.mk2leo.com/</wfw:comment><wfw:commentRss>http://www.mk2leo.com/feed.asp?cmt=6</wfw:commentRss><trackback:ping>http://www.mk2leo.com/cmd.asp?act=tb&amp;id=6&amp;key=37145ae6</trackback:ping></item></channel></rss>
