[zt]再談QQ自動登陸器:提供C#源碼下載(下)

上次提到的QQ自動登陸器C++版本,其技術太過低級,但是所用方法在其他的應用中作用強大,尤其是外掛程序。其實就QQ登錄來說有其接口的,用C#代碼描述就一條語句:
1Process.Start(qqPath, "/START QQUIN:" + strAcntNum + " PWDHASH:" + strAcntPsw + " /STAT:" + (blAcntSts ? "40" : "41")); 2
其中 qqPath爲QQ程序路徑,strAcntNum爲QQ號碼,strAcntPsw爲QQ的Hash值,布爾類型blAcntSts爲登錄狀態,即是否隱身。     簡單吧,看來QQ自動登陸器是沒有技術含量了,今天就設計過程中的其他技術作一介紹: (1)註冊表中添加QQ程序路徑和登陸器程序打開密碼
 1        public static string SetQQRegistryValue(string key, object value)  2        {  3            RegistryKey pregkey = Registry.CurrentUser.OpenSubKey(Constants.STR_QQ_REG_PATH, true);  4            if (pregkey == null)  5            {  6                pregkey = Registry.CurrentUser.CreateSubKey(Constants.STR_QQ_REG_PATH, RegistryKeyPermissionCheck.ReadWriteSubTree);  7                pregkey.SetValue(key, string.Empty);  8                pregkey.Close();  9                return string.Empty; 10            } 11            else 12            { 13                pregkey.SetValue(key, value); 14                pregkey.Close(); 15                return value.ToString(); 16            } 1718        } 1920        public static string GetQQRegistryValue(string key) 21        { 22            RegistryKey pregkey = Registry.CurrentUser.OpenSubKey(Constants.STR_QQ_REG_PATH, true); 23            if (pregkey == null) 24            { 25                pregkey = Registry.CurrentUser.CreateSubKey(Constants.STR_QQ_REG_PATH, RegistryKeyPermissionCheck.ReadWriteSubTree); 26            } 27            object value = pregkey.GetValue(key); 28            pregkey.Close(); 29            if (value == null) 30            { 31                return string.Empty; 32            } 33            else 34            { 35                return value.ToString(); 36            } 37        } 38
(2)序列化QQ帳號信息到文件
 1public static List<QQAccount> Get(string path)  2        {  3            if (qqInfoList == null)  4            {  5                FileStream fs = null;  6                try  7                {  8                    XmlSerializer xs = new XmlSerializer(typeof(List<QQAccount>));  9                    fs = new FileStream(path, FileMode.Open, FileAccess.Read); 10                    qqInfoList = (List<QQAccount>)xs.Deserialize(fs); 11                    fs.Close(); 12                    return qqInfoList; 13                } 14                catch 15                { 16                    if (fs != null) 17                        fs.Close(); 18                    return null; 19                } 2021            } 22            else 23            { 24                return qqInfoList; 25            } 26        } 2728public static void Set(string path, List<QQAccount> qqList) 29        { 30            if (qqList == null) 31                throw new Exception("Parameter is null!"); 3233            FileStream fs = null; 34            try 35            { 36                XmlSerializer xs = new XmlSerializer(typeof(List<QQAccount>)); 37                fs = new FileStream(path, FileMode.Create, FileAccess.Write); 38                xs.Serialize(fs, qqList); 39                fs.Close(); 40            } 41            catch 42            { 43                if (fs != null) 44                    fs.Close(); 45                throw new Exception("Xml serialization failed!"); 46            } 47        }
(3)Hash處理登錄密碼
 1        public static string HashBase64(string str)  2        {  3            byte[] result = new byte[str.Length];  4            try  5            {  6                MD5 md = new MD5CryptoServiceProvider();  7                result = md.ComputeHash(System.Text.Encoding.UTF8.GetBytes(str));  8                return Convert.ToBase64String(result);  9            } 10            catch 11            { 12                return ""; 13            } 14        } 15
如下提供源碼下載,作的粗糙,原諒!如有更好的建議請留言! 源碼下載
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章