在VFP中调用系统用户及单位名称
本地lcBuffer,;
lnBufferSize,;
lcRetVal,;
lnReserved,;
lnResult,;
lnError,;
in type,;
lcKey,;
lcUser,;
LC company
#定义错误_成功0
# DEFINE HKEY _ LOCAL _ MACHINE-2147483646
# DEFINE KEY _ win 4 _ MSINFO " Software \ Microsoft \ Windows \ Current "
# DEFINE KEY _ query _ value 1
*-注册表函数
在Win32 API中声明整数regopenkeyex
Integer nKey,String @cSubKey,Integer nReserved,;
Integer nAccessMask,Integer @ n result
在Win32API中声明Integer RegQueryValueEx
Integer nKey,String cValueName,Integer nReserved,;
Integer @nType,String @cBuffer,Integer @ nBufferSize
在Win32API中声明Integer RegCloseKey
Integer Key
*-Windows 3 . x API函数
将Win32 API中的Integer GetProfileString声明为GetProstr
String cSection,String cKey,String cDefault,;
string @ cbuffer,integer n buffer size
*-初始化DLL调用变量
store0to ln reserved,ln result,lnType
LC buffer = SPACE(128)
lnbuffer size = LEN(LC buffer)
STORE " " TO LC user,Company
do case
case upper(OS())= " windows nt "
*-系统为windows nt
lnerror
lnReserved,KEY_QUERY_VALUE,@ ln result)
IF lnError = ERROR _ SUCCESS
lnType = 0
LC buffer = SPACE(128)
lnbuffer size = LEN(LC buffer)
lnError = RegQueryValueEx(ln result," RegisteredOwner ",lnReserved,;
@lnType,@lcBuffer,@ lnbuffer size)
IF lnError = ERROR _ SUCCESS AND LC buffer CHR(0)
lcUser = LEFT(LC buffer,lnbuffer size-1)
ENDIF
lnType = 0
LC buffer = SPACE(128)
lnbuffer size = LEN(LC buffer)
lnError = RegQueryValueEx(lnResult," registered
@lnType,@lcBuffer,@ Lnbuffer size)
IF lnError = ERROR _ SUCCESS AND LC buffer CHR(0)
LC company = LEFT(LC buffer,ln buffer size-1)
endif
= regclosekey(ln result)
caseupper(OS())= " Windows 4 "
*-系统为Windows 95或更高版本
lnError = reg
lnReserved,KEY_QUERY_VALUE,@ ln result)
IF lnError = ERROR _ SUCCESS
lnType = 0
LC buffer = SPACE(128)
lnbuffer size = LEN(LC buffer)
lnError = RegQueryValueEx(ln result," RegisteredOwner ",lnReserved,;
@lnType,@lcBuffer,@ lnbuffer size)
IF lnError = ERROR _ SUCCESS AND LC buffer CHR(0)
lcUser = LEFT(LC buffer,lnbuffer size-1)
ENDIF
lnType = 0
LC buffer = SPACE(128)
lnbuffer size = LEN(LC buffer)
lnError = RegQueryValueEx(lnResult," registered
@lnType,@lcBuffer,@ Lnbuffer size)
IF lnError = ERROR _ SUCCESS AND LC buffer CHR(0)
LC company = LEFT(LC buffer,ln buffer size-1)
Endif
= regclosekey(ln result)
other
*-系统为Windows版本3 . x
lcRetVal = get prostr(" MS用户信息"," DEFNAME
0条评论