Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Event logging with VFP revisited
Message
De
27/03/2002 08:39:46
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00637226
Message ID:
00637775
Vues:
22
Thank's guys,

It seems I'm almost, but not quite there.
I downloaded Ed Rauh's program & all, but there's something missing, because in the eventlog, instead of the message 'Test message from Peter Pirker'

I get:

The description for Event ID ( 0 ) in Source ( HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog\Application\WinApp) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. The following information is part of the event: Test message from Peter Pirker.

Now I don't know what the 'remote computer' talk's all about, I'm running it locally.

I don't have a WinApp entry under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog\Application\, so I tried with one that's there - but that get's me the same message.

I assume I still have to RegisterEventSource() to get a handle & all that?

So where's my snafu?

>Peter,
>Vlad is correct, you need a memory managment class to handle this and ClsHeap is perfect for this, IMO.
>#define EVENTLOG_ERROR_TYPE 0x1
>#define EVENTLOG_WARNING_TYPE 0x2
>
>local loheap, lcmessage, lnptr
>loheap = newobject('heap','clsheap.prg')
>lcmessage = 'Test message'
>
>lnptr = loheap.AllocString(lcmessage)
>
>declare integer ReportEvent in win32api ;
>   integer hEventlog, ;
>   integer nEventType,;
>   integer nEventCategory, ;
>   integer nEventID, ;
>   integer nSecurityIdentifier, ;
>   integer nNumberofStrings, ;
>   integer nDatasize, ;
>   integer@ pMessage, ;
>   integer nDatabuffer
>
>? ReportEvent(MyHandle,EVENTLOG_ERROR_TYPE,0,0,0,1,0,@lnptr,0)
>The above example added an error event to my Application event log.
>
>HTH.
>
>>This is as far as I got and now I'm stuck:
>>
>>
>>lcString1='\\SMT002'
>>lcString2='HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog\Application\WinApp'
>>
>>DECLARE INTEGER RegisterEventSource IN WIN32API STRING lcString1,STRING lcString2
>>
>>MyHandle=RegisterEventSource(lcString1,lcString2)
>>
>>&& The ReportEvent() should be here
>>
>>DECLARE INTEGER DeregisterEventSource IN WIN32API INTEGER lnHandle
>>=DeregisterEventSource(MyHandle)
>>
>>
>>I seem to get a valid handle, because some huge number is returned, and I get a returncode of 1 when I call DeregisterEventSource, so I assume that works as well.
>>
>>The MSDN Library describes how to call ReportEvent in Win32API as follows-
>>
>>
>>BOOL ReportEvent(
>>  HANDLE hEventLog,    // handle to event log
>>  WORD wType,          // event type
>>  WORD wCategory,      // event category
>>  DWORD dwEventID,     // event identifier
>>  PSID lpUserSid,      // user security identifier
>>  WORD wNumStrings,    // number of strings to merge
>>  DWORD dwDataSize,    // size of binary data
>>  LPCTSTR *lpStrings,  // array of strings to merge
>>  LPVOID lpRawData     // binary data buffer
>>);
>>Parameters
>>hEventLog
>>[in] Handle to the event log. This handle is returned by the RegisterEventSource function.
>>wType
>>[in] Specifies the type of event being logged. This parameter can be one of the following values. Value Meaning
>>EVENTLOG_SUCCESS Success event
>>EVENTLOG_ERROR_TYPE Error event
>>EVENTLOG_WARNING_TYPE Warning event
>>EVENTLOG_INFORMATION_TYPE Information event
>>EVENTLOG_AUDIT_SUCCESS Success audit event
>>EVENTLOG_AUDIT_FAILURE Failure audit event
>>
>>
>>Now as far as C/C++ is concerned, I don't know my backside from my elbow, and
>>my questions here really are:
>>
>>How do I translate this stuff into a VFP DECLARE-DLL statement?
>>
>>Which parameter types should I use as seen from VFP?
>>
>>Which values shoul I pass?
>>
>>TIA, your help is greatly appreciated.
Peter Pirker


Whosoever shall not fall by the sword or by famine, shall fall by pestilence, so why bother shaving?

(Woody Allen)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform