Subversion Repositories simple_log_event

Compare Revisions

No changes between revisions

Regard whitespace Rev 3 → Rev 2

/trunk/Setup/SimpleLogEventSetup.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/trunk/Setup/ManualEventSourceRegistration.reg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/trunk/Setup/DllRes.rc
File deleted
/trunk/Setup/SimpleLogEventSetupMain.dfm
File deleted
/trunk/Setup/SimpleLogEventSetup.dproj
File deleted
/trunk/Setup/DelWaste.bat
File deleted
/trunk/Setup/DllRes.RES
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/trunk/Setup/SimpleLogEventSetup.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/trunk/Setup/SimpleLogEventSetup.dpr
File deleted
/trunk/Setup/DllResCompile.bat
File deleted
/trunk/Setup/SimpleLogEventSetupMain.pas
File deleted
/trunk/LogTestUsingDelphi/LogWriteTestDelphi.dpr
9,6 → 9,12
ActiveX,
ViaThinkSoftSimpleLogEvent_TLB in '..\TLB\ViaThinkSoftSimpleLogEvent_TLB.pas';
 
const
LOGEVENT_MSG_SUCCESS = 0;
LOGEVENT_MSG_INFORMATIONAL = 1;
LOGEVENT_MSG_WARNING = 2;
LOGEVENT_MSG_ERROR = 3;
 
var
x: IViaThinkSoftSimpleEventLog;
begin
16,9 → 22,9
CoInitialize(nil);
x := CoViaThinkSoftSimpleEventLog.Create;
{$IFDEF WIN64}
x.LogEvent('MySourceName', ViaThinkSoftSimpleLogEvent_TLB.Warning, 'This is a test warning written by Delphi 64 bit');
x.LogEvent(LOGEVENT_MSG_WARNING, 'This is a test warning written by Delphi 64 bit');
{$ELSE}
x.LogEvent('MySourceName', ViaThinkSoftSimpleLogEvent_TLB.Warning, 'This is a test warning written by Delphi 32 bit');
x.LogEvent(LOGEVENT_MSG_WARNING, 'This is a test warning written by Delphi 32 bit');
{$ENDIF}
x := nil;
//CoUninitialize; // TODO: If I do this, I get an access violation at process end?!
/trunk/LogTestUsingDelphi/LogWriteTestDelphi.dproj
6,7 → 6,7
<MainSource>LogWriteTestDelphi.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Release</Config>
<Platform Condition="'$(Platform)'==''">Win64</Platform>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>3</TargetedPlatforms>
<AppType>Console</AppType>
</PropertyGroup>
/trunk/LogTestUsingDelphi/LogWriteTestDelphi.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/LogTestUsingDelphi/LogWriteTestDelphi32.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/LogTestUsingDelphi/LogWriteTestDelphi64.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/LogTestUsingPHP/LogTest.php
27,10 → 27,10
}
 
if (PHP_INT_SIZE == 8) {
$x->LogEvent('MySourceName', LOGEVENT_MSG_WARNING, 'This is a test warning written by 64 bit PHP');
$x->LogEvent(LOGEVENT_MSG_WARNING, 'This is a test warning written by 64 bit PHP');
} else if (PHP_INT_SIZE == 4) {
$x->LogEvent('MySourceName', LOGEVENT_MSG_WARNING, 'This is a test warning written by 32 bit PHP');
$x->LogEvent(LOGEVENT_MSG_WARNING, 'This is a test warning written by 32 bit PHP');
} else {
// Should never happen!
$x->LogEvent('MySourceName', LOGEVENT_MSG_WARNING, 'This is a test warning written by whatever-bit PHP');
$x->LogEvent(LOGEVENT_MSG_WARNING, 'This is a test warning written by whatever-bit PHP');
}
/trunk/LogTestUsingVBS/LogTest.vbs
7,6 → 7,6
const LOGEVENT_MSG_WARNING = 2
const LOGEVENT_MSG_ERROR = 3
 
objMyObject.LogEvent "MySourceName", LOGEVENT_MSG_WARNING, "This is a test warning written by VBS"
objMyObject.LogEvent LOGEVENT_MSG_WARNING, "This is a test warning written by VBS"
 
MsgBox "OK"
/trunk/README.txt
14,18 → 14,15
without MessageTable/Provider.
 
 
Distribution to the end user
Distribution to the end user (files found in folder "TLB")
----------------------------
 
You only need to deploy SimpleLogEventSetup.exe
which is located in the folder "Setup".
Register.bat
UnRegister.bat
ViaThinkSoftSimpleLogEvent32.dll
ViaThinkSoftSimpleLogEvent64.dll
 
The EXE file contains everything inside:
- 32 bit and 64 bit DLL (will be unpacked to target location)
- Registration procedure for COM/Typelib
- Registration procedure for SourceNames
 
 
Installation
------------
 
60,7 → 57,7
const LOGEVENT_MSG_WARNING = 2
const LOGEVENT_MSG_ERROR = 3
 
objMyObject.LogEvent "MySourceName", LOGEVENT_MSG_WARNING, "This is a test warning written by VBS"
objMyObject.LogEvent LOGEVENT_MSG_WARNING, "This is a test warning written by VBS"
 
 
Example usage with PHP
74,7 → 71,7
define('LOGEVENT_MSG_ERROR', 3);
 
$x = new COM(CLASS_ViaThinkSoftSimpleEventLog);
$x->LogEvent('MySourceName', LOGEVENT_MSG_WARNING, 'This is a test warning written by PHP');
$x->LogEvent(LOGEVENT_MSG_WARNING, 'This is a test warning written by PHP');
 
 
Example usage with Delphi
84,43 → 81,23
ActiveX,
ViaThinkSoftSimpleLogEvent_TLB;
 
const
LOGEVENT_MSG_SUCCESS = 0;
LOGEVENT_MSG_INFORMATIONAL = 1;
LOGEVENT_MSG_WARNING = 2;
LOGEVENT_MSG_ERROR = 3;
 
procedure LogTest;
var
x: IViaThinkSoftSimpleEventLog;
begin
CoInitialize(nil); // needs to be called only once
CoInitialize(nil); // <-- only needs to be called once
x := CoViaThinkSoftSimpleEventLog.Create;
x.LogEvent('MySourceName', ViaThinkSoftSimpleLogEvent_TLB.Warning, 'This is a test warning written by Delphi');
x.LogEvent(LOGEVENT_MSG_WARNING, 'This is a test warning written by Delphi');
x := nil;
end.
 
 
A short note about the compilation workflow (for developers)
-------------------------------------------
 
This only applies if you want to change/extend/fork ViaThinkSoftSimpleEventLog yourself.
You do not need this if you just want to use ViaThinkSoftSimpleEventLog to log events.
 
1. In folder "MessageTable":
Run "EventlogMessagesCompile.bat", it will do:
- MC file => RC+BIN files (using "mc.exe" from Windows SDK)
- RC+BIN files => RES file (using "rc.exe")
2. In folder "TLB":
Compile using Delphi (it will include the MessageTable RES file):
- ViaThinkSoftSimpleLogEvent32.dll
- ViaThinkSoftSimpleLogEvent64.dll
 
3. In folder "Setup":
3.1 Run "DllResCompile.bat", it will do:
- RC file => RES file (will include the two DLLs from folder "TLB")
3.2 Then, compile SimpleLogEventSetup.exe using Delphi
 
4. In folder "LogTestUsingDelphi":
Compile LogWriteTestDelphi*.exe using Delphi
(it will read "ViaThinkSoftSimpleLogEvent_TLB.pas" from the "TLB" folder)
 
 
License
-------
 
/trunk/TLB/ViaThinkSoftSimpleLogEvent.dpr
2,6 → 2,10
 
uses
ComServ,
Registry,
Vcl.Dialogs,
Windows,
SysUtils,
ViaThinkSoftSimpleLogEvent_TLB in 'ViaThinkSoftSimpleLogEvent_TLB.pas',
ViaThinkSoftSimpleLogEvent_Impl in 'ViaThinkSoftSimpleLogEvent_Impl.pas' {ViaThinkSoftSimpleEventLog: CoClass};
 
11,6 → 15,60
 
{$R '..\MessageTable\EventlogMessages.RES'}
 
function GetOwnDllPath: string;
var
reg: TRegistry;
regKey: string;
begin
result := '';
reg := TRegistry.Create;
try
reg.RootKey := HKEY_CLASSES_ROOT;
{$IFDEF WIN64}
regKey := 'TypeLib\'+GuidToString(LIBID_ViaThinkSoftSimpleLogEvent)+'\1.0\0\win64';
{$ELSE}
regKey := 'TypeLib\'+GuidToString(LIBID_ViaThinkSoftSimpleLogEvent)+'\1.0\0\win32';
{$ENDIF}
if reg.OpenKeyReadOnly(regKey) then
begin
result := reg.ReadString('');
reg.CloseKey;
end;
finally
reg.Free;
end;
end;
 
procedure RegisterEventLogProviderIfRequired;
var
reg: TRegistry;
begin
reg := TRegistry.Create;
try
reg.RootKey := HKEY_LOCAL_MACHINE;
if not reg.OpenKey('SYSTEM\CurrentControlSet\Services\Eventlog\Application\'+LOGEVENT_PROVIDER_NAME, true) then
begin
ShowMessage('Cannot register EventLog provider! Please run the application as administrator');
end
else
begin
reg.WriteInteger('CategoryCount', 0);
reg.WriteInteger('TypesSupported', 7);
reg.WriteString('EventMessageFile', GetOwnDllPath);
reg.WriteString('CategoryMessageFile', GetOwnDllPath);
reg.CloseKey;
end;
finally
reg.Free;
end;
end;
 
function DllRegisterServer: HResult;
begin
result := ComServ.DllRegisterServer;
RegisterEventLogProviderIfRequired;
end;
 
exports
DllGetClassObject,
DllCanUnloadNow,
/trunk/TLB/ViaThinkSoftSimpleLogEvent.dproj
9,7 → 9,7
<ProjectVersion>18.8</ProjectVersion>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Release</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<Platform Condition="'$(Platform)'==''">Win64</Platform>
<TargetedPlatforms>3</TargetedPlatforms>
<AppType>Library</AppType>
</PropertyGroup>
/trunk/TLB/ViaThinkSoftSimpleLogEvent.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/TLB/ViaThinkSoftSimpleLogEvent.ridl
6,7 → 6,7
// Änderungen. Wenn Sie aber Änderungen mit dem Editor vornehmen, wird diese
// Datei neu erzeugt und Kommentare oder Formatänderungen gehen verloren.
// ************************************************************************ //
// Datei erzeugt am 30.04.2020 23:03:28 (- $Rev: 12980 $, 10609955).
// Datei erzeugt am 29.04.2020 21:29:52 (- $Rev: 12980 $, 7765620).
 
[
uuid(D7654BA7-41D0-4FF9-8543-C3A4DA936856),
24,17 → 24,6
 
 
[
uuid(7E436E11-889B-4DB6-8530-D3933ED080A2)
]
enum LogEventType
{
Success = 0,
Informational = 1,
Warning = 2,
Error = 3
};
 
[
uuid(4094657E-8199-460F-A3DD-5BB63B6B0F65),
version(1.0),
helpstring("Dispatch interface for ViaThinkSoftSimpleEventLog Object"),
44,7 → 33,7
interface IViaThinkSoftSimpleEventLog: IDispatch
{
[id(0x000000C9)]
HRESULT _stdcall LogEvent([in] BSTR SourceName, [in] enum LogEventType EventType, [in] BSTR LogMsg);
HRESULT _stdcall LogEvent([in] long EventType, [in] BSTR LogMsg);
};
 
[
/trunk/TLB/ViaThinkSoftSimpleLogEvent.tlb
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/TLB/ViaThinkSoftSimpleLogEvent32.dll
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/TLB/ViaThinkSoftSimpleLogEvent64.dll
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/TLB/ViaThinkSoftSimpleLogEvent_Impl.pas
10,10 → 10,12
type
TViaThinkSoftSimpleEventLog = class(TAutoObject, IViaThinkSoftSimpleEventLog)
protected
procedure LogEvent(const SourceName: WideString; EventType: LogEventType; const LogMsg: WideString);
safecall;
procedure LogEvent(EventType: Integer; const LogMsg: WideString); safecall;
end;
 
const
LOGEVENT_PROVIDER_NAME = 'ViaThinkSoft';
 
implementation
 
uses ComServ, Windows;
49,18 → 51,20
end;
end;
 
procedure TViaThinkSoftSimpleEventLog.LogEvent(const SourceName: WideString; EventType: LogEventType;
procedure TViaThinkSoftSimpleEventLog.LogEvent(EventType: Integer;
const LogMsg: WideString);
begin
case EventType of
ViaThinkSoftSimpleLogEvent_TLB.Success:
WriteEventLog(SourceName, EVENTLOG_SUCCESS, MSG_SUCCESS, LogMsg);
ViaThinkSoftSimpleLogEvent_TLB.Informational:
WriteEventLog(SourceName, EVENTLOG_INFORMATION_TYPE, MSG_INFORMATIONAL, LogMsg);
ViaThinkSoftSimpleLogEvent_TLB.Warning:
WriteEventLog(SourceName, EVENTLOG_WARNING_TYPE, MSG_WARNING, LogMsg);
ViaThinkSoftSimpleLogEvent_TLB.Error:
WriteEventLog(SourceName, EVENTLOG_ERROR_TYPE, MSG_ERROR, LogMsg);
0:
WriteEventLog(LOGEVENT_PROVIDER_NAME, EVENTLOG_SUCCESS, MSG_SUCCESS, LogMsg);
1:
WriteEventLog(LOGEVENT_PROVIDER_NAME, EVENTLOG_INFORMATION_TYPE, MSG_INFORMATIONAL, LogMsg);
2:
WriteEventLog(LOGEVENT_PROVIDER_NAME, EVENTLOG_WARNING_TYPE, MSG_WARNING, LogMsg);
3:
WriteEventLog(LOGEVENT_PROVIDER_NAME, EVENTLOG_ERROR_TYPE, MSG_ERROR, LogMsg);
else
// TODO: Exception/Error ?
end;
end;
 
/trunk/TLB/ViaThinkSoftSimpleLogEvent_TLB.pas
1,48 → 1,46
unit ViaThinkSoftSimpleLogEvent_TLB;
 
// ************************************************************************ //
// WARNUNG
// WARNING
// -------
// Die in dieser Datei deklarierten Typen wurden aus Daten einer Typbibliothek
// generiert. Wenn diese Typbibliothek explizit oder indirekt (über eine
// andere Typbibliothek) reimportiert wird oder wenn der Befehl
// 'Aktualisieren' im Typbibliotheks-Editor während des Bearbeitens der
// Typbibliothek aktiviert ist, wird der Inhalt dieser Datei neu generiert und
// alle manuell vorgenommenen Änderungen gehen verloren.
// The types declared in this file were generated from data read from a
// Type Library. If this type library is explicitly or indirectly (via
// another type library referring to this type library) re-imported, or the
// 'Refresh' command of the Type Library Editor activated while editing the
// Type Library, the contents of this file will be regenerated and all
// manual modifications will be lost.
// ************************************************************************ //
 
// $Rev: 52393 $
// Datei am 30.04.2020 23:02:59 erzeugt aus der unten beschriebenen Typbibliothek.
// $Rev: 8291 $
// File generated on 29.04.2020 21:22:15 from Type Library described below.
 
// ************************************************************************ //
// Typbib.: C:\Users\DELL User\SVN\SimpleLogEvent\trunk\TLB\ViaThinkSoftSimpleLogEvent (1)
// Type Lib: D:\VtsEventLog\ComTest2\ViaThinkSoftSimpleLogEvent.tlb (1)
// LIBID: {D7654BA7-41D0-4FF9-8543-C3A4DA936856}
// LCID: 0
// Hilfedatei:
// Hilfe-String: ViaThinkSoftSimpleLogEvent Library
// Liste der Abhäng.:
// Helpfile:
// HelpString: ViaThinkSoftSimpleLogEvent Library
// DepndLst:
// (1) v2.0 stdole, (C:\Windows\SysWOW64\stdole2.tlb)
// SYS_KIND: SYS_WIN32
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit muss ohne Typüberprüfung für Zeiger compiliert werden.
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
{$ALIGN 4}
 
interface
 
uses Winapi.Windows, System.Classes, System.Variants, System.Win.StdVCL, Vcl.Graphics, Vcl.OleServer, Winapi.ActiveX;
uses Windows, ActiveX, Classes, StdVCL, Variants;
 
 
// *********************************************************************//
// In der Typbibliothek deklarierte GUIDS. Die folgenden Präfixe werden verwendet:
// Typbibliotheken : LIBID_xxxx
// GUIDS declared in the TypeLibrary. Following prefixes are used:
// Type Libraries : LIBID_xxxx
// CoClasses : CLASS_xxxx
// DISPInterfaces : DIID_xxxx
// Nicht-DISP-Interfaces: IID_xxxx
// Non-DISP interfaces: IID_xxxx
// *********************************************************************//
const
// Haupt- und Nebenversionen der Typbibliothek
// TypeLibrary Major and minor versions
ViaThinkSoftSimpleLogEventMajorVersion = 1;
ViaThinkSoftSimpleLogEventMinorVersion = 0;
 
50,30 → 48,17
 
IID_IViaThinkSoftSimpleEventLog: TGUID = '{4094657E-8199-460F-A3DD-5BB63B6B0F65}';
CLASS_ViaThinkSoftSimpleEventLog: TGUID = '{E4270053-A217-498C-B395-9EF33187E8C2}';
 
// *********************************************************************//
// Deklaration von in der Typbibliothek definierten Aufzählungen
// *********************************************************************//
// Konstanten für enum LogEventType
type
LogEventType = TOleEnum;
const
Success = $00000000;
Informational = $00000001;
Warning = $00000002;
Error = $00000003;
 
type
 
// *********************************************************************//
// Forward-Deklaration von in der Typbibliothek definierten Typen
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
IViaThinkSoftSimpleEventLog = interface;
IViaThinkSoftSimpleEventLogDisp = dispinterface;
 
// *********************************************************************//
// Deklaration von in der Typbibliothek definierten CoClasses
// (HINWEIS: Hier wird jede CoClass ihrem Standard-Interface zugewiesen)
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
ViaThinkSoftSimpleEventLog = IViaThinkSoftSimpleEventLog;
 
85,8 → 70,7
// *********************************************************************//
IViaThinkSoftSimpleEventLog = interface(IDispatch)
['{4094657E-8199-460F-A3DD-5BB63B6B0F65}']
procedure LogEvent(const SourceName: WideString; EventType: LogEventType;
const LogMsg: WideString); safecall;
procedure LogEvent(EventType: Integer; const LogMsg: WideString); safecall;
end;
 
// *********************************************************************//
96,16 → 80,15
// *********************************************************************//
IViaThinkSoftSimpleEventLogDisp = dispinterface
['{4094657E-8199-460F-A3DD-5BB63B6B0F65}']
procedure LogEvent(const SourceName: WideString; EventType: LogEventType;
const LogMsg: WideString); dispid 201;
procedure LogEvent(EventType: Integer; const LogMsg: WideString); dispid 201;
end;
 
// *********************************************************************//
// Die Klasse CoViaThinkSoftSimpleEventLog stellt die Methoden Create und CreateRemote zur
// Verfügung, um Instanzen des Standard-Interface IViaThinkSoftSimpleEventLog, dargestellt
// von CoClass ViaThinkSoftSimpleEventLog, zu erzeugen. Diese Funktionen können
// von einem Client verwendet werden, der die CoClasses automatisieren
// will, die von dieser Typbibliothek dargestellt werden.
// The Class CoViaThinkSoftSimpleEventLog provides a Create and CreateRemote method to
// create instances of the default interface IViaThinkSoftSimpleEventLog exposed by
// the CoClass ViaThinkSoftSimpleEventLog. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
CoViaThinkSoftSimpleEventLog = class
class function Create: IViaThinkSoftSimpleEventLog;
114,7 → 97,7
 
implementation
 
uses System.Win.ComObj;
uses ComObj;
 
class function CoViaThinkSoftSimpleEventLog.Create: IViaThinkSoftSimpleEventLog;
begin
127,4 → 110,3
end;
 
end.