Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Custom GDI+ class
Converting Unicode data from the Clipboard to a character string using a given code page
Custom FTP Class for Visual FoxPro application
Custom HttpRequest class (WinINet)
Splash Screen for the VFP application
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
Establishing connection using the SQLDriverConnect
Displaying bitmap using the AlphaBlend function
How to put a vertical text scrolling on the form (a movie cast)
How to make a VFP form fading out when released (GDI+ version)
How to make a VFP form fading out when released (GDI version)
Using FlashWindowEx to flash the taskbar button of the VFP application
Winsock: sending email messages (SMTP, port 25)
How to create non-blocking Winsock server
Using WM_COPYDATA for interprocess communication (VFP9)
Creating a mailslot
Peer-to-peer LAN messenger built with Mailslot API functions
How to print a bitmap file
Sending a standard message with one or more attached files using default email client
Class for sound recording
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
Pocket PC: System Registry Viewer

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
Before you begin:
Start ActiveSync and establish connection with your Pocket PC before testing the following code.

The code is based on custom RAPI class. Download the class module first and save it in clsRapiReg.prg file.

Note that this class creates several Collections, which makes it unusable in older Visual FoxPro versions.


 
oForm = CREATEOBJECT("Tform")
oForm.Show(1)
* end of main
 
DEFINE CLASS Tform As Form
PROTECTED root, rapi
    Height=419
    Width=685
    BorderStyle=2
    AutoCenter=.T.
    Caption="Registry Viewer for Windows CE-based device"
    MaxButton=.F.
    ADD OBJECT tree As Ttree WITH Top=0, Left=0, Height=396, Width=204
    ADD OBJECT lst As Tlst WITH Top=0, Left=216, Height=396, Width=468
    ADD OBJECT sbar As Tbar WITH Top=398, Left=0, Height=21, Width=685
 
PROCEDURE Init
#DEFINE HKEY_CLASSES_ROOT   0x80000000
#DEFINE HKEY_CURRENT_USER   0x80000001
#DEFINE HKEY_LOCAL_MACHINE  0x80000002
#DEFINE HKEY_USERS          0x80000003
 
    SET PROCEDURE TO clsRapiReg ADDITIVE
    THIS.rapi = CREATEOBJECT("Trapi")
 
    IF NOT THIS.rapi.connected
        = MESSAGEBOX("Mobile device is unavailable.     ", 48, "Error")
        RETURN
    ENDIF
 
    THIS.root = THIS.tree.Nodes.Add(,, "root", "MyDevice")
 
    THIS.AddNode(THIS.root, HKEY_CLASSES_ROOT,;
        HKEY_CLASSES_ROOT, "HKEY_CLASSES_ROOT")
 
    THIS.AddNode(THIS.root, HKEY_CURRENT_USER,;
        HKEY_CURRENT_USER, "HKEY_CURRENT_USER")
 
    THIS.AddNode(THIS.root, HKEY_LOCAL_MACHINE,;
        HKEY_LOCAL_MACHINE, "HKEY_LOCAL_MACHINE")
 
    THIS.AddNode(THIS.root, HKEY_USERS,;
        HKEY_USERS, "HKEY_USERS")
 
    THIS.root.expanded = .T.
 
PROCEDURE addnode(ParentNode, nRootKey, RegKey, RegKeyName)
    LOCAL oNode, cNodeKey, oSubkeys, nIndex, cSubkeyName
    cNodeKey = "n" + LTRIM(STR(THIS.tree.Nodes.Count))
    oNode = THIS.tree.Nodes.Add(ParentNode, 4, cNodeKey, RegKeyName)
    oNode.Tag = nRootKey
 
    IF ParentNode.Key="root"
        oNode.Bold = .T.
    ENDIF
    IF RegKey <> 0
        THIS.AddChildren(oNode, nRootKey, RegKey)
    ENDIF
 
PROCEDURE addchildren(oParentNode, nRootKey, RegKey)
    LOCAL oSubkeys, cSubkeyName, oItem
    oSubkeys = CREATEOBJECT("Tkeys", m.RegKey)
    oSubkeys.KeySort=2
    FOR EACH oItem IN oSubkeys
        cSubkeyName = oItem.keyname
        THIS.AddNode(oParentNode, nRootKey, 0, cSubkeyName)
    ENDFOR
 
PROCEDURE onnodeexpand(oParent)
    LOCAL nIndex, oNode, cPath, nRootKey
    nRootKey = oParent.Tag
    oNode = oParent.Child
 
    DO WHILE .T.
        IF NOT oNode.Checked
            cPath = oNode.FullPath
            cPath = SUBSTR(cPath, AT("\",cPath,2)+1)
 
            LOCAL oSubkey
            oSubkey = CREATEOBJECT("Tkey", nRootKey, cPath)
            oSubkey.OpenKey
            THIS.AddChildren(oNode, nRootKey, oSubkey.hkey)
            RELEASE oSubkey
 
            oNode.Checked = .T.
        ENDIF
        IF oNode = oNode.LastSibling
            EXIT
        ENDIF
        oNode = oNode.Next
    ENDDO
 
PROCEDURE onnodeclick(oNode)
    THIS.sbar.Panels(1).Text = oNode.FullPath
    THIS.DisplayValues(oNode)
 
PROCEDURE displayvalues(oNode)
#DEFINE REG_NONE  0
#DEFINE REG_SZ  1
#DEFINE REG_EXPAND_SZ 2
#DEFINE REG_BINARY  3
#DEFINE REG_DWORD  4
#DEFINE REG_MULTI_SZ 7
 
    THIS.lst.ListItems.Clear
    IF oNode.key = "root"
        RETURN
    ENDIF
 
    LOCAL nRootKey, cPath, oKey, oListItem
    nRootKey = oNode.Tag
    cPath = oNode.FullPath
    cPath = SUBSTR(cPath, AT("\",cPath,2)+1)
 
    oKey = CREATEOBJECT("Tkey", nRootKey, cPath)
    oKey.OpenKey
    oKey.GetValues
    oKey.keyvalues.KeySort=2
 
    LOCAL cValue, nType, cType, vValue, oValue
    FOR EACH oValue IN oKey.keyvalues
        cValue = oValue.valuename
        vValue = oValue.valuerawdata
        nType = oValue.valuetype
 
        DO CASE
        CASE nType = REG_NONE
            cType = "REG_NONE"
        CASE nType = REG_SZ
            cType = "REG_SZ"
            vValue = STRCONV(vValue, 6)
        CASE nType = REG_EXPAND_SZ
            cType = "REG_EXPAND_SZ"
            vValue = STRCONV(vValue, 6)
        CASE nType = REG_MULTI_SZ
            cType = "REG_MULTI_SZ"
            vValue = STRCONV(vValue, 6)
        CASE nType = REG_BINARY
            cType = "REG_BINARY"
            vValue = "(binary)"
        CASE nType = REG_DWORD
            cType = "REG_DWORD"
            vValue = buf2dword(vValue)
        OTHERWISE
            cType = LTRIM(STR(nType))
        ENDCASE
 
        oListItem = THIS.lst.ListItems.Add(,, cValue)
        oListItem.Subitems(1) = cType
        oListItem.Subitems(2) = vValue
    ENDFOR
ENDDEFINE
 
DEFINE CLASS Ttree As OleControl
    OleClass="MSComctlLib.TreeCtrl"
PROCEDURE Init
    THIS.PathSeparator="\"
    THIS.Style=7
    THIS.LineStyle=0
    THIS.LabelEdit=1
    THIS.Indentation=12
 
PROCEDURE Collapse(node)
    ThisForm.OnNodeClick(node)
PROCEDURE Expand(node)
    ThisForm.OnNodeExpand(node)
PROCEDURE NodeClick(node)
    ThisForm.OnNodeClick(node)
ENDDEFINE
 
DEFINE CLASS Tlst As OleControl
    OleClass="MSComctlLib.ListViewCtrl"
PROCEDURE Init
    THIS.View=3
    THIS.Arrange=0
    THIS.LabelEdit=1
    THIS.AddColumnHeader("Name", 140)
    THIS.AddColumnHeader("Type", 120)
    THIS.AddColumnHeader("Data", 200)
 
PROTECTED PROCEDURE AddColumnHeader(cCaption, nWidth)
    WITH THIS.ColumnHeaders.Add()
        .Text=cCaption
        .Width=nWidth
    ENDWITH
ENDDEFINE
 
DEFINE CLASS Tbar As OleControl
    OleClass="MSComctlLib.SBarCtrl.2"
PROCEDURE Init
    THIS.Height=21
    THIS.Panels(1).Width = 800
ENDDEFINE
 
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
4776 bytes  
Created: 2004-06-24 01:28:22  
Modified: 2011-01-08 08:19:09  
Visits in 7 days: 54  
Listed functions:
Printer friendly API declarations
My comment:
API functions used in the base class:
CeRapiInitEx
CeRapiUninit
CeRegCloseKey
CeRegCreateKeyEx
CeRegDeleteKey
CeRegDeleteValue
CeRegEnumKeyEx
CeRegEnumValue
CeRegOpenKeyEx
CeRegQueryInfoKey
CeRegSetValueEx
WaitForSingleObject

#kwd: sln_pocketpc.
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 (23.20.196.179)
18.2 min.Function: 'send'
Function group: 'Windows Sockets 2 (Winsock)'
18.35 min.Example: 'Who owns the Windows Clipboard'
1.04 hrs.
 Function: 'GetVersionEx'
5.16 hrs.Function: 'GetDlgItem'
 Function: 'LocalSize'
8.64 hrs.Example: 'GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file'
12.35 hrs.Function: 'DeleteObject'
Google
Advertise here!