Konvertering af en include fil fra Delphi til Visual Basic
Jeg har en include fil jeg gerne vil have konverteret til Visual Basic så jeg kan anvende en dll. Er der nogen der kan hjælpe med det ?----------------------------------------------------
{**** Definitions for SCAUTO.DLL ****}
unit SCAuto;
interface
type
Pscauto_event = ^scauto_event;
scauto_event = packed record
evfields : string;
evtype : string[16];
evtime : string[17];
evsysseq : string[32];
evusrseq : string[32];
evsysopt : string[24];
evuser : string[24];
evpswd : string[24];
evsepchar : Char;
end;
const
{ Basic SCAuto error codes }
NOCONN = 800 ; { No connection established }
INVID = 801 ; { No connection which matches passed ID }
DELINI = 802 ; { Delete only allowed on initial session }
LICENCE = 803 ; { caller not licenced connection denied }
FILERR = 804 ; { File error occured check standard error }
FORKERR = 805 ; { Fork failure check standard error }
EXECERR = 806 ; { Execlp failure check standard error }
STORERR = 807 ; { Malloc failure check standard error }
DUPEID = 808 ; { Duplicate ID specified }
NOEVFND = 809 ; { No events found }
NOQUERY = 810 ; { No previous query_events issued }
OPNERR = 811 ; { Open file error check standard error }
SYNTAX = 812 ; { Specification has syntax error }
DELERR = 813 ; { Error on delete see server log }
INSERR = 814 ; { Error on Insert see server log }
CONERR = 815 ; { Could not create new connection }
BADREQ = 816 ; { Command not understood by SCAuto server }
{Codes for network errors; check scauto_errror for OS specific error code }
NETERR_SOCKINIT = 101 ; { Socket library initialization failed }
NETERR_GETHOST = 102 ; { Host name lookup failed }
NETERR_GETSERV = 103 ; { Service name lookup failed }
NETERR_SOCKET = 104 ; { Socket creation failed }
NETERR_CONNECT = 105 ; { Socket connect to server failed }
NETERR_BIND = 106 ; { Couldn't bind address }
NETERR_SOCKSEND = 107 ; { Error sending data to remote server }
NETERR_SOCKRECV = 108 ; { Error receiving data from remote server }
{ 109 currently unused }
NETERR_LOSTCONN = 110 ; { Remote connection closed or server died }
function scauto_connect(Id: string; Server: string; Events: string; Users: string) : Integer;
function scauto_disconnect(Id: string) : Integer;
function scauto_query(Id: string; Start: string; Opt: string; var Event: scauto_event) : Integer;
function scauto_get_next(Id: string; var Event: scauto_event) : Integer;
function scauto_create(Id: string; var Event: scauto_event) : Integer;
function scauto_delete(Id: string; var Event: scauto_event) : Integer;
function scauto_error(Id: string) : Integer;
function scauto_error_string (error: Integer) : string;
function scauto_version(a:integer) : string;
implementation
uses SysUtils;
{ Here we put a wrapper around everything. This way callers can use
'string' for everything, and we transparently convert to/from Pchar
behind the scenes. }
type
{* This is what the DLL really wants to see *}
real_scauto_event = packed record
evfields: PAnsiChar;
evtype: array[0..16] of AnsiChar;
evtime: array[0..17] of AnsiChar;
evsysseq: array[0..32] of AnsiChar;
evusrseq: array [0..32] of AnsiChar;
evsysopt: array [0..24] of AnsiChar;
evuser: array [0..24] of AnsiChar;
evpswd: array [0..24] of AnsiChar;
evsepchar: AnsiChar;
end;
{* A couple of helper functions *}
procedure real_to_fake(var real_ev : real_scauto_event; var fake_ev : scauto_event);
begin
fake_ev.evtype := string(real_ev.evtype);
fake_ev.evsysseq := string(real_ev.evsysseq);
fake_ev.evusrseq := string(real_ev.evusrseq);
fake_ev.evtime := string(real_ev.evtime);
fake_ev.evsysopt := string(real_ev.evsysopt);
fake_ev.evuser := string(real_ev.evuser);
fake_ev.evsepchar := real_ev.evsepchar;
fake_ev.evfields := string(real_ev.evfields);
end;
procedure fake_to_real(var fake_ev : scauto_event; var real_ev : real_scauto_event);
begin
StrPLCopy(real_ev.evtype, fake_ev.evtype, SizeOf(real_ev.evtype));
StrPLCopy(real_ev.evsysseq, fake_ev.evsysseq, SizeOf(real_ev.evsysseq));
StrPLCopy(real_ev.evusrseq, fake_ev.evusrseq, SizeOf(real_ev.evusrseq));
StrPlCopy(real_ev.evtime, fake_ev.evtime, SizeOf(real_ev.evtime));
StrPlCopy(real_ev.evsysopt, fake_ev.evsysopt, SizeOf(real_ev.evsysopt));
StrPlCopy(real_ev.evuser, fake_ev.evuser, SizeOf(real_ev.evuser));
real_ev.evsepchar := fake_ev.evsepchar;
real_ev.evfields := PChar(fake_ev.evfields);
end;
{* Here are the DLL functions *}
function real_scauto_connect(Id: PChar; Server: PChar; Events: PChar; Users: PChar) : Integer;
stdcall; external 'scauto.dll' name 'scauto_connect';
function real_scauto_disconnect(Id: PChar) : Integer;
stdcall; external 'scauto.dll' name 'scauto_disconnect';
function real_scauto_query(Id: PChar; Start: PChar; Opt: PChar; var Event: real_scauto_event) : Integer;
stdcall; external 'scauto.dll' name 'scauto_query';
function real_scauto_get_next(Id: PChar; var Event: real_scauto_event) : Integer;
stdcall; external 'scauto.dll' name 'scauto_get_next';
function real_scauto_create(Id: PChar; var Event: real_scauto_event) : Integer;
stdcall; external 'scauto.dll' name 'scauto_create';
function real_scauto_delete(Id: PChar; var Event: real_scauto_event) : Integer;
stdcall; external 'scauto.dll' name 'scauto_delete';
function real_scauto_error(Id: PChar) : Integer;
stdcall; external 'scauto.dll' name 'scauto_error';
function real_scauto_error_string (error: Integer) : PChar;
stdcall; external 'scauto.dll' name 'scauto_error_string';
function real_scauto_version : PChar;
stdcall; external 'scauto.dll' name 'scauto_version';
{* And now the wrapper functions *}
function scauto_connect(Id: string; Server: string; Events: string; Users: string) : Integer;
begin
scauto_connect := real_scauto_connect(PChar(Id), PChar(Server),
PChar(Events), PChar(Users));
end;
function scauto_disconnect(Id: string) : Integer;
begin
scauto_disconnect := real_scauto_disconnect(PChar(Id));
end;
function scauto_query(Id: string; Start: string; Opt: string; var Event: scauto_event) : Integer;
var real_ev : real_scauto_event;
status : Integer;
begin
status := real_scauto_query(PChar(Id), PChar(Start), PChar(Opt), real_ev);
if status = 0 then
real_to_fake(real_ev, Event);
scauto_query := status;
end;
function scauto_get_next(Id: string; var Event: scauto_event) : Integer;
var real_ev : real_scauto_event;
status : Integer;
begin
status := real_scauto_get_next(PChar(Id), real_ev);
if status = 0 then
real_to_fake(real_ev, Event);
scauto_get_next := status;
end;
function scauto_create(Id: string; var Event: scauto_event) : Integer;
var real_ev : real_scauto_event;
begin
fake_to_real(Event, real_ev);
scauto_create := real_scauto_create(PChar(Id), real_ev);
end;
function scauto_delete(Id: string; var Event: scauto_event) : Integer;
var real_ev : real_scauto_event;
begin
fake_to_real(Event, real_ev);
scauto_delete := real_scauto_delete(PChar(Id), real_ev);
end;
function scauto_error(Id: string) : Integer;
begin
scauto_error := real_scauto_error(PChar(Id));
end;
function scauto_error_string(error: integer) : string;
begin
scauto_error_string := real_scauto_error_string(error);
end;
function scauto_version(a:integer) : string;
begin
scauto_version := real_scauto_version;
end;
end.