| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1660 人关注过本帖
标题:C#与电脑的红外通信
只看楼主 加入收藏
wenkiller
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-5-9
收藏
 问题点数:0 回复次数:16 
C#与电脑的红外通信
各位大哥,小弟最近在做一个手机与电脑的红外通信功能的程序。可是不知道怎么用C#进行红外通信的编写。希望各位大虾指点迷津。
搜索更多相关主题的帖子: 通信 红外 手机 
2006-09-25 21:05
永鹏在线
Rank: 1
等 级:新手上路
帖 子:97
专家分:0
注 册:2006-7-8
收藏
得分:0 

一般的串口通信方式就可以,就是在串口外边要有红外转换电路!

2006-09-26 09:03
yts111
Rank: 1
等 级:新手上路
帖 子:79
专家分:0
注 册:2006-5-17
收藏
得分:0 
关注,大虾快来呀

希望能和大家交流一起进步我的QQ:274405946 欢迎加我
2006-09-26 09:04
chenjin145
Rank: 1
等 级:禁止访问
帖 子:3922
专家分:0
注 册:2006-7-12
收藏
得分:0 
如第二樓的

就是個com口而已

[url=javascript:alert(1);] [div]fdgfdgfdg\" on\"[/div] [/url]
2006-09-26 09:07
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
我也没见过啊,有没有大侠提供些代码来见识见识?
2006-09-26 09:13
永鹏在线
Rank: 1
等 级:新手上路
帖 子:97
专家分:0
注 册:2006-7-8
收藏
得分:0 
串口通信你没做过吗?可以去参考一下这方面的书籍,比较简单的!
2006-09-26 09:19
CrazyWeed0907
Rank: 2
等 级:新手上路
威 望:5
帖 子:1385
专家分:0
注 册:2006-5-30
收藏
得分:0 

我看有些资料也能用socket做的,不过我没做过,好像有个特殊的地址


“十步杀一人,千里不留行。事了拂衣去,深藏身与名。”
2006-09-26 12:26
wenkiller
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-5-9
收藏
得分:0 
socket关于网络通信的我已经做好了,就差红外通信的。哪个大虾给点代码阿

我现在正在读研究生,有热爱学习的朋友愿意交流请加我。360187438
2006-09-27 17:30
wenkiller
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-5-9
收藏
得分:0 

刚刚自己从一些资料中找到一点用C#编写红外通信的,希望对大家有用。本人还没有来得及仔细看,先发过来给大家共享。
using System;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.WindowsCE.Forms;

namespace MySquirtCF
{
/// <summary>
/// Summary description for MyMsgWindow.
/// </summary>
public class MyMsgWindow : MessageWindow
{
public MyMsgWindow()
{
//
// TODO: Add constructor logic here
//
}
public string Text
{
get
{
StringBuilder sbText = new StringBuilder (256);
GetWindowText (this.Hwnd, sbText, sbText.Capacity);
return sbText.ToString();
}
set
{
SetWindowText (this.Hwnd, value);
}
}
public static IntPtr FindOtherWindow (string strTitle)
{
return FindWindow (null, strTitle);
}
protected override void WndProc(ref Message m)
{
base.WndProc (ref m);
}

/// <summary>
/// Returns true when running on a Pocket PC
/// </summary>
/// <returns></returns>
public static bool IsPocketPC ()
{
bool fPocketPC = false;
StringBuilder sb = new StringBuilder (256);
PrivGetPlatString (257, sb.Capacity, sb, 0);
string strPlat = sb.ToString();
if (strPlat == "PocketPC")
fPocketPC = true;
return fPocketPC;
}
// Used by IsPocketPC routine to get the platform string
[DllImport ("Coredll.dll", EntryPoint="SystemParametersInfoW")]
private static extern bool PrivGetPlatString (int Cmd,
int StrLen, StringBuilder strPlat, int fWinIni);

[DllImport ("coredll.dll", EntryPoint="FindWindowW")]
private static extern IntPtr FindWindow (string strClass,
string strTitle);

[DllImport ("coredll.dll", EntryPoint="SetWindowTextW")]
private static extern void SetWindowText (IntPtr h, string s);

[ DllImport( "coredll.dll", EntryPoint="GetWindowTextW")]
public static extern int GetWindowText (IntPtr h,
StringBuilder sysDirBuffer, int size );

}
}


