永远的SKYFEI
喜欢在阳光下,光着脊梁,挥汗如雨地工作,每次回头擦汗,看到的都是成就!
posts - 60,  comments - 113,  trackbacks - 3

using Microsoft.Win32;

 

 

     RegistryKey regKey  RegistryKey.FromHandle(Registry.LocalMachine.Handle, RegistryView.Registry64);
             regKey.OpenSubKey(
"****");

 

posted @ 2011-06-10 14:51 skyfei 阅读(177) 评论(0) 编辑

step1: reconstruct the WebClient class

 

public class MyWebClient : WebClient
    {
        
protected override WebRequest GetWebRequest(Uri address)
        {
            HttpWebRequest request 
= base.GetWebRequest(address) as HttpWebRequest;
            request.Timeout 
= -1;
            request.CachePolicy 
= new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
            request.AllowWriteStreamBuffering 
= false;
            
return request;
        }
    }

Step2: use new WebClient as the WebClient

 

                WebClient web = new MyWebClient();
                web.UploadFileCompleted 
+= new UploadFileCompletedEventHandler(web_UploadFileCompleted);
                web.UploadProgressChanged 
+= new UploadProgressChangedEventHandler(web_UploadProgressChanged);
                FileInfo fi 
= new FileInfo(@"D:\VirtualBox VMs\VMxp\VMxp.vdi");
                Uri uri 
= new Uri("http://127.0.0.1:9090/upload");
                web.UploadFileAsync(uri, fi.FullName);

 

 

posted @ 2011-04-08 10:46 skyfei 阅读(70) 评论(0) 编辑

steps:

open the window code page, and find the construction function;

add code like below:

 

 public MainWindow()
        {
            InitializeComponent();

            
// Create the CommandBinding.
            CommandBinding cmd = new CommandBinding();
            cmd.Command 
= ApplicationCommands.New;

            cmd.Executed 
+= new ExecutedRoutedEventHandler(CommandBinding_CmdKey_Executed);
            cmd.CanExecute 
+= new CanExecuteRoutedEventHandler(CommandBinding_CmdKey_CanExecute);
            
this.CommandBindings.Add(cmd);
            
// Creating a KeyBinding between the Open command and Ctrl-R
            KeyBinding CmdKey = new KeyBinding();
            CmdKey.Key 
= Key.F;
            CmdKey.Modifiers 
= ModifierKeys.Control;
            CmdKey.Command 
= cmd.Command;
            
this.InputBindings.Add(CmdKey);
        }
        
private void CommandBinding_CmdKey_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute 
= true;
        }

        
private void CommandBinding_CmdKey_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            MessageBox.Show(
"OK");
        }

 

posted @ 2011-04-08 10:07 skyfei 阅读(122) 评论(0) 编辑

we can get the all the adroid device information with adb, see below picture:

 

 

 

posted @ 2011-02-12 15:35 skyfei 阅读(176) 评论(1) 编辑

In android vcard file, the QuotedPrintable string will be like:

 ENCODING=QUOTED-PRINTABLE:=E9=A3=9E;=E5=88=98;=E7=A7=8D;=E5=85=88=E7=94=9F;=E5=8F=B7

while in the outlook vcard, it will like:

ENCODING=QUOTED-PRINTABLE:=E5=95=8A=E5=95=8A

 

that mean that the android will not encode the normail char

so update one decode method, which I find in the internet:

 

代码
/// <summary>   
        
/// Decodes a QuotedPrintable encoded string    
        
/// 
        
/// </summary>   
        
/// <param name="_ToDecode">The encoded string to decode</param>   
        
