Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
How to display Windows On-Screen Keyboard
How to print a bitmap file
Winsock: sending email messages (SMTP, port 25)
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
System Image List Viewer
Custom HttpRequest class (WinHTTP)
Creating the Save dialog box to specify the drive, directory, and name of a file to save
The window and its ancestors
Printing Image File, programmatically set print page orientation to landscape
How to convert a bitmap file to monochrome format (1 bpp)
Mapping and disconnecting network drives
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Using EnumPrinters function to enumerate locally installed printers
Custom FTP Class for Visual FoxPro application
Displaying the associated icons and descriptions for files and folders
How to activate Windows Calculator
How to download a file from the FTP server using FtpGetFile
Sending email messages with Simple MAPI
Confining Windows calculator inside the VFP main window
Windows Shell Icons displayed and exported to ICO files (Vista)
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
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
Versions:
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
  •  
    #DEFINE HKEY_LOCAL_MACHINE 0x80000002
     
    #DEFINE REG_PATH_EVENTLOG;
        "SYSTEM\CurrentControlSet\services\eventlog"
     
    #DEFINE MESSAGE_SOURCE_DLL;
        "C:\Windows\Microsoft.NET\Framework\" +;
        "v2.0.50727\EventLogMessages.dll"
     
    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",;
            HKEY_LOCAL_MACHINE, REG_PATH_EVENTLOG)
     
        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()
                                    .SetValue("EventMessageFile",;
                                        2, MESSAGE_SOURCE_DLL)
                                ENDIF
                            ENDWITH
     
                        ENDIF
                    ENDIF
                ENDWITH
            ENDIF
        ENDIF
     

    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: 82  
    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  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright © 2001-2013 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.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (50.16.166.175)
    3 sec.Example: 'Opening access to the Microsoft Internet functions for the application'
    7 sec.Example: 'Adding printer to the list of supported printers for the specified server'
    3.86 hrs.Example: 'How to play AVI file on the _screen'
    3.87 hrs.Example: 'Custom GDI+ class'
    5.85 hrs.Function: 'CreateCompatibleDC'
    Function group: 'Device Context'
     Example: 'Displaying animated images on FoxPro form with BitBlt and StretchBlt functions'
    6.94 hrs.Example: 'Retrieving information about the main VFP window'
    6.95 hrs.Example: 'How to empty the Recycle Bin'
     Example: 'How to position the GETPRINTER() dialog'
    10.87 hrs.Example: 'Accessing LSA Policy object (Local Security Authority)'
    Google
    Advertise here!