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
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
Winsock: sending email messages (SMTP, port 25)
System Image List Viewer
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Creating the Save dialog box to specify the drive, directory, and name of a file to save
Custom HttpRequest class (WinHTTP)
Printing Image File, programmatically set print page orientation to landscape
How to convert a bitmap file to monochrome format (1 bpp)
The window and its ancestors
Mapping and disconnecting network drives
How to download a file from the FTP server using FtpGetFile
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
Displaying icons in the system tray (VFP9)
How to activate Windows Calculator
Drawing Windows predefined bitmaps using the LoadBitmap functions
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
Sending email messages with Simple MAPI
Class library providing access to the System Registry

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:
The following code includes classes registry, regkey, regkeys, regvalue and regvalues. All together they provide view, read, write and delete functionality for the System Registry. Examples showing how to use this class are coming soon.

Create Registry object before using any other class from this library. This object contains API declarations the other classes use.

LOCAL rg As Registry
rg = CREATEOBJECT("Registry")

The next snip opens Software key in HKEY_LOCAL_MACHINE and adds _test subkey to it.

LOCAL rgkey As regkey
rgkey = CREATEOBJECT("regkey",;
        HKEY_LOCAL_MACHINE, "Software")

WITH rgkey
        IF .OpenKey()
                .CreateSubkey("_test", "")
        ENDIF
ENDWITH

And the last one adds several values to a key.

WITH rgkey
        IF .OpenKey()
                .SetValue("TestValue0", 0, 16) && REG_NONE
                .SetValue("TestValue1", 1, "abc") && REG_SZ
                .SetValue("TestValue3", 3, "abc") && REG_BINARY
                .SetValue("TestValue4", 4, "128") && REG_DWORD
        ENDIF
ENDWITH
 
Imports Microsoft.Win32
 
Module Module1
    Sub Main()
        Dim r As Registry
 
        REM: ClassesRoot, CurrentConfig, CurrentUser
        REM: LocalMachine, Users
        Dim k As RegistryKey = r.CurrentConfig
 
        REM: recursive procedure
        PrintKey(k, 0)
 
        Console.Write("Press Enter to close this window...")
        Console.ReadLine()
    End Sub
 
    Sub PrintKey(ByRef key As RegistryKey, ByVal level As Integer)
        Dim s As String = ""
        Dim name As String = key.Name
        Dim pos As Integer = InStrRev(name, "\")
        If pos > 0 Then name = Mid(name, pos + 1)
 
        Console.WriteLine(s.PadRight(level * 3, " ") & name)
 
        If key.SubKeyCount = 0 Then Exit Sub
 
        Dim subkeynames() As String = key.GetSubKeyNames()
        Dim subkeyname As String
 
        For Each subkeyname In subkeynames
            Dim subkey As RegistryKey
            Try
                subkey = key.OpenSubKey(subkeyname)
                PrintKey(subkey, level + 1)
                subkey.Close()
            Catch
            End Try
        Next
    End Sub
 
End Module
 
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1152 bytes  
Created: 2004-10-18 19:25:31  
Modified: 2011-12-10 09:20:22  
Visits in 7 days: 95  
Listed functions:
RegCloseKey
RegCreateKeyEx
RegDeleteKey
RegDeleteValue
RegEnumKeyEx
RegEnumValue
RegOpenKeyEx
RegQueryInfoKey
RegSetValueEx
Printer friendly API declarations
My comment:
RegDeleteKey: the subkey to be deleted must not have subkeys. CeRegDeleteKey (Windows CE, RAPI) deletes the subkey regardless of whether it has its own subkeys.
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.132.180)
13.15 min.Example: 'Terminating all running applications from a VFP program'
13.2 min.Function: 'SetMenu'
Function group: 'Menu'
13.28 min.Example: 'Using LoadLibrary'
52.93 min.Example: 'Displaying the color palette stored in an image file'
53 min.Example: 'How to obtain Content-Type value for a file type from the System Registry'
1.09 hrs.Example: 'GetFocus returns a HWND value'
 Example: 'Obtaining names and positions for shortcuts located on the Windows Desktop'
Language: 'C++'
1.44 hrs.Function: 'CeRapiFreeBuffer'
Function group: 'Remote Application Programming (RAPI)'
 Example: 'How to create a desktop shortcut (shell link)'
2.01 hrs.Example: 'Winsock: retrieving Web pages using sockets (HTTP, port 80)'
Google
Advertise here!