请兄弟们帮我分析下代码,经常会崩溃,郁闷啊
代码可能有些长,请各位兄弟耐住性子看看,感激不尽:
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Configuration;
using System.Runtime.InteropServices;
namespace 滁州移动服务评价系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//引用dll部分
#region
Cls cls = new Cls();
[DllImport("centerm_i70.dll", EntryPoint = "GetPasswordFromKeypad", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GetPasswordFromKeypad(ref Cls.COMMPARAMETER stComParam, ref string strPassword, int nLen, int nMode, double nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "SetEvaluatorInfo", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SetEvaluatorInfo(ref Cls.COMMPARAMETER stComParam, string strDepartment, string strPosition, string strID, int nStar);
[DllImport("centerm_i70.dll", EntryPoint = "GetEvaluationFromEvaluator", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GetEvaluationFromEvaluator(ref Cls.COMMPARAMETER stComParam, ref string strEvaluation, int nEvaLen, ref string strReason, int nReaLen, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "GetValueFromInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GetValueFromInfoviewer(ref Cls.COMMPARAMETER stComParam, ref string strValue, int nVLen, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "AppendToInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int AppendToInfoviewer(ref Cls.COMMPARAMETER stComParam, string strInfo, int nLen);
[DllImport("centerm_i70.dll", EntryPoint = "ClearInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ClearInfoviewer(ref Cls.COMMPARAMETER stComParam);
[DllImport("centerm_i70.dll", EntryPoint = "EnableInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int EnableInfoviewer(ref Cls.COMMPARAMETER stComParam);
[DllImport("centerm_i70.dll", EntryPoint = "SetInfoviewerText", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SetInfoviewerText(ref Cls.COMMPARAMETER stComParam, int fontsize, string fontcolor, string backcolor);
[DllImport("centerm_i70.dll", EntryPoint = "ListPictureBegin", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListPictureBegin(ref Cls.COMMPARAMETER stComParam, ref string listBuffer, ref int nSize, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "ListPictureEnd", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListPictureEnd(string listBuffer);
[DllImport("centerm_i70.dll", EntryPoint = "ListMP3AudioBegin", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListMP3AudioBegin(ref Cls.COMMPARAMETER stComParam, ref string listBuffer, ref int nSize, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "ListMP3AudioEnd", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListMP3AudioEnd(string listBuffer);
[DllImport("centerm_i70.dll", EntryPoint = "DownloadOperatorPicture", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int DownloadOperatorPicture(ref Cls.COMMPARAMETER stComParam, string strSrcFileName, string strDestFileName, int outtime);
[DllImport("centerm_i70.dll", EntryPoint = "PlayMP3Audio", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int PlayMP3Audio(ref Cls.COMMPARAMETER stComParam, string strFileName);
[DllImport(".\\centerm_i70.dll", EntryPoint = "isCommPortUsed", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int isCommPortUsed(); //检测端口是否被占用
[DllImport(".\\centerm_i70.dll", EntryPoint = "ForceCloseCommPort", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ForceCloseCommPort(ref Cls.COMMPARAMETER stComParam);//关闭当前端口
[DllImport(".\\centerm_i70.dll", EntryPoint = "CloseApplication", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int CloseApplication(ref Cls.COMMPARAMETER stComParam); //关闭程序
#endregion
//程序初始化
public DataSet ds = null;
public static string _tc = "";
public static string _pj = "";
public static string _pwd = "";
public static int ppstate = 0;
public static string loadhtml = "";
public static string loadurl = "";
private void Form1_Load(object sender, EventArgs e)
{
CSHLoad csh = new CSHLoad();
csh.label1.Text = "系统正在初始化中,请稍后...";
csh.ShowDialog();
string _text = ConfigurationSettings.AppSettings["title"].ToString();
string _pwdname = ConfigurationSettings.AppSettings["pwdname"].ToString();
string _telname = ConfigurationSettings.AppSettings["telname"].ToString();
string _submitname = ConfigurationSettings.AppSettings["submitname"].ToString();
string _frmname = ConfigurationSettings.AppSettings["frmname"].ToString();
Cls.bossurl = ConfigurationSettings.AppSettings["bossurl"].ToString();
_tc = ConfigurationSettings.AppSettings["tc"].ToString();
_pj = ConfigurationSettings.AppSettings["pj"].ToString();
_pwd = ConfigurationSettings.AppSettings["pwd"].ToString();
this.Text = "滁州移动综合业务系统(版本:" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + ")";// _text;
if (_pwdname != "" && _submitname != "")
{
Cls.submitname = _submitname;
Cls.pwdname = _pwdname;
Cls.telname = _telname;
Cls.frmname = _frmname;
}
else
{ MessageBox.Show("程序初始化失败,请设置app.config文件"); }
toolStripLabel1.Text = Cls.usercode;
}
//检验加载是否完毕
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
timer1.Start();
}