我现在正在读研究生,有热爱学习的朋友愿意交流请加我。360187438
2006-09-27 17:37
wenkiller
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-5-9
收藏
得分:0 

紧接上面的代码
Form1.cs
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Net.Sockets;
using System.IO;
using System.Text;
using System.Threading;

namespace MySquirtCF
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.Button btnGo;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnBrowse;
private System.Windows.Forms.TextBox textFileName;
private System.Windows.Forms.ListBox listOut;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private Microsoft.WindowsCE.Forms.InputPanel inputPanel1;

private bool m_fPocketPC;
private bool isRunning;
private Thread thServ;
private MenuItem menuFile;
private MenuItem menuExit;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

// See if we're running on a Pocket PC
if (MyMsgWindow.IsPocketPC())
m_fPocketPC = true;

if (m_fPocketPC)
{
// On a Pocket PC, adjust control position since
// Commandbar isn't used.

this.label1.Location = new Point (4, 5);
this.textFileName.Location = new Point (46, 4);
this.btnBrowse.Location = new Point (4, 30);
this.btnGo.Location = new Point (100, 30);
this.listOut.Location = new Point (4, 54);
// Set size of listbox depending on SIP
int height = this.inputPanel1.VisibleDesktop.Height -
this.listOut.Top;
if (!this.inputPanel1.Enabled)
height -= 26;
this.listOut.Size = new Size (this.listOut.Width, height);

// Place OK button on Nav Bar to close application
this.ControlBox = true;
this.MinimizeBox = false;

}
else
{
// On an embedded device, add a File | Exit menu item
menuFile = new MenuItem();
menuExit = new MenuItem();

menuExit.Text = "Exit";
menuExit.Click += new EventHandler(menuExit_Click);

menuFile.Text = "File";
menuFile.MenuItems.Add (menuExit);

mainMenu1.MenuItems.Add (menuFile);

}
int widthC = this.ClientRectangle.Width;
int heightC = this.ClientRectangle.Height;
this.Text = "IrSquirt";
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.btnGo = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.textFileName = new System.Windows.Forms.TextBox();
this.btnBrowse = new System.Windows.Forms.Button();
this.listOut = new System.Windows.Forms.ListBox();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.inputPanel1 = new Microsoft.WindowsCE.Forms.InputPanel();
//
// btnGo
//
this.btnGo.Location = new System.Drawing.Point(160, 58);
this.btnGo.Size = new System.Drawing.Size(80, 20);
this.btnGo.Text = "Send";
this.btnGo.Click += new System.EventHandler(this.btnGo_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 33);
this.label1.Size = new System.Drawing.Size(32, 20);
this.label1.Text = "File:";
//
// textFileName
//
this.textFileName.Location = new System.Drawing.Point(48, 32);
this.textFileName.Size = new System.Drawing.Size(192, 22);
this.textFileName.Text = "";
//
// btnBrowse
//
this.btnBrowse.Location = new System.Drawing.Point(8, 58);
this.btnBrowse.Size = new System.Drawing.Size(80, 20);
this.btnBrowse.Text = "Browse";
this.btnBrowse.Click += new
System.EventHandler(this.btnBrowse_Click);
//
// listOut
//
this.listOut.Location = new System.Drawing.Point(8, 82);
this.listOut.Size = new System.Drawing.Size(232, 198);
//
// inputPanel1
//
this.inputPanel1.EnabledChanged += new
System.EventHandler(this.inputPanel1_EnabledChanged);
//
// Form1
//
this.ClientSize = new System.Drawing.Size(250, 292);
this.Controls.Add(this.listOut);
this.Controls.Add(this.btnBrowse);
this.Controls.Add(this.textFileName);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnGo);
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.Text = "Form1";
this.Closing += new
System.ComponentModel.CancelEventHandler(this.Form1_Closing);
this.Load += new System.EventHandler(this.Form1_Load);

}
#endregion


我现在正在读研究生,有热爱学习的朋友愿意交流请加我。360187438
2006-09-27 17:38
快速回复:C#与电脑的红外通信
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012256 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved