function log_record(aHandle:THandle;logtype,username:string;sortno,eventno:integer):integer;stdcall;
var
strdatetime:string;
strcomputer:string;
computername
char;
size
word;
logsource:string;
SQLSVR:string;
SQLUser:string;
SQLPwd:string;
begin
SQLsvr:='200.200.200.1';
SQLUser:='chiuser';
SQLPwd:='dvb';
logSource:=Application.ExeName;
while pos('/',logSource)<>0 do
logSource:=copy(logSource,pos('/',logSource)+1,length(logSource));
logSource:=copy(logSource,1,pos('.',logSource)-1);
Application.Handle:=aHandle;
Application.CreateForm(TDataModule1, DataModule1);
strdatetime:=datetimetostr(now);
size:=255;
GetMem(computername,size);
if GetComputerName(computername,size)=false then
begin
MessageBox(aHandle,'获取计算机名称失败','错误',MB_OK+MB_ICONERROR);
FreeMem(Computername);
Result:=0;
exit;
end;
strcomputer:=computername;
DataModule1.Query1.Close;
DataModule1.Query1.SQL.Clear;
DataModule1.Query1.SQL.Add('insert into logfile(logtype,eventdatetime,logsource,username,computer,sortno,eventno)');
DataModule1.Query1.SQL.Add('values('''+logtype+''','''+strdatetime+''','''+logsource+''','''+username+''','''+strcomputer+''','+inttostr(sortno)+','+inttostr(eventno)+')');
DataModule1.Query1.ExecSQL;
DataModule1.Query1.Close;
DataModule1.Free;
Result:=1;
end;
exports
log_record index 1 name 'logrecord' resident;
begin