请问我这样把一些信息写进一个文本文件
解决方案 »
- 用sendkeys 循环发送消息 会出现假死 有办法解决吗
- ClientSocket的问题
- 怎么样写一个让Java可以调用的DLL
- ★Socket通信如何发送字符串??
- 为什么打印机不打报表,而是空走纸呀
- RichEdit如何才能Load一个Unicode的文本文件
- 如何更改StringGrid的行的颜色?
- 各位兄台,,救命呀。。。好簡單的。
- 请教delphi + intrabweb 问题
- pzh_sql是变量,但在sql查询中出错了,不知什么原因?
- 如何在 StringGrid 上移动光标到上行或下行时,第零列上画上红色的字符 "->>>"
- 限制计算时间和辅助空间的数组排序算法问题!!高分赐教。
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs; //private {the no function or procedure} //public{the function have not override object}
Function GetLocalHostName:string;
Function CodeChangeToName(Tablename,Code:string):string;
Function NameChangeToCode(Cname:string):string;
procedure DownloadCodeTable(Tablename,param: string);
type TuserInfo=Class(Tobject)
private
public
Procedure CreateUserFile(servername:string; username:string; password:string;F:boolean);
procedure CloseUserFile;
Function Getusername:string;
Function Getuserpass:string;
Function GetServername:string;
function GetF:boolean;
end;
type TuserRec=packed record
LinkServer:string[40];
userpassword:string[20];
username:string[20];
F:boolean;
end; var
userinfo:Tuserinfo;
userRec:TUserRec;
userinfofile:file of TuserRec;
oldvalue:string;
DMValue,MCValue:string;
TNValue,FieldName:string;
LABEL_MC:string;
implementation
uses U_DM,U_Link;
//获取本机的名称
Function GetLocalHostName:string;
var
ComputerName:pchar;
Size: Cardinal;
Re:Boolean;
begin
Size := MAX_COMPUTERNAME_LENGTH+1;
Getmem(ComputerName,Size);
{retrieve computer name}
Re:=GetComputerName(ComputerName, Size);
if re then
result := StrPas(Computername)
else Showmessage('Computer Name Not Found');
Freemem(ComputerName);
end; Function CodeChangeToName(Tablename,Code:string):string;
var
SQLSTR:string;
begin
SQLSTR:='select MC From '+tablename+' where Rtrim(Ltrim(DM))='''+trim(CODE)+'''';
DM.DM_query.Data:=DM.DM_query.DataRequest(SQLSTR);
DM.DM_query.open;
if DM.DM_query.RecordCount=0 then
result:=''
else begin
DM.DM_query.first;
if not DM.DM_query.Fields[0].IsNull then
result:=DM.DM_query.Fields[0].AsString
else result:='';
end;
end; Function NameChangeToCode(Cname:string):string;
begin
end;
procedure DownloadCodeTable(Tablename,param: string);
var
SQLSTR:string;
begin
SQLSTR:='select DM,MC From '+tablename+' where Rtrim(Ltrim(DM)) like'+'''%'+trim(Param)+'%'' or rTrim(Ltrim(MC)) like'+'''%'+trim(param)+'%''';
DM.DM_query.Data:=DM.DM_query.DataRequest(SQLSTR);
DM.DM_query.open;
end;
{ TuserInfo }procedure TuserInfo.CloseUserFile;
begin
closefile(userinfofile);
end;procedure TuserInfo.CreateUserFile(servername:string; username:string; password:string; F:boolean);
var
path:string;
begin
path:=extractfilepath(application.ExeName)+'\userinfo\';
if NOT directoryExists(path) then
CreateDir(path);
AssignFile(userinfofile,path+'userinfo.dat');
rewrite(userinfofile);
userRec.LinkServer:=servername;
userRec.username:=username;
userRec.F:=F;
if F then
userrec.userpassword:=password
else userrec.userpassword:='';
write(userinfofile,userRec);
closefile(userinfofile);
end;function TuserInfo.GetF: boolean;
var
path:string;
begin
path:=extractfilepath(application.ExeName)+'\userinfo\';
AssignFile(userinfofile,path+'userinfo.dat');
reset(userinfofile);
seek(userinfofile,0);
read(userinfofile,userRec);
result:=userRec.F;
closefile(userinfofile);
end;function TuserInfo.GetServername: string;
var
path:string;
begin
path:=extractfilepath(application.ExeName)+'\userinfo\';
AssignFile(userinfofile,path+'userinfo.dat');
reset(userinfofile);
seek(userinfofile,0);
read(userinfofile,userRec);
result:=trim(userRec.LinkServer);
closefile(userinfofile);
end;function TuserInfo.Getusername: string;
var
path:string;
begin
path:=extractfilepath(application.ExeName)+'\userinfo\';
AssignFile(userinfofile,path+'userinfo.dat');
reset(userinfofile);
seek(userinfofile,0);
read(userinfofile,userRec);
result:=trim(userRec.username);
closefile(userinfofile);
end;function TuserInfo.Getuserpass: string;
var
path:string;
begin
path:=extractfilepath(application.ExeName)+'\userinfo\';
AssignFile(userinfofile,path+'userinfo.dat');
reset(userinfofile);
seek(userinfofile,0);
read(userinfofile,userRec);
result:=trim(userRec.userpassword);
closefile(userinfofile);
end;end.