制作MSN机器人,如何使用Vc.Net调用C#编写的.net库
我想编写一个MSN机器人,并找到相应的MSN协议库,就可以不用研究MSN的协议了。但此MSN协议库(DotMsn)是用C#编写的.net的库,我现在由于对C#不熟悉,还想用VC编写。
所以决定使用VC.net,来调用此.net的库。
但是我并不太清楚,VC.net如何来调用此.net的库(DotMsn)
不知哪位能提供一个例子程序,如何调用.net的库
下面是C#调用此库的例子程序的部分代码
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using DotMSN;
namespace dotMSNFramework
{
public class Form1 : System.Windows.Forms.Form
{
#region Variables
private System.Windows.Forms.TextBox Log;
private System.Windows.Forms.Button StartButton;
private System.Windows.Forms.TextBox mailTextBox;
private System.Windows.Forms.TextBox passTextBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button showlistButton;
private System.Windows.Forms.ListView contactListView;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button SendFileButton;
private System.ComponentModel.Container components = null;
#endregion
#region Standard windows.forms code
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
// this object will be the inte易做图ce to the dotMSN library
private DotMSN.Messenger messenger = new Messenger();
// Called when the button 'Connected' is clicked
private void StartMSN()
{
messenger = new Messenger();
try
{
// make sure we don't use the default settings, since they're invalid
if(mailTextBox.Text == "yourmail@hotmail.com")
MessageBox.Show(this, "Fill in your own passport details to connect to the messenger service");
else
{
// setup the callbacks
// we log when someone goes online
messenger.ContactOnline += new Messenger.ContactOnlineHandler(ContactOnline);
// we want to do something when we have a conversation
messenger.ConversationCreated += new Messenger.ConversationCreatedHandler(ConversationCreated);
// notify us when synchronization is completed
messenger.SynchronizationCompleted += new Messenger.SynchronizationCompletedHandler(OnSynchronizationCompleted);
// everything is setup, now connect to the messenger service
messenger.Connect(mailTextBox.Text, passTextBox.Text);
Log.Text += "Connected!\r\n";
// synchronize the whole list.
// remember you can only do this once per session!
// after synchronizing the initial status will be set.
messenger.SynchronizeList();
/* uncomment this when you want to automatically add
* people who have added you to their contactlist on your own
* contactlist. (remember the pop-up dialog in MSN Messenger client when someone adds you, this is the 'automatic' method)
foreach(Contact contact in
messenger.GetListEnumerator(MSNList.ReverseList))
{
messenger.AddContact(contact.Mail);
}
*/
}
}
catch(MSNException e)
{
// in case of an error, report this to the user (or developer)
MessageBox.Show(this, "Connecting failed: " + e.ToString());
}
}
--------------------编程问答-------------------- vc.net 打开clr支持,引用c#的库
--------------------编程问答-------------------- 是不是用项目->Visual C++ ->CLR ->窗体应用程序
用这种VC++才可以调用呀
补充:.NET技术 , VC.NET