|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
中间码是基于一个虚拟机器。源代码是最高层的,理论上从源代码开始直接编译成本地码能提供最大优化的。而中间码只能是转译成本地码,效率上难免受到损耗。根据虚拟机器所设定的体系结构的特点,和本地机器的差异的多少。用ini文件感到仍是挺便利的
usingSystem;
usingSystem.Drawing;
usingSystem.Collections;
usingSystem.ComponentModel;
usingSystem.Windows.Forms;
usingSystem.IO;
usingSystem.Runtime.InteropServices;
usingSystem.Text;
namespaceini
{
///<summary>
///Form1的择要申明。
///</summary>
publicclassForm1:System.Windows.Forms.Form
{
privateSystem.Windows.Forms.Buttonbutton1;
privateSystem.Windows.Forms.TextBoxtextBox1;
privateSystem.Windows.Forms.TextBoxtextBox2;
privateSystem.Windows.Forms.TextBoxtextBox3;
privateSystem.Windows.Forms.Buttonbutton3;
publicstringdatabase,userid,server;
//声名INI文件的写操纵函数WritePrivateProfileString()
[DllImport("kernel32")]
privatestaticexternlongWritePrivateProfileString(stringsection,stringkey,stringval,stringfilePath);
//声名INI文件的读操纵函数GetPrivateProfileString()
[DllImport("kernel32")]
privatestaticexternintGetPrivateProfileString(stringsection,stringkey,stringdef,StringBuilderretVal,intsize,stringfilePath);
///<summary>
///必须的计划器变量。
///</summary>
privateSystem.ComponentModel.Containercomponents=null;
publicForm1()
{
//
//Windows窗体计划器撑持所必须的
//
InitializeComponent();
//
//TODO:在InitializeComponent挪用后增加任何机关函数代码
//
}
///<summary>
///清算一切正在利用的资本。
///</summary>
protectedoverridevoidDispose(booldisposing)
{
if(disposing)
{
if(components!=null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#regionWindows窗体计划器天生的代码
///<summary>
///计划器撑持所需的办法-不要利用代码编纂器修正
///此办法的内容。
///</summary>
privatevoidInitializeComponent()
{
this.button1=newSystem.Windows.Forms.Button();
this.textBox1=newSystem.Windows.Forms.TextBox();
this.textBox2=newSystem.Windows.Forms.TextBox();
this.textBox3=newSystem.Windows.Forms.TextBox();
this.button3=newSystem.Windows.Forms.Button();
this.SuspendLayout();
//
//button1
//
this.button1.Location=newSystem.Drawing.Point(176,16);
this.button1.Name="button1";
this.button1.Size=newSystem.Drawing.Size(88,24);
this.button1.TabIndex=0;
this.button1.Text="写ini文件";
this.button1.Click+=newSystem.EventHandler(this.button1_Click);
//
//textBox1
//
this.textBox1.Location=newSystem.Drawing.Point(40,8);
this.textBox1.Name="textBox1";
this.textBox1.Size=newSystem.Drawing.Size(96,21);
this.textBox1.TabIndex=1;
this.textBox1.Text="";
//
//textBox2
//
this.textBox2.Location=newSystem.Drawing.Point(40,40);
this.textBox2.Name="textBox2";
this.textBox2.Size=newSystem.Drawing.Size(96,21);
this.textBox2.TabIndex=2;
this.textBox2.Text="";
//
//textBox3
//
this.textBox3.Location=newSystem.Drawing.Point(40,72);
this.textBox3.Name="textBox3";
this.textBox3.Size=newSystem.Drawing.Size(96,21);
this.textBox3.TabIndex=3;
this.textBox3.Text="";
//
//button3
//
this.button3.Location=newSystem.Drawing.Point(176,56);
this.button3.Name="button3";
this.button3.Size=newSystem.Drawing.Size(88,24);
this.button3.TabIndex=6;
this.button3.Text="读ini文件";
this.button3.Click+=newSystem.EventHandler(this.button3_Click);
//
//Form1
//
this.AutoScaleBaseSize=newSystem.Drawing.Size(6,14);
this.ClientSize=newSystem.Drawing.Size(320,117);
this.Controls.Add(this.button3);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Name="Form1";
this.Text="ini";
this.Load+=newSystem.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
///<summary>
///使用程序的主出口点。
///</summary>
[STAThread]
staticvoidMain()
{
Application.Run(newForm1());
}
privatevoidServer_Info()
{
strings=Application.ExecutablePath;
strings1;
s1=s.Replace("ini.exe","config.ini");
//写进INI文件
stringFileName="FiatDataBase";
stringpath=s1;
stringkey1="DataBase";
stringkeyValue1=textBox1.Text;
stringkey2="Server";
stringkeyValue2=textBox2.Text;
stringkey3="UserId";
stringkeyValue3=textBox3.Text;
WritePrivateProfileString(FileName,key1,keyValue1,path);
WritePrivateProfileString(FileName,key2,keyValue2,path);
WritePrivateProfileString(FileName,key3,keyValue3,path);
MessageBox.Show("终了!");
}
//读取服务器信息
privatevoidbutton1_Click(objectsender,System.EventArgse)
{
Server_Info();
}
privatevoidbutton2_Click(objectsender,System.EventArgse)
{
}
//读取服务器信息
privatevoidRead_SystemInfo()
{
try
{
//猎取设置信息
strings=Application.ExecutablePath;
strings1;
s1=s.Replace("ini.exe","config.ini");
StringBuildertemp1=newStringBuilder(255);
inti1=GetPrivateProfileString("FiatDataBase","DataBase","",temp1,255,s1);
database=temp1.ToString();
StringBuildertemp2=newStringBuilder(255);
inti2=GetPrivateProfileString("FiatDataBase","Server","",temp2,255,s1);
server=temp2.ToString();
StringBuildertemp3=newStringBuilder(255);
inti3=GetPrivateProfileString("FiatDataBase","UserId","",temp3,255,s1);
userid=temp3.ToString();
}
catch(Exceptione1)
{
MessageBox.Show("请先设置服务器信息!");
}
}
privatevoidbutton3_Click(objectsender,System.EventArgse)
{
Read_SystemInfo();
}
privatevoidForm1_Load(objectsender,System.EventArgse)
{
}
}
}
我觉得很重要,一般所说的不重要应该指的是:你学好一种以后再学另一种就很容易了。(因为这样大家可能有一个错觉就是语言不是很重要,只要随便学一种就可以了,其实不是这样的。 |
|