1

有人在 c# 中使用过 YMSGPro.OCX 吗?我怎样才能连接到雅虎呢?

如果不使用,为什么我会出现此错误 -User of unassigned local variable 'js'- ?

YMSGClass ys;
string username="m.moh3en1375";
string password="mypw";
string host = "a";
string port = "2800";
string amoo = "";
string hole = "";
ys.Connect(ref username,ref password,ref host,ref port,ref amoo,ref hole);

这也是错误的:

YMSGClass ys = new YMSGClass();
4

2 回答 2

0

你需要的是这个。 https://github.com/klog/ycs

我发现了一些关于这个 OCX 的 VB6 代码。将它转换为 C# 会很容易。这是使用此 OCX 的某种 Yahoo Chatroom 客户端

Private Sub Command1_Click () 
Call YMSG1.Connect (User.Text, Pass.Text) 
End Sub 

Private Sub Command2_Click () 
Call YMSG1.PckChangeStatus (TXTST.Text, False) 
End Sub 

Private Sub Command3_Click () 
Call YMSG1.PckSendTextRoom (pmtoroom.Text) 
End Sub 

Private Sub Command4_Click () 
List1.Clear 

Call YMSG1.PckJoindRoom (Toroom.Text) 


End Sub 

Private Sub Command5_Click () 
Call YMSG1.PckLeftRoom 
End Sub 


Private Sub Form_Load () 
Call YMSG1.Invisible (True) 

End Sub 

Private Sub lblst_Change () 
If lblst.Caption = "login." Then 
YMSG1.ConvertFarsi = True 
YMSG1.FilterMessage = True 
End If 
End Sub 

Private Sub mnuAbut_Click () 
abut.Show 
End Sub 

Private Sub Timer1_Timer () 
On Error GoTo Eror 
Call YMSG1.PckSendTextRoom (PM2Room.Text) 
Eror: 
End Sub 

Private Sub YMSG1_IncomingAddRequest (ByVal From As String, ByVal ToUser As String, ByVal Message As String, ByVal SenderName As Variant, ByVal SenderLastName As String, ByVal AutoAdd As Boolean) 
YMSG1.PckAcceptAdd From, ToUser 
Call YMSG1.PckSendMsg (From, txtadd.Text) 
End Sub 

Private Sub YMSG1_IncomingAppear (ByVal User As String, ByVal Status As YMSGMode_V2.StatusYID, Messege As String) 
If Status = Available Then Call YMSG1.PckSendMsg (User, txtOnline.Text) 
End Sub 

Private Sub YMSG1_IncomingCaptcha (ByVal PictureLink As String, ByVal DATA As String) 
Form2.Web.Navigate "http://captcha.chat.yahoo.com/go/captchat/?img =" & PictureLink & "&. Intl = us &. Lang = en-US" 
Form2.Show 
Timer1.Interval = "30000" 
End Sub 

Private Sub YMSG1_IncomingChatList (ByVal ChatterLst As String, ByVal Status As YMSGMode_V2.StatusRoom, ByVal DATA As String) 
If Status = Joind Then 
List1.AddItem ChatterLst 
List2.AddItem ChatterLst & "Join Room" 
Call YMSG1.PckSendMsg (ChatterLst, txtWel.Text) 


lblUser.Caption = "Users:" & List1.ListCount 
ElseIf Status = Leave Then 
List2.AddItem ChatterLst & "Left Room" 
Call YMSG1.PckSendMsg (ChatterLst, txtWel.Text) 

For i = 0 To List1.ListCount - 1 
If List1.List (i) = ChatterLst Then 
List1.RemoveItem i 
End If 
Next i 
lblUser.Caption = "Users:" & List1.ListCount 
ElseIf Status = RoomFull Then 
MsgBox ("Room The Full") 
End If 


End Sub 

Private Sub YMSG1_IncomingMessage (ByVal From As String, ByVal ToUser As String, ByVal TextMessage As String) 
Call YMSG1.PckSendMsg (From, txtrespones.Text) 
End Sub 

Private Sub YMSG1_IncomingRoomTxtMessage (ByVal FromUser As String, ByVal Msg As String, ByVal Client As String, ByVal RoomName As String, ByVal DATA As String) 
List2.AddItem FromUser & ":" & Msg 
End Sub 

Private Sub YMSG1_Status (ByVal MsgStatus As String, ByVal Status As String, ByVal Connecting As Boolean) 
lblst.Caption = MsgStatus 
End Sub

这是一些图片 在此处输入图像描述 在此处输入图像描述 在此处输入图像描述 在此处输入图像描述 在此处输入图像描述

于 2013-08-09T21:32:45.153 回答
0

感谢您的回答,但我不知道 VB6 。

这是我的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using YMSGPro;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            YMSGClass ym = null;
            string username = "m.mohsen1375";
            string password = "pw";
            ym.Connect(ref username, ref password);
        }
    }
}

问题是编译器需要连接方法的所有 6 个参数,而在您的代码中,您只需插入用户名和密码(2 个参数)。

看这里是编译器的错误:

方法 'Connect' 没有重载需要 '2' 参数。

谢谢 !

于 2013-08-10T07:03:29.897 回答