SuperBug

博客园 首页 联系 订阅 管理

06 2012 档案

摘要:1.DataTable empTable = new DataTable();注释:定义了一个内存中的表empTable。2.empTable.Columns.Add("ID", Type.GetType("System.String"));注释:函数原型:public DataColumn Add(string columnName, Type type);添加一个列名为“ID”,其对应的类型为“System.String”的列。这属于设计表的范畴。3.empTable.Rows.Add(dataRow);注释:向表empTable添加一行,其中dat 阅读全文
posted @ 2012-06-26 19:45 SuperBug 阅读(3578) 评论(0) 推荐(0)

摘要:1.SqlCommand cmd = new SqlCommand(sql, connection);注释:定义一个数据库命令对象,参数为:sql为string类型,是一个数据库查询语句。例如string sql = "update EMPLOYESS set STATE=@STATE where ID=@ID";这里的@STATE和@ID表示这两个是参数。 connection是SqlConnection类型。2.cmd.CommandType = CommandType.Text;注释:设置cmd的执行类型为使用sql语句执行。3.cmd.Parameters.Add( 阅读全文
posted @ 2012-06-26 19:44 SuperBug 阅读(257) 评论(0) 推荐(0)

摘要:首先加入头文件:using System.Data;using System.Data.SqlClient;接着:步骤1:按照一定的格式将连接所需信息填入一个字符串。如:string connectStr = "Data Source=192.168.0.198,1433;// 数据库所在机器IP地址和端口号 Network Library=DBMSSOCN; Initial Catalog=LK;// 数据库名称 User ID=sa; // 数据库登陆ID Password=123456; // 数据库登陆密码 Persist Security Info=True";步 阅读全文
posted @ 2012-06-26 19:30 SuperBug 阅读(263) 评论(0) 推荐(0)

摘要:前面写的系列还没有发布,没有数字证书,还不算真正能部署在服务器上的ActiveX控件,想要部署成真正的ActiveX控件,请继续往下看。选择安装与部署选择主输出项目选择注册的类型点击生成生成后debug文件夹中有该文件修改install。inf信息下面是dos下的命令 阅读全文
posted @ 2012-06-20 18:40 SuperBug 阅读(439) 评论(0) 推荐(0)

摘要:using System;using System.Collections.Generic;using System.Text;using System.Threading;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { Thread newThread = new Thread(test); newThread.Start("para input"); newThread =... 阅读全文
posted @ 2012-06-14 17:31 SuperBug 阅读(222) 评论(0) 推荐(0)

摘要:using System;using System.Threading;class Test{ static void Main() { // To start a thread using a static thread procedure, use the // class name and method name when you create the ThreadStart // delegate. Beginning in version 2.0 of the .NET Framework, // it is no... 阅读全文
posted @ 2012-06-14 16:40 SuperBug 阅读(286) 评论(0) 推荐(0)

摘要:1.添加安全接口2.安全接口源代码namespace WindowsControlLibrary1{ [ComImport, GuidAttribute("CB5BDC81-93C1-11CF-8F20-00805F2CD064")] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] public interface IObjectSafety { [PreserveSig] int GetInterfaceSafetyOptions(ref Guid riid, ... 阅读全文
posted @ 2012-06-13 18:43 SuperBug 阅读(896) 评论(0) 推荐(0)

摘要:步骤1:新建工程第二步:勾选Make assembly com-visible第三步:勾选Register for com interop第四步:定义接口,注意接口的属性需要为public。(右键工程,添加一个接口Item即可)using System;using System.Collections.Generic;using System.Text;using System.Runtime.InteropServices;namespace WindowsControlLibrary1{ [ComVisible(true)] [Guid("C2918110-A1C4-4188-. 阅读全文
posted @ 2012-06-13 01:18 SuperBug 阅读(1635) 评论(0) 推荐(0)

摘要:1.char* 转换成 LPCTSTRchar ch[1024] = "wo shi ni baba";int num = MultiByteToWideChar(0,0,ch,-1,NULL,0);wchar_t *wide = new wchar_t[num];MultiByteToWideChar(0,0,ch,-1,wide,num);解析:num 获得长字节所需的空间MultiByteToWideChar()表示将s中的字符传递到ps指向的内存中。-1表示传输至s中的'\0'处,num表示传递的字节个数。2.LPCTSTR 转换成 char *wc 阅读全文
posted @ 2012-06-11 11:33 SuperBug 阅读(23905) 评论(1) 推荐(3)

摘要:第一步:如上图,点击确定,输入名称后点击完成第二步:如图,其中_Dtest是接口,可以添加属性和接口函数。_DtestEvents是事件接口。右键点击_Dtest可以添加属性和方法。右键点击CtestCtrl可以添加事件。添加后的属性和接口在控件外调用使用在是_Dtest中显示的。而控件内部的实现代码在CtestCtrl中。注:属性和方法相当于接口,而接口必须是有通用的标准,否则就不能跨平台使用。例如C++中有char *表示字符串,C#中是string表示字符串,为了双方能够通过接口交流所以接口中在字符串类型为BSTR. 阅读全文
posted @ 2012-06-09 21:38 SuperBug 阅读(210) 评论(0) 推荐(0)