/// <returns>Decoded string</returns>   
        public static string DecodeTest(string _ToDecode, string encoderName)
        {
            
//remove soft-linebreaks first   
            
//_ToDecode = _ToDecode.Replace("=\r\n", "");   

            Encoding encoding;
            
if (string.IsNullOrEmpty(encoderName))
            {
                encoding 
= Encoding.Default;
            }
            
else
            {
                
try
                {
                    encoding 
= Encoding.GetEncoding(encoderName);
                   
// encoding = Encoding.Default;
                }
                
catch
                {
                    encoding 
= Encoding.Default;
                }
            }

            
char[] chars = _ToDecode.ToCharArray();

        
//    byte[] bytes = new byte[chars.Length];
            List<byte> bytes = new List<byte>();
            
int bytesCount = 0;

            StringBuilder sb 
= new StringBuilder();

            
string Hex = string.Empty;
            
bool flag = false;
            
foreach (char c in chars)
            {
                
if (c == '=')
                {
                    flag 
= true;
                }
                
else
                {
                    
if (flag)
                    {
                        Hex 
+= c;
                        
if (Hex.Length == 2)
                        {
                            bytes.Add(System.Convert.ToByte(
int.Parse(Hex, System.Globalization.NumberStyles.HexNumber)));
                            Hex 
= string.Empty;
                            flag 
= false;
                        }
                    }
                    
else
                    {
                        
if (bytes.Count >0)
                        {
                            sb.Append( encoding.GetString(bytes.ToArray(), 
0, bytes.Count));
                            bytes.Clear();
                        }
                        sb.Append(c);
                    }
                }
            }

            
if (bytes.Count > 0)
            {
                sb.Append(encoding.GetString(bytes.ToArray(), 
0, bytes.Count));
                bytes.Clear();
            }

            
// original code
            
//for (int i = 0; i < chars.Length; i++)
            
//{
            
//    // if encoded character found decode it   
            
//    if (chars[i] == '=')
            
//    {
            
//        bytes[bytesCount++] = System.Convert.ToByte(int.Parse(chars[i + 1].ToString() + chars[i + 2].ToString(), System.Globalization.NumberStyles.HexNumber));

            
//        i += 2;
            
//    }
            
//    else
            
//    {
            
//        bytes[bytesCount++] = System.Convert.ToByte(chars[i]);
            
//    }
            
//}

            
//return System.Text.Encoding.Default.GetString(bytes, 0, bytesCount);   
            
//return encoding.GetString(bytes, 0, bytesCount);
            return sb.ToString();
        }

 

 

posted @ 2010-12-23 14:48 skyfei 阅读(118) 评论(0) 编辑
摘要: Win From Version:代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Management;usingSystem.Runtime.InteropServices;namespaceSyncContac阅读全文
posted @ 2010-12-23 14:41 skyfei 阅读(509) 评论(1) 编辑
摘要: 原帖:http://www.vckbase.com/document/viewdoc/?id=1708八、线程的同步  虽然多线程能给我们带来好处,但是也有不少问题需要解决。例如,对于像磁盘驱动器这样独占性系统资源,由于线程可以执行进程的任何代码段,且线程的运行是由系统调度自动完成的,具有一定的不确定性,因此就有可能出现两个线程同时对磁盘驱动器进行操作,从而出现操作错误;又例如,对于银行系统的计算...阅读全文
posted @ 2009-12-23 16:00 skyfei 阅读(95) 评论(0) 编辑
摘要: 我上一篇随笔转了一篇C# 面试题合集(转:C# Interview Questions ), 但感觉还有些没有覆盖到, 有些是我平时没有注意到的, 特补充一下. 答案是我自己网络搜集理解, 不代表正确答案: 1. 线程之间如何通讯一般而言,应用程序中的一个次要线程总是为主线程执行特定的任务,这样,主线程和次要线程间必定有一个信息传递的渠道,也就是主线程和次要线程间要进行通信。这种线程间的通信不但是...阅读全文
posted @ 2009-12-23 15:47 skyfei 阅读(211) 评论(0) 编辑
摘要: 转自: http://blogs.crsw.com/mark/articles/252.aspxC# Interview QuestionsThis is a list of questions I have gathered from other sourcesand created myselfover a period of time from my experience, many of ...阅读全文
posted @ 2009-11-10 12:28 skyfei 阅读(181) 评论(0) 编辑
摘要: 在cell中如果cell中的文本有换行符, 默认是不显示换行的, 只有点了excel 工具栏中的“Wrap Text" 按钮, 才会显示换行, 见下图:这个效果, 可以通过设置openxml的 style sheet 来实现。[代码]在创建stylesheet时, 必须创建fonts, Fills,Borders 和cellXfs(CellFormats)四个节点, 在显示cell是通...阅读全文
posted @ 2009-07-16 12:12 skyfei 阅读(2401) 评论(5) 编辑
仅列出标题  下一页