Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Saying "Hello World!" with VFP and WinAPI
Simulating DOEVENTS
Adding supplementary data to AVI files
Using IsChild() for testing ThisForm.ShowWindow property
Using the Semaphore object
Winsock: how to retrieve a service information corresponding to a service name
Current System information
GetFileOwner - Get the owner of an NTFS file
Hiding mouse cursor
Running a regular FoxPro form while main VFP window is minimized
Starting a dialog box for connecting to network resources and passing input parameters
An alternative way of setting Form.Closable to False
Building a tree of subdirectories for a given path using FindFile functions
Enumerating MIDI output devices
How to retrieve version information for the specified file
Reading STARTUPINFO structure for the current VFP session
Simple MAPI: how to resolve a name to unique address list entry
Drawing a window caption using the DrawCaption routine
How to enumerate terminal servers within the specified Windows domain
Retrieving geometrical parameters of the system desktop window
Copying files as a transacted operation (Vista)
How to generate UUID values
How to test file attributes (key method for FileExists and DirectoryExists routines)
Setting and retrieving the double-click time for the mouse
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: 45  
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 (107.20.129.212)
34.38 min.Example: 'How to delete IE cookies, clear IE history and delete files in Temporary Internet Files directory'
34.43 min.Links
Page 4
1.28 hrs.Example: 'Peer-to-peer LAN messenger built with Mailslot API functions'
4.16 hrs.Function: 'DeletePort'
Function group: 'Printing and Print Spooler'
4.62 hrs.Function: 'send'
6.99 hrs.Function: 'NetUserEnum'
Function group: 'Network Management'
 Example: 'Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form'
7.64 hrs.Function: 'UrlUnescape'
Function group: 'Shell Lightweight Utility APIs -- Path Functions'
 Example: 'Passing data records between VFP applications via the Clipboard'
10.3 hrs.Example: 'Reading VFP settings from the Windows Registry'
Google
Advertise here!