Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to register custom Event Log source
Starting external program from VFP and waiting for its termination
The window and its ancestors
Using Beep and Sleep functions to make the old tin buzz sing (WinNT only?)
Verifying a file using the Authenticode policy provider
Dragging files from Explorer window and dropping them on FoxPro control (requires VFP9)
How to create a service object
How to create non-blocking Winsock server
Retrieving the name of the primary domain controller (PDC) and join status information
Uploading file to the FTP server using InternetWriteFile
Using GetFileSize
Changing pitch and speed of a wave file
Custom HttpRequest class (WinINet)
How to read email messages using Simple MAPI
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Drawing a window caption using the DrawCaption routine
Enumerating Performance Counters
How to prevent users from accessing the Windows Desktop and from switching to other applications
Playing WAV files on InteractiveChange
GDI+ fun: roach-infested desktop
How to change the name and the size of the font in the MessageBox dialog
How to create transparent areas inside a form -- punching holes in the form
Start an executable from VFP application by using the CreateProcess
Time in milliseconds represented as string (e.g. 1 hour 24 min 36 sec)
How to register custom Event Log source

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
click to open
Before you begin:
When properly registered, a custom event log is listed in Application and Services Logs. A picture below displays custom event log MyEventLog opened in Windows Event Viewer.

Such log can be created through adding several Registry keys and values. Required Registry entries can be produced either manually (use Windows RegEdit or any similar utility) or programmatically (assumes admin rights).

MaxSize = maximum size, in bytes, of the log file. This value is of type REG_DWORD. The value must be set to a multiple of 64K for a System, Application, or Security log. The default value is 1MB.

Read more about Eventlog Keys on MSDN.

EventMessageFile value normally contains the path to a DLL or EXE file containing message resources designed for a particular application.

To fill the blank, the path to .NET message resource file is used -- C:\Windows\Microsoft.NET\Framework64\v2.0.50727\EventLogMessages.dll -- in real life to be substituted with application-specific file.

* * *
Note that the code below creates objects from classes implemented in Windows Registry class library. Before testing this code sample, store the library code in RegistryClassLib.PRG file.

VFP Registry Access Foundation Class contains all required functionality, and also can be used for building a similar code.

* * *
Note that VFP session or VFP application intended to access the Registry must be started with admin privileges.

See also:
  • Writing entries to custom Event Log
  • Reading entries from Event logs
        "C:\Windows\Microsoft.NET\Framework\" +;
    DO CreateEventSource;
        WITH "MyEventLog", "MyEventSource"
    * end of main
    PROCEDURE CreateEventSource(cLogName As String,;
        cSourceName As String)
        *** save code sample #472 in RegistryClassLib.PRG
        SET PROCEDURE TO RegistryClassLib ADDITIVE
        LOCAL oRegistry As Registry, oEventlogKey As regkey,;
            oAppLogKey As regkey, oEventSourceKey As regkey
        oRegistry = CREATEOBJECT("Registry")
        oEventlogKey = CREATEOBJECT("regkey",;
        IF oEventlogKey.OpenKey()
            IF oEventlogKey.subkeyexists(m.cLogName, .T.)
                oAppLogKey = CREATEOBJECT("regkey",;
                    oEventlogKey.hKey, m.cLogName)
                WITH oAppLogKey
                    IF .OpenKey()
                        .SetValue("AutoBackupLogFiles", 4, 0)
                        .SetValue("MaxSize", 4, 0x80000)
                        IF .subkeyexists(m.cSourceName, .T.)
                            oEventSourceKey = CREATEOBJECT("regkey",;
                                oAppLogKey.hKey, m.cSourceName)
                            WITH oEventSourceKey
                                IF .OpenKey()
                                        2, MESSAGE_SOURCE_DLL)

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    1352 bytes  
    Created: 2010-06-29 13:04:47  
    Modified: 2010-06-30 09:08:59  
    Visits in 7 days: 152  
    Listed functions:
    Printer friendly API declarations
    My comment:
    Read article Using the Windows Event Log from Visual FoxPro written by Craig Berntson and Cole Gleave.
    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.

    Copyright 2001-2018 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (
    3 sec.Function: 'GetFileAttributesEx'
    Function group: 'File Management'
    5 sec.Example: 'How to download a file from HTTP server using URL Monikers functions'
    6 sec.Function: 'DeleteFileTransacted'
    Function group: 'File Management'
    10 sec.Function: 'WSAEnumProtocols'
    Function group: 'Windows Sockets 2 (Winsock)'
    14 sec.
    16 sec.Updates
    18 sec.Function: 'SHAddToRecentDocs'
    Function group: 'Shell Functions'
    20 sec.Function: 'waveInStart'
    Function group: 'Windows Multimedia'
    21 sec.
    24 sec.Function: 'GetTextCharacterExtra'
    Function group: 'Font and Text'
    Advertise here!