9月 29

将DLL合并到exe中

需要用到 ILmerge.exe(600K) 软件

微软出品

下载地址:http://www.microsoft.com/downloads/en/details.aspx?FamilyID=22914587-B4AD-4EAE-87CF-B14AE6A939B0&displaylang=en

注意:语法要将exe文件放在前面

C:\Program Files (x86)\Microsoft\ILMerge>ILMerge.exe /ndebug /target:winexe /out
:e:\1\1.exe e:\1\TestDemo.ApplyQQ.exe /log e:\1\XydSoft.FrameWork.dll

written by ocean

9月 14

其实本质上就是把远程的图片Stream流下载到本地,用pictureBox展示出来而已

带上cookie,这样就可以肉眼识别

代码很简单,直接上了

前台也就是一个pictureBox控件

AutoLoginHelper autoLoginHelper=new AutoLoginHelper(Encoding.UTF8);
            CookieContainer cc=new CookieContainer();
            Stream stream=autoLoginHelper.GetImages("http://passport.csdn.net/ShowExPwd.aspx",string.Empty,Encoding.UTF8,ref cc);
            Image img = new Bitmap(stream);
            this.pictureBox1.Image = img;

public Stream GetImages(string url, string postData, Encoding encoding, ref CookieContainer cookieContainer)
        {
            byte[] postByte = encoding.GetBytes(postData);
            HttpWebRequest wr = System.Net.HttpWebRequest.Create(url) as HttpWebRequest;
            wr.CookieContainer = cookieContainer;
            wr.Method = "POST";
            wr.ContentType = "application/x-www-form-urlencoded";
            wr.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; MS-RTC LM 8; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)";
            wr.Referer = url;
            wr.CookieContainer = cookieContainer;
            wr.ContentLength = postByte.Length;
            Stream sr = wr.GetRequestStream();
            sr.Write(postByte, 0, postByte.Length);
            sr.Close();
            HttpWebResponse response = wr.GetResponse() as HttpWebResponse;
            System.IO.Stream responseStream = response.GetResponseStream();
            return responseStream;
        }

written by ocean

9月 09

Emit就是快啊,我有做测试

30000条数据,直接发射的话7秒多,Emit1.2秒左右

先记下来,有空了研究

public static class NewClas
    {

                 public static List<T> ToList<T>(DataTable dt)
        {
            List<T> list = new List<T>();
            if (dt == null) return list;
            DataTableEntityBuilder<T> eblist = DataTableEntityBuilder<T>.CreateBuilder(dt.Rows[0]);
            foreach (DataRow info in dt.Rows)
                list.Add(eblist.Build(info));
            dt.Dispose();
            dt = null;
            return list;
        }

        public class DataTableEntityBuilder<T>
        {
            private static readonly MethodInfo getValueMethod = typeof(DataRow).GetMethod("get_Item", new Type[] { typeof(int) });
            private static readonly MethodInfo isDBNullMethod = typeof(DataRow).GetMethod("IsNull", new Type[] { typeof(int) });
            private delegate T Load(DataRow dataRecord);

            private Load handler;
            private DataTableEntityBuilder() { }

            public T Build(DataRow dataRecord)
            {
                return handler(dataRecord);
            }

            public static DataTableEntityBuilder<T> CreateBuilder(DataRow dataRow)
            {
                DataTableEntityBuilder<T> dynamicBuilder = new DataTableEntityBuilder<T>();
                DynamicMethod method = new DynamicMethod("DynamicCreateEntity", typeof(T), new Type[] { typeof(DataRow) }, typeof(T), true);
                ILGenerator generator = method.GetILGenerator();
                LocalBuilder result = generator.DeclareLocal(typeof(T));
                generator.Emit(OpCodes.Newobj, typeof(T).GetConstructor(Type.EmptyTypes));
                generator.Emit(OpCodes.Stloc, result);

                for (int index = 0; index < dataRow.ItemArray.Length; index++)
                {
                    PropertyInfo propertyInfo = typeof(T).GetProperty(dataRow.Table.Columns[index].ColumnName);
                    Label endIfLabel = generator.DefineLabel();
                    if (propertyInfo != null && propertyInfo.GetSetMethod() != null)
                    {
                        generator.Emit(OpCodes.Ldarg_0);
                        generator.Emit(OpCodes.Ldc_I4, index);
                        generator.Emit(OpCodes.Callvirt, isDBNullMethod);
                        generator.Emit(OpCodes.Brtrue, endIfLabel);
                        generator.Emit(OpCodes.Ldloc, result);
                        generator.Emit(OpCodes.Ldarg_0);
                        generator.Emit(OpCodes.Ldc_I4, index);
                        generator.Emit(OpCodes.Callvirt, getValueMethod);
                        generator.Emit(OpCodes.Unbox_Any, propertyInfo.PropertyType);
                        generator.Emit(OpCodes.Callvirt, propertyInfo.GetSetMethod());
                        generator.MarkLabel(endIfLabel);
                    }
                }
                generator.Emit(OpCodes.Ldloc, result);
                generator.Emit(OpCodes.Ret);
                dynamicBuilder.handler = (Load)method.CreateDelegate(typeof(Load));
                return dynamicBuilder;
            }
        }
    }

written by ocean

9月 08

     MySQL一窍不通啊,今天工作上需要用到,请教了别人,做以备忘

DROP PROCEDURE test_insert ;
DELIMITER ;;
CREATE PROCEDURE test_insert ()
BEGIN

DECLARE i INT DEFAULT 0;

WHILE i<10
DO
INSERT INTO CMS.CMS_Module
(
ModuleType,
ModuleName,
ModuleDescription,
DesignHTML,
QUERY
)
VALUES
(
'2',
CONCAT('活动',i),
'测试加入',
'aaaaaaaaaa',
''
);
SET i=i+1;
END WHILE ;

END;;

CALL test_insert();
   

written by ocean

9月 02

Set ExcelApp = CreateObject("Excel.Application")
Set ExcelSheet = createobject("Excel.Sheet")
ExcelSheet.ActiveSheet.Cells(1,1).Value = "My Vbscript"
ExcelSheet.SaveAs("C:\111.XLS")
ExcelSheet.Application.Quit()

将这些代码复制到记事本中,然后另存为所有文件,文件名叫1.vbs
然后双击一下,在c盘就会出现一个xls文件,

将其中的代码改成你的代码即可,完全支持EXCEL中的VBA,无论安全性高与中,都可运行,还可以利用FSO,WSCRIPT等模型操纵硬盘文件,注册表,哇靠,世界太美好了~~

written by ocean