/// <summary> /// 发送文件 /// </summary> /// <param name="filename"></param> private void SendFile(string filename) { TLQ_ID tlqId = new TLQ_ID(); bool online = tlqInterface.tlq_login(ref tlqId, ProgramNO, 0) >= 0; if (online) { // string filename = textBox1.Text;// "readme.txt"; TLQMSG_INFO msginfo = new TLQMSG_INFO(); msginfo.CompressFlag = 0;//1压缩,0不压缩 msginfo.Expiry = -1;//生命周期-1,为无限若Expiry>0, 要求发送消息的生命周期大于[system]中的核心检测周期TimeV msginfo.MsgLen = filename.Length;//消息的长度,若MsgType 为BUF_MSG 类型时,则为消息内容;若MsgType 为FILE_MSG 类型时,则为文件消息的文件名。 msginfo.MsgType = 1;//文件为1,数据报为0 msginfo.RemoveFileFlag = 1;//1删除原文件,0不删除 msginfo.CryptFlag = 0;//0不加密,1加密 msginfo.PriorNo = PriorNo;//配置的优先及 msginfo.QueName = QueName;//消息队列名 int ti = tlqInterface.tlq_putmsg(ref tlqId, ref msginfo, filename, 0); // MessageBox.Show(ti.ToString()); tlqInterface.tlq_logout(ref tlqId); } }
private void button6_Click(object sender, EventArgs e) { //TLQMSG_INFO msg = new TLQMSG_INFO(); //bool connected = false; // this get //Process myProcess = Process.GetProcessesByName("ChachMessage")[0]; //Process myProcess = Process.GetCurrentProcess(); //int thisid = myProcess.Id; //System.Windows.Forms.MessageBox.Show(myProcess.Id + ":" + myProcess.ProcessName); TLQ_ID tlqId = new TLQ_ID(); bool online = tlqInterface.tlq_login(ref tlqId, ProgramNO, 0) >= 0; if (online) { string filename = textBox1.Text;// "readme.txt"; TLQMSG_INFO msginfo = new TLQMSG_INFO(); msginfo.CompressFlag = 0;//1压缩,0不压缩 msginfo.Expiry = -1;//生命周期-1,为无限若Expiry>0, 要求发送消息的生命周期大于[system]中的核心检测周期TimeV msginfo.MsgLen = filename.Length;//消息的长度,若MsgType 为BUF_MSG 类型时,则为消息内容;若MsgType 为FILE_MSG 类型时,则为文件消息的文件名。 msginfo.MsgType = 1;//文件为1,数据报为0 msginfo.RemoveFileFlag = 1;//1删除原文件,0不删除 msginfo.CryptFlag = 0;//0不加密,1加密 msginfo.PriorNo = PriorNo;//配置的优先及 msginfo.QueName = QueName;//消息队列名 int ti = tlqInterface.tlq_putmsg(ref tlqId, ref msginfo, filename, 0); MessageBox.Show(ti.ToString()); tlqInterface.tlq_logout(ref tlqId); } }