当前位置: 代码迷 >> VFP >> 怎样在VFP下如何获取当前机器的ODBC驱动列表
  详细解决方案

怎样在VFP下如何获取当前机器的ODBC驱动列表

热度:7042   发布时间:2013-02-26 00:00:00.0
【求助】怎样在VFP下怎么获取当前机器的ODBC驱动列表
如题
要求能列举出实际例子!谢谢
分数不多了,不能给高分,请见谅

------解决方案--------------------------------------------------------
VB code
MyRegRead("Software\ODBC\ODBC.INI\ODBC Data Sources")Function MyRegRead    Lparameters tcSubKey    #Define ERROR_SUCCESS               0    #Define KEY_READ               131097    #Define KEY_ALL_ACCESS         983103    #Define HKEY_CLASSES_ROOT      -2147483648  && BITSET(0,31)    #Define HKEY_CURRENT_USER      -2147483647  && BITSET(0,31) + 1    #Define HKEY_LOCAL_MACHINE     -2147483646  && BITSET(0,31) + 2    #Define HKEY_USERS             -2147483645  && BITSET(0,31) + 3    #Define HKEY_CURRENT_CONFIG    -2147483643  && BITSET(0,31) + 5    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    Create Cursor MyODBC (ValueType C(50),ValueName C(50),ValueValue C(200))    hBaseKey=0    If RegOpenKeyEx(HKEY_LOCAL_MACHINE,tcSubKey,0,KEY_ALL_ACCESS,@hBaseKey)<>ERROR_SUCCESS        ? "Error opening registry key"        Return    Endif    ReadReg(hBaseKey,"系统DSN")    hBaseKey=0    If RegOpenKeyEx(HKEY_CURRENT_USER,tcSubKey,0,KEY_ALL_ACCESS,@hBaseKey)<>ERROR_SUCCESS        ? "Error opening registry key"        Return    Endif    ReadReg(hBaseKey,"用户DSN")    =RegCloseKey(hBaseKey)    Select MyODBC    Index On ValueType+ValueName To ls    Go Top    Brow Normal NowaitEndfuncFunction ReadReg    Lparameters tnphkResult,tcValueType    dwIndex=0    Do While .T.        lnValueLen=250        lcValueName=Repli(Chr(0),lnValueLen)        lnType=0        lnDataLen=250        lcData=Repli(Chr(0),lnDataLen)        lnResult=RegEnumValue(tnphkResult,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 MyODBC Values (tcValueType,lcValueName,lcData)        dwIndex=dwIndex+1    EnddoEndfunc
  相关解决方案