5-8万年薪顶级嵌入式,京沪深就业地 浅谈并行编程中的任务分解模式
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  C#

用C#怎么做电话拨号程序

楼主IamDinosaur(恐龙)2006-01-04 22:15:00 在 .NET技术 / C# 提问

以前在C++Builder   用Win32   Api   CreateFile("COM1",....),WRITE(...),结合AT   DT   等命令做了一个电话拨号程序,能过MODEM拨打电话,用以代替电话机键盘拨号。  
  现在在VS.NET   C#中,做相同的Win32API调,怎么不行了!!!!  
  哪位有这方面的例子程序,谢了! 问题点数:20、回复次数:1Top

1 楼lxcc()回复于 2006-01-04 23:27:40 得分 0

Public   Class   Form1  
          Inherits   System.Windows.Forms.Form  
   
  #Region   "   Windows   窗体设计器生成的代码   "  
   
          Public   Sub   New()  
                  MyBase.New()  
   
                  '该调用是   Windows   窗体设计器所必需的。  
                  InitializeComponent()  
   
                  '在   InitializeComponent()   调用之后添加任何初始化  
   
          End   Sub  
   
          '窗体重写   dispose   以清理组件列表。  
          Protected   Overloads   Overrides   Sub   Dispose(ByVal   disposing   As   Boolean)  
                  If   disposing   Then  
                          If   Not   (components   Is   Nothing)   Then  
                                  components.Dispose()  
                          End   If  
                  End   If  
                  MyBase.Dispose(disposing)  
          End   Sub  
   
          'Windows   窗体设计器所必需的  
          Private   components   As   System.ComponentModel.IContainer  
   
          '注意:   以下过程是   Windows   窗体设计器所必需的  
          '可以使用   Windows   窗体设计器修改此过程。  
          '不要使用代码编辑器修改它。  
          Friend   WithEvents   Label1   As   System.Windows.Forms.Label  
          Friend   WithEvents   TextBox1   As   System.Windows.Forms.TextBox  
          Friend   WithEvents   Button1   As   System.Windows.Forms.Button  
          Friend   WithEvents   Button2   As   System.Windows.Forms.Button  
          Friend   WithEvents   ListBox1   As   System.Windows.Forms.ListBox  
          Friend   WithEvents   Icon1   As   System.Windows.Forms.NotifyIcon  
          Friend   WithEvents   ContextMenu1   As   System.Windows.Forms.ContextMenu  
          Friend   WithEvents   MenuItem1   As   System.Windows.Forms.MenuItem  
          Friend   WithEvents   MenuItem2   As   System.Windows.Forms.MenuItem  
          <System.Diagnostics.DebuggerStepThrough()>   Private   Sub   InitializeComponent()  
                  Me.components   =   New   System.ComponentModel.Container  
                  Dim   resources   As   System.Resources.ResourceManager   =   New   System.Resources.ResourceManager(GetType(Form1))  
                  Me.Label1   =   New   System.Windows.Forms.Label  
                  Me.TextBox1   =   New   System.Windows.Forms.TextBox  
                  Me.Button1   =   New   System.Windows.Forms.Button  
                  Me.Button2   =   New   System.Windows.Forms.Button  
                  Me.ListBox1   =   New   System.Windows.Forms.ListBox  
                  Me.Icon1   =   New   System.Windows.Forms.NotifyIcon(Me.components)  
                  Me.ContextMenu1   =   New   System.Windows.Forms.ContextMenu  
                  Me.MenuItem1   =   New   System.Windows.Forms.MenuItem  
                  Me.MenuItem2   =   New   System.Windows.Forms.MenuItem  
                  Me.SuspendLayout()  
                  '  
                  'Label1  
                  '  
                  Me.Label1.Location   =   New   System.Drawing.Point(8,   8)  
                  Me.Label1.Name   =   "Label1"  
                  Me.Label1.Size   =   New   System.Drawing.Size(160,   16)  
                  Me.Label1.TabIndex   =   0  
                  Me.Label1.Text   =   "请输入你要拨的电话号码:"  
                  '  
                  'TextBox1  
                  '  
                  Me.TextBox1.Location   =   New   System.Drawing.Point(8,   24)  
                  Me.TextBox1.Name   =   "TextBox1"  
                  Me.TextBox1.Size   =   New   System.Drawing.Size(272,   21)  
                  Me.TextBox1.TabIndex   =   1  
                  Me.TextBox1.Text   =   ""  
                  '  
                  'Button1  
                  '  
                  Me.Button1.Location   =   New   System.Drawing.Point(24,   56)  
                  Me.Button1.Name   =   "Button1"  
                  Me.Button1.TabIndex   =   2  
                  Me.Button1.Text   =   "拨号"  
                  '  
                  'Button2  
                  '  
                  Me.Button2.Location   =   New   System.Drawing.Point(192,   56)  
                  Me.Button2.Name   =   "Button2"  
                  Me.Button2.TabIndex   =   3  
                  Me.Button2.Text   =   "退出"  
                  '  
                  'ListBox1  
                  '  
                  Me.ListBox1.ItemHeight   =   12  
                  Me.ListBox1.Location   =   New   System.Drawing.Point(8,   88)  
                  Me.ListBox1.Name   =   "ListBox1"  
                  Me.ListBox1.Size   =   New   System.Drawing.Size(272,   76)  
                  Me.ListBox1.TabIndex   =   4  
                  '  
                  'Icon1  
                  '  
                  Me.Icon1.ContextMenu   =   Me.ContextMenu1  
                  Me.Icon1.Icon   =   CType(resources.GetObject("Icon1.Icon"),   System.Drawing.Icon)  
                  Me.Icon1.Text   =   "电话拨号"  
                  Me.Icon1.Visible   =   True  
                  '  
                  'ContextMenu1  
                  '  
                  Me.ContextMenu1.MenuItems.AddRange(New   System.Windows.Forms.MenuItem()   {Me.MenuItem1,   Me.MenuItem2})  
                  '  
                  'MenuItem1  
                  '  
                  Me.MenuItem1.Index   =   0  
                  Me.MenuItem1.Text   =   "退出"  
                  '  
                  'MenuItem2  
                  '  
                  Me.MenuItem2.Index   =   1  
                  Me.MenuItem2.Text   =   "还原"  
                  '  
                  'Form1  
                  '  
                  Me.AutoScaleBaseSize   =   New   System.Drawing.Size(6,   14)  
                  Me.ClientSize   =   New   System.Drawing.Size(292,   174)  
                  Me.Controls.Add(Me.ListBox1)  
                  Me.Controls.Add(Me.Button2)  
                  Me.Controls.Add(Me.Button1)  
                  Me.Controls.Add(Me.TextBox1)  
                  Me.Controls.Add(Me.Label1)  
                  Me.Icon   =   CType(resources.GetObject("$this.Icon"),   System.Drawing.Icon)  
                  Me.Name   =   "Form1"  
                  Me.Text   =   "电话拨号"  
                  Me.ResumeLayout(False)  
   
          End   Sub  
   
  #End   Region  
   
          Private   Declare   Function   tapiRequestMakeCall   Lib   "tapi32.dll"   (ByVal   DestAddress   As   String,   ByVal   AppName   As   String,   ByVal   CalledParty   As   String,   ByVal   comment   As   String)   As   Integer  
          Const   TAPIERR_CONNECTED   As   Short   =   0  
          Const   TAPIERR_DROPPED   As   Short   =   -1  
          Const   TAPIERR_NOREQUESTRECIPIENT   As   Short   =   -2  
          Const   TAPIERR_REQUESTQUEUEFULL   As   Short   =   -3  
          Const   TAPIERR_INVALDESTADDRESS   As   Short   =   -4  
          Const   TAPIERR_DESTBUSY   As   Short   =   -11  
          Const   TAPIERR_UNKNOWNREQUESTID   As   Short   =   -15  
          Const   TAPIERR_REQUESTFAILED   As   Short   =   -16  
   
          Private   Sub   EnableDial()  
                  Button1.Enabled   =   Len(Trim(TextBox1.Text))   >   0  
          End   Sub  
   
          Sub   tapiStatus(ByRef   strres   As   Integer)  
                  Select   Case   strres  
                          Case   TAPIERR_CONNECTED  
                                  ListBox1.Items.Add("信息:拨号已连接!")  
                          Case   TAPIERR_INVALDESTADDRESS  
                                  ListBox1.Items.Add("错误:错误的目的地址!")  
                          Case   TAPIERR_NOREQUESTRECIPIENT  
                                  ListBox1.Items.Add("错误:没有电话接口程序运行!")  
                          Case   TAPIERR_REQUESTFAILED  
                                  ListBox1.Items.Add("错误:拨号请求由于未知原因失败!")  
                          Case   TAPIERR_DESTBUSY  
                                  ListBox1.Items.Add("错误:对方电话正忙!")  
                          Case   TAPIERR_UNKNOWNREQUESTID  
                                  ListBox1.Items.Add("错误:没有这个电话号码!")  
                          Case   TAPIERR_DROPPED  
                                  ListBox1.Items.Add("错误:对方已挂断!")  
                  End   Select  
          End   Sub  
          Private   Sub   Button1_Click(ByVal   sender   As   System.Object,   ByVal   e   As   System.EventArgs)   Handles   Button1.Click  
                  Dim   strPhoneNum   As   String  
                  Dim   res   As   Integer  
                  If   Trim(TextBox1.Text)   =   ""   Then  
                          ListBox1.Items.Add("错误:没有输入电话号码!")  
                          Exit   Sub  
                  Else  
                          strPhoneNum   =   TextBox1.Text  
                  End   If  
   
                  res   =   tapiRequestMakeCall(strPhoneNum,   "Tapi   Sample",   strPhoneNum,   "")  
                  Call   tapiStatus(res)  
          End   Sub  
   
          Private   Sub   Button2_Click(ByVal   sender   As   System.Object,   ByVal   e   As   System.EventArgs)   Handles   Button2.Click  
                  Close()  
          End   Sub  
   
          Private   Sub   Form1_MinimumSizeChanged(ByVal   sender   As   Object,   ByVal   e   As   System.EventArgs)   Handles   MyBase.MinimumSizeChanged  
                  Icon1.Visible   =   True  
          End   Sub  
   
          Private   Sub   MenuItem1_Click(ByVal   sender   As   System.Object,   ByVal   e   As   System.EventArgs)   Handles   MenuItem1.Click  
                  Close()  
          End   Sub  
   
          Private   Sub   MenuItem2_Click(ByVal   sender   As   System.Object,   ByVal   e   As   System.EventArgs)   Handles   MenuItem2.Click  
                  Me.Show()  
          End   Sub  
  End   Class  
  Top

相关问题

  • 请问如何用C++Builder编写一个电话拨号程序?
  • 电话拨号程序,救急救急!!!
  • 有没有电话拨号的程序
  • 高分求电话拨号源程序
  • 我想用win2k下的电话拨号程序打电话。
  • 如何用VB纺制一个电话拨号程序?
  • 如何用VC(VB)编写一个电话拨号程序?
  • 电话拨号程序,怎么替换它?
  • 有人做过电话拨号程序吗?研究一下
  • ×××怎么用程序对电话拨号音的识别?×××

关键词

  • c#
  • me
  • listbox
  • 拨号
  • contextmenu
  • icon
  • friend withevents
  • menuitem
  • button
  • textbox

得分解答快速导航

  • 帖主:IamDinosaur

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
x 提问