孤
孤独求败
Unregistered / Unconfirmed
GUEST, unregistred user!
我在一个Dll 文件中,继承TTable 类,共有两个FoxPro数据库;
测试如下:
原程序如下:
library counter;
uses
SysUtils,
Classes,
DealString in 'DealString.pas',
{$R *.RES}
exports
DealString;
begin
end.
--------------------------
unit DealString;
interface
uses
Windows, Messages, dbtables,SysUtils, Classes, Graphics, Controls, Forms,
Dialogs;
Const
Function DealString(AInput: PChar)Char;stdcall;
implementation
Function DealString(AInput: PChar)Char;stdcall;
var
AOutputChar;
Path:array[0..MAX_PATH-1] of Char;
PathStr:string;
Appini:TiniFile;
BranchPath:string;
InString: string;
InType: string;
OutString: string;
InStringList: TStringList;
InTable,OutTable :TTable;
begin
SetString(PathStr,Path,GetModuleFileName(HInstance,Path,SizeOf(Path)));
BranchPath:=ExtractFilePath(PathStr);
Appini:=TiniFile.Create(BranchPath+'Branch.ini');
InTable:=TTable.Create(nil );
OutTable:=TTable.Create(nil );
InStringList := TstringList.Create;
CommandList := TStringList.Create;
try
InTable.DatabaseName:=Appini.ReadString('Interface','InDatabaseName','');
OutTable.DatabaseName:=Appini.ReadString('Interface','OutDatabaseName','');
InTable.Tablename := Appini.ReadString('Interface','InTablename','');
OutTable.Tablename := Appini.ReadString('Interface','OutTablename','');
InTable.Active := True;
OutTable.Active := True;
InString := AInput;
OutStrin := InString+' Hello';
GetMem(AOutput,Length(OutString)+ 1);
StrCopy(AOutput, PChar(OutString));
FreeMem(AOutput);
Result:=AOutput;
finally
InStringList.Free;
Appini.Free;
InTable.Free ;
OutTable.Free;
end;
end;
end.
-------------------
调用程序如下:
procedure TForm1.Button1Click(Sender: TObject);
var
InString: string;
DInput: PChar;
DOutput: PChar;
begin
InString := edit1.text;
GetMem(DInput,Length(InString)+ 1);
StrCopy(DInput,PChar(InString));
DOutput:=DealString(DInput);
Label1.Caption:= DOutput;
FreeMem(DInput);
end;
---------
branch.ini
[Interface]
InDatabaseName=C:/WINDOWS/Desktop/tt/db/longdatabase
OutDatabaseName=C:/WINDOWS/Desktop/tt/db/longdatabase
InTableName=info.dbf
OutTableName=info1.dbf
------------
出现错误如下:
1、当两个数据库同时Active:=True系统报错;
2、当数据字段为10时(我设定的)系统报错,或出来乱码;
3、字段少时没有问题
4、不稳定
环境:win98/Delphi 5 enterprise