Subversion Repositories simple_log_event

Compare Revisions

Regard whitespace Rev 2 → Rev 3

/trunk/TLB/ViaThinkSoftSimpleLogEvent.dpr
2,10 → 2,6
 
uses
ComServ,
Registry,
Vcl.Dialogs,
Windows,
SysUtils,
ViaThinkSoftSimpleLogEvent_TLB in 'ViaThinkSoftSimpleLogEvent_TLB.pas',
ViaThinkSoftSimpleLogEvent_Impl in 'ViaThinkSoftSimpleLogEvent_Impl.pas' {ViaThinkSoftSimpleEventLog: CoClass};
 
15,60 → 11,6
 
{$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)'==''">Win64</Platform>
<Platform Condition="'$(Platform)'==''">Win32</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 29.04.2020 21:29:52 (- $Rev: 12980 $, 7765620).
// Datei erzeugt am 30.04.2020 23:03:28 (- $Rev: 12980 $, 10609955).
 
[
uuid(D7654BA7-41D0-4FF9-8543-C3A4DA936856),
24,6 → 24,17
 
 
[
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"),
33,7 → 44,7
interface IViaThinkSoftSimpleEventLog: IDispatch
{
[id(0x000000C9)]
HRESULT _stdcall LogEvent([in] long EventType, [in] BSTR LogMsg);
HRESULT _stdcall LogEvent([in] BSTR SourceName, [in] enum LogEventType 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,12 → 10,10
type
TViaThinkSoftSimpleEventLog = class(TAutoObject, IViaThinkSoftSimpleEventLog)
protected
procedure LogEvent(EventType: Integer; const LogMsg: WideString); safecall;
procedure LogEvent(const SourceName: WideString; EventType: LogEventType; const LogMsg: WideString);
safecall;
end;
 
const
LOGEVENT_PROVIDER_NAME = 'ViaThinkSoft';
 
implementation
 
uses ComServ, Windows;
51,20 → 49,18
end;
end;
 
procedure TViaThinkSoftSimpleEventLog.LogEvent(EventType: Integer;
procedure TViaThinkSoftSimpleEventLog.LogEvent(const SourceName: WideString; EventType: LogEventType;
const LogMsg: WideString);
begin
case EventType of
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 ?
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);
end;
end;
 
/trunk/TLB/ViaThinkSoftSimpleLogEvent_TLB.pas
1,46 → 1,48
unit ViaThinkSoftSimpleLogEvent_TLB;
 
// ************************************************************************ //
// WARNING
// WARNUNG
// -------
// 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.
// 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.
// ************************************************************************ //
 
// $Rev: 8291 $
// File generated on 29.04.2020 21:22:15 from Type Library described below.
// $Rev: 52393 $
// Datei am 30.04.2020 23:02:59 erzeugt aus der unten beschriebenen Typbibliothek.
 
// ************************************************************************ //
// Type Lib: D:\VtsEventLog\ComTest2\ViaThinkSoftSimpleLogEvent.tlb (1)
// Typbib.: C:\Users\DELL User\SVN\SimpleLogEvent\trunk\TLB\ViaThinkSoftSimpleLogEvent (1)
// LIBID: {D7654BA7-41D0-4FF9-8543-C3A4DA936856}
// LCID: 0
// Helpfile:
// HelpString: ViaThinkSoftSimpleLogEvent Library
// DepndLst:
// Hilfedatei:
// Hilfe-String: ViaThinkSoftSimpleLogEvent Library
// Liste der Abhäng.:
// (1) v2.0 stdole, (C:\Windows\SysWOW64\stdole2.tlb)
// SYS_KIND: SYS_WIN32
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$TYPEDADDRESS OFF} // Unit muss ohne Typüberprüfung für Zeiger compiliert werden.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
{$ALIGN 4}
 
interface
 
uses Windows, ActiveX, Classes, StdVCL, Variants;
uses Winapi.Windows, System.Classes, System.Variants, System.Win.StdVCL, Vcl.Graphics, Vcl.OleServer, Winapi.ActiveX;
 
// *********************************************************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used:
// Type Libraries : LIBID_xxxx
// In der Typbibliothek deklarierte GUIDS. Die folgenden Präfixe werden verwendet:
// Typbibliotheken : LIBID_xxxx
// CoClasses : CLASS_xxxx
// DISPInterfaces : DIID_xxxx
// Non-DISP interfaces: IID_xxxx
// Nicht-DISP-Interfaces: IID_xxxx
// *********************************************************************//
const
// TypeLibrary Major and minor versions
// Haupt- und Nebenversionen der Typbibliothek
ViaThinkSoftSimpleLogEventMajorVersion = 1;
ViaThinkSoftSimpleLogEventMinorVersion = 0;
 
48,17 → 50,30
 
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 declaration of types defined in TypeLibrary
// Forward-Deklaration von in der Typbibliothek definierten Typen
// *********************************************************************//
IViaThinkSoftSimpleEventLog = interface;
IViaThinkSoftSimpleEventLogDisp = dispinterface;
 
// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// Deklaration von in der Typbibliothek definierten CoClasses
// (HINWEIS: Hier wird jede CoClass ihrem Standard-Interface zugewiesen)
// *********************************************************************//
ViaThinkSoftSimpleEventLog = IViaThinkSoftSimpleEventLog;
 
70,7 → 85,8
// *********************************************************************//
IViaThinkSoftSimpleEventLog = interface(IDispatch)
['{4094657E-8199-460F-A3DD-5BB63B6B0F65}']
procedure LogEvent(EventType: Integer; const LogMsg: WideString); safecall;
procedure LogEvent(const SourceName: WideString; EventType: LogEventType;
const LogMsg: WideString); safecall;
end;
 
// *********************************************************************//
80,15 → 96,16
// *********************************************************************//
IViaThinkSoftSimpleEventLogDisp = dispinterface
['{4094657E-8199-460F-A3DD-5BB63B6B0F65}']
procedure LogEvent(EventType: Integer; const LogMsg: WideString); dispid 201;
procedure LogEvent(const SourceName: WideString; EventType: LogEventType;
const LogMsg: WideString); dispid 201;
end;
 
// *********************************************************************//
// 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.
// 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.
// *********************************************************************//
CoViaThinkSoftSimpleEventLog = class
class function Create: IViaThinkSoftSimpleEventLog;
97,7 → 114,7
 
implementation
 
uses ComObj;
uses System.Win.ComObj;
 
class function CoViaThinkSoftSimpleEventLog.Create: IViaThinkSoftSimpleEventLog;
begin
110,3 → 127,4
end;
 
end.