csharp Send Skype messages from webform and winform
2012-07-25 17:41
330 查看
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using SKYPE4COMLib; //下載地址:http://en.sourceforge.jp/projects/sfnet_skype4mp/downloads/Skype4MP/obj/Release/Interop.SKYPE4COMLib.dll/ namespace ListBoxDemo { /// <summary> /// skype 發送信息,也可以用在WinForm /// Geovin Du 塗聚文 /// 締友計算機信息技術有限公司 /// 20120725 /// /// </summary> public partial class _Default : System.Web.UI.Page { string strskypeuser = string.Empty; string strskypeid = string.Empty; /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //1 Geovin Du 塗聚文 BindSmartListBox(); //2 Geovin Du 塗聚文 //this.ListBox1.DataSource = skyuselist(); //this.ListBox1.DataTextField = "userDisplayName"; //this.ListBox1.DataValueField = "userLoginName"; //this.ListBox1.DataBind(); } } /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { //1 //strskypeuser = ListBox1.SelectedItem.Text; //strskypeid = ListBox1.SelectedValue.ToString(); //2 // strskypeuser = ListBox1.SelectedItem.Text; strskypeid = ListBox1.SelectedValue.ToString(); this.TextBox2.Text = strskypeid; SKYPE4COMLib.Skype oSkype = new SKYPE4COMLib.Skype(); if (!string.IsNullOrEmpty(strskypeid)) { oSkype.SendMessage(strskypeid, strskypeuser + ":" + this.TextBox1.Text); } else { oSkype.SendMessage("ginhongzhao", strskypeuser + ":" + this.TextBox1.Text); } } /// <summary> /// 初始化物件,預設會抓本機的Skype帳號資訊 /// </summary> private void BindSmartListBox() { SKYPE4COMLib.Skype oSkype = new SKYPE4COMLib.Skype(); UserCollection tFriends = oSkype.Friends; ListItem li =null; foreach (User tUser in oSkype.Friends) { if (tUser.FullName.Trim() != "") { li = new ListItem(tUser.FullName, tUser.Handle); ListBox1.Items.Add(li); } else { li = new ListItem(tUser.Handle, tUser.Handle); ListBox1.Items.Add(li); } } } /// <summary> /// 初始化物件,預設會抓本機的Skype帳號資訊 /// </summary> /// <returns></returns> private DataTable skyuselist() { DataTable d = new DataTable(); //初始化物件,預設會抓本機的Skype帳號資訊 SKYPE4COMLib.Skype oSkype = new SKYPE4COMLib.Skype(); UserCollection tFriends = oSkype.Friends; d.Columns.Add("userLoginName", typeof(string)); d.Columns.Add("userDisplayName", typeof(string)); //取出所有的朋友資訊 foreach (User tUser in oSkype.Friends) { if (tUser.FullName.Trim() != "") { d.Rows.Add(tUser.Handle, tUser.FullName); } else { d.Rows.Add(tUser.Handle, tUser.Handle); } } return d; } } }
相关文章推荐
- csharp Send Skype messages from webform and winform
- csharp Send Skype messages from webform and winform
- How to: Send and Receive Large Amounts of Data to and from a Web Service
- csharp skype send message in winform
- C# UrlEncode(WinForm and WebForm)
- Sofire v1.0 开源——WinForm/SL/WebForm 的 Remoting(1)
- Csharp:WebClient and WebRequest use http download file
- ImageMagick Tricks: Web Image Effects from the Command Line and PHP
- Get data from specified URI using WebRequest and WebResponse(读取网页数据并存入对应html文档)
- Webservice error, "The test form is only available for requests from the local machine"
- How to build a Bot Trap and keep bad bots away from a web site
- Csharp:WebClient and WebRequest use http download file
- 利用webservice和.net技术上传和下载文件--Sending files in chunks with MTOM Web Services and .NET 2.0 from:http://www.codeproject.com/soap/MTO
- Csharp windowform datagridview TO EXCEL OR FROM EXCEL DATA 保存datagridview所有數據
- 20100811 学习记录2:Webservice error, "The test form is only available for requests from the local machine"
- \t\tSeparation of form and content(形式与内容的分离)--[xml&xsl在web网页中的应用]
- Csharp: Create Excel Workbook or word from Template File using aspose.Word 14.5 and aspose.Cell 8.1
- Csharp:WebClient and WebRequest use http download file
- C# Label显示多行文本及换行(WinForm/WebForm)
- Spring Security HTTP Basic for RESTFul and FormLogin (Cookies) for web - Annotations