tinifile *ini = new tinifile(dir);
try{
ini->writestring("clientcfg","server",serverip);
ini->writestring("clientcfg","user",username);
delete ini;
}
catch(...){
application->messageboxa("写入配置文件config.ini失败!",null,mb_ok+16);
delete ini;
}
close();
}
if(msg->msgtype==0xb){
application->messagebox("用户名或密码错误!",null,mb_ok);
}
}
//---------------------------------------------------------------------------
void __fastcall tloginform::formclose(tobject *sender,
tcloseaction &action)
{
clientsocket1->active=false;
}
//---------------------------------------------------------------------------
bool __fastcall tloginform::getispass()
{
//todo: add your source code here
return ispass;
}
void __fastcall tloginform::formcreate(tobject *sender)
{
char dir[max_path];
//----获取运行程序的目录开始
char *tfile = "/config.ini";
//将程序现在目录所在输入此字符数组
::getcurrentdirectory(max_path,dir);
//将现在目录加上指定文件名
strcat(dir,tfile);
//----获取运行程序的目录结束
tinifile *ini = new tinifile(dir);
try
{
editname->text = ini->readstring("clientcfg","user","");
editserver->text = ini->readstring("clientcfg","server","");
port = ini->readinteger("clientcfg","port",1555);
misurl = ini->readstring("clientcfg","misurl","http://192.168.1.101:7001/webmis/login/logincontroller.jpf");
delete ini;
}
catch(...)
{
messagebox(application->handle,"读取配置文件config.ini失败!","信息提示!",mb_ok+mb_iconinformation+mb_systemmodal);
delete ini;
}
}
//---------------------------------------------------------------------------
void __fastcall tloginform::editserverdblclick(tobject *sender)
{
editserver->readonly = false;
editserver->font->color = clblack;
}
//---------------------------------------------------------------------------
unit2.h
//---------------------------------------------------------------------------
#ifndef unit2h
#define unit2h
//---------------------------------------------------------------------------
#include <classes.hpp>
#include <controls.hpp>
#include <stdctrls.hpp>
#include <forms.hpp>
#include <scktcomp.hpp>
#include <mask.hpp>
#include <buttons.hpp>
//---------------------------------------------------------------------------
class tloginform : public tform
{
__published: // ide-managed components
tbutton *button1;
tgroupbox *groupbox1;
tlabel *label1;
tlabel *label2;
tedit *editname;
tedit *editpwd;
tlabel *label3;
tedit *editserver;
tclientsocket *clientsocket1;
void __fastcall button1click(tobject *sender);
void __fastcall clientsocket1error(tobject *sender,
tcustomwinsocket *socket, terrorevent errorevent,
int &errorcode);
void __fastcall clientsocket1connect(tobject *sender,
tcustomwinsocket *socket);
void __fastcall clientsocket1read(tobject *sender,
tcustomwinsocket *socket);
void __fastcall formclose(tobject *sender, tcloseaction &action);
void __fastcall formcreate(tobject *sender);