ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

Comment récupérer les 'settings' de Visual Foxpro avec les API   



L'auteur

Mike Gagnon
Canada Canada
Membre Simple
# 0000000025
enregistré le 14/10/2004

Gagnon Mike
Pointe Cla H9R 3K8
de la société Carver Technologies Inc.
Fiche personnelle


Note des membres
pas de note

Contributions > 05 - API et appels systèmes

Comment récupérer les 'settings' de Visual Foxpro avec les API
# 0000000828
ajouté le 08/07/2012 23:34:05 et modifié le 08/07/2012
consulté 7027 fois
Niveau initié

Version(s) Foxpro :
VFP 9.0
VFP 8.0
VFP 7.0
VFP 6.0
VFP 5.0

Description

À la demande de Koen à la conférence.

Code source :
#DEFINE ERROR_SUCCESS 0
#DEFINE KEY_READ 0x020019
#DEFINE KEY_ALL_ACCESS 0x0F003F
#DEFINE HKEY_CURRENT_USER 0x80000001

DO declare

hBaseKey = 0
lcBaseKey = "Software\Microsoft\VisualFoxPro\9.0\Options"

IF RegOpenKeyEx(HKEY_CURRENT_USER, lcBaseKey,;
    0, KEY_ALL_ACCESS, @hBaseKey) <> ERROR_SUCCESS
    ? "Error opening registry key"
    RETURN
ENDIF

CREATE CURSOR cs (valuename C(50), valuevalue C(200))

dwIndex = 0
DO WHILE .T.
    lnValueLen = 250
    lcValueName = Repli(Chr(0), lnValueLen)
    lnType = 0
    lnDataLen = 250
    lcData = Repli(Chr(0), lnDataLen)

    lnResult = RegEnumValue(hBaseKey, dwIndex,;
        @lcValueName, @lnValueLen, 0,;
        @lnType, @lcData, @lnDataLen)

    * for this case on return the type of data (lnType)
    * is always equal to 1 (REG_SZ)
    * that means null-terminated string

    IF lnResult <> ERROR_SUCCESS
        EXIT
    ENDIF

    lcValueName = Left(lcValueName, lnValueLen)
    lcData = Left(lcData, lnDataLen-1)
    INSERT INTO cs VALUES (lcValueName, lcData)

    dwIndex = dwIndex + 1
ENDDO

= RegCloseKey(hBaseKey)
SELECT cs
INDEX ON valuename TAG valuename
GO TOP
BROW NORMAL NOWAIT

PROCEDURE declare
    DECLARE INTEGER RegCloseKey IN advapi32 INTEGER hKey

    DECLARE INTEGER RegOpenKeyEx IN advapi32;
        INTEGER hKey, STRING lpSubKey, INTEGER ulOptions,;
        INTEGER samDesired, INTEGER @phkResult

    DECLARE INTEGER RegEnumValue IN advapi32;
        INTEGER hKey, INTEGER dwIndex, STRING @lpValueName,;
        INTEGER @lpcValueName, INTEGER lpReserved, INTEGER @lpType,;
        STRING @lpData, INTEGER @lpcbData
Commentaires
Aucun commentaire enregistré ...

Publicité

Les pubs en cours :

www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2024.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3