RtTool/Delphi7/开发档案/马国钢开发代码/ThreeFun/dllPas/getsvrcon.pas

85 lines
1.7 KiB
ObjectPascal
Raw Normal View History

2025-01-08 11:55:07 +08:00
unit getsvrcon;
interface
uses
SysUtils, Windows, Forms, IniFiles,strUtils;
function FTConSvr(H: THandle; ProdID, Address, Server, User, Pswd, DTBase: PChar): Integer; stdcall; external 'FTClient.dll';
function GetSvrConn(
H: THandle;
ProdID: String;
var Server: String;
var User: String;
var Pswd: String;
var DTBase: String
): Integer;
implementation
function GetSvrConn(
H: THandle;
ProdID: String;
var Server: String;
var User: String;
var Pswd: String;
var DTBase: String
): Integer;
var
Ini: TIniFile;
Address, Server1, User1, Pswd1, DTBase1,DtType: String;
iPos:integer;
begin
Ini := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'consvr.ini');
try
Address := Ini.ReadString('SERVER', 'SERVER', '0.0.0.0');
finally
Ini.Free;
end;
if Address = '0.0.0.0' then
begin
Application.MessageBox('<27><><EFBFBD>ļ<EFBFBD>consvr.ini<6E><69><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD>', MB_ICONERROR);
Application.Terminate;
end;
Server1 := StringOfChar(#0, 20);
User1 := StringOfChar(#0, 20);
Pswd1 := StringOfChar(#0, 20);
DTBase1 := StringOfChar(#0, 20);
Result := FTConSvr(H, PChar(ProdID), Pchar(address),PChar(Server1), PChar(User1), PChar(Pswd1), PChar(DTBase1));
Server := Trim(Server1);
User := Trim(User1);
Pswd := Trim(Pswd1);
DTBase := Trim(DTBase1);
/////////////////////
//database
iPos:=pos('/',dtbase);
if iPos>0 then
begin
DtType:=leftStr(dtbase,iPos-1);
DTBase:=rightStr(dtBase,length(dtbase)-iPos);
end
else
DtType:='';
//////////////////////////////
//user
if DtType='' then
begin
iPos:=pos('/',User);
if iPos>0 then
begin
DtType:=leftStr(User,iPos-1);
User:=rightStr(User,length(User)-iPos);
end
else
DtType:='';
end;
if trim(DTType)<>'' then
server:=server+'\'+DTType;
end;
end.