Yes. This computer isn't connected to a LAN, but this Delphi code works:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function ErrorLog(comp, app, msg: string; _type, errornum: integer): boolean;
var
hEventSource:THANDLE;
sstring: array [0..1] of string;
etype:word;
begin
hEventSource := RegisterEventSource(PChar(comp), PChar(app));
case _type of
0: etype:=EVENTLOG_ERROR_TYPE;
1: etype:=EVENTLOG_WARNING_TYPE;
2: etype:=EVENTLOG_INFORMATION_TYPE;
3: etype:=EVENTLOG_AUDIT_SUCCESS;
4: etype:=EVENTLOG_AUDIT_FAILURE;
end;
if hEventSource > 0 then
begin
sString[0] := app; // application
sString[1] := Msg; // message
ReportEvent(hEventSource,
etype, // event type
1, // event category
errornum, // event identifier
nil, // user security identifier (optional)
2, // number of strings to merge msg
0, // size of binary data, in bytes
@sString, // array of strings to merge with msg
nil); // address of binary data
DeregisterEventSource(hEventSource);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
buffer: array[0..255] of char;
size: dword;
ComputerName: String;
begin
ComputerName := '';
size := 256;
if GetComputerName(buffer, size) then ComputerName := buffer;
ShowMessage('This computer is called: ' + ComputerName);
ErrorLog(ComputerName, 'My App','Tis an error, you know?', 0, 1234);
end;
end.