VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 数据库 > Oracle教程 >
  • vfp教程之在VFP中调用系统用户及单位名称

LOCAL lcBuffer, ; 
lnBufferSize, ; 
lcRetVal, ; 
lnReserved, ; 
lnResult, ; 
lnError, ; 
lnType, ; 
lcKey, ; 
lcUser, ; 
lcCompany 
#DEFINE ERROR_SUCCESS 0 
#DEFINE HKEY_LOCAL_MACHINE -2147483646 
#DEFINE KEY_WIN4_MSINFO "Software\Microsoft\Windows\CurrentVersion" 
#DEFINE KEY_QUERY_VALUE 1 
*-- 注册表函数 
DECLARE Integer RegOpenKeyEx IN Win32API ; 
Integer nKey, String @cSubKey, Integer nReserved,; 
Integer nAccessMask, Integer @nResult 
DECLARE Integer RegQueryValueEx IN Win32API ; 
Integer nKey, String cValueName, Integer nReserved,; 
Integer @nType, String @cBuffer, Integer @nBufferSize 
DECLARE Integer RegCloseKey IN Win32API ; 
Integer nKey 
*-- Windows 3.X API 函数 
DECLARE INTEGER GetProfileString IN Win32API AS GetProStr ; 
String cSection, String cKey, String cDefault, ; 
String @cBuffer, Integer nBufferSize   
*-- 初始化DLL调用变量 
STORE 0 TO lnReserved, lnResult, lnType 
lcBuffer = SPACE(128) 
lnBufferSize = LEN(lcBuffer)   
STORE "" TO lcUser, lcCompany   
DO CASE 
CASE UPPER(OS()) = "WINDOWS NT" 
*-- 系统为Windows NT 
lnError =RegOpenKeyEx(HKEY_LOCAL_MACHINE, KEY_SHARED_TOOLS_LOCATION, ; 
lnReserved, KEY_QUERY_VALUE, @lnResult) 
IF lnError = ERROR_SUCCESS 
lnType = 0 
lcBuffer = SPACE(128) 
lnBufferSize = LEN(lcBuffer) 
lnError = RegQueryValueEx(lnResult, "RegisteredOwner", lnReserved, ; 
@lnType, @lcBuffer, @lnBufferSize) 
IF lnError = ERROR_SUCCESS AND lcBuffer <> CHR(0) 
lcUser = LEFT(lcBuffer, lnBufferSize - 1) 
ENDIF 
lnType = 0 
lcBuffer = SPACE(128) 
lnBufferSize = LEN(lcBuffer) 
lnError = RegQueryValueEx(lnResult, "RegisteredOrganization", lnReserved, ; 
@lnType, @lcBuffer, @lnBufferSize)   
IF lnError = ERROR_SUCCESS AND lcBuffer <> CHR(0) 
lcCompany = LEFT(lcBuffer, lnBufferSize - 1) 
ENDIF 
ENDIF 
=RegCloseKey(lnResult) 
CASE UPPER(OS()) = "WINDOWS 4" 
*-- 系统为Windows 95 以上版本 
lnError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KEY_WIN4_MSINFO, ; 
lnReserved, KEY_QUERY_VALUE, @lnResult) 
IF lnError = ERROR_SUCCESS 
lnType = 0 
lcBuffer = SPACE(128) 
lnBufferSize = LEN(lcBuffer) 
lnError = RegQueryValueEx(lnResult, "RegisteredOwner", lnReserved, ; 
@lnType, @lcBuffer, @lnBufferSize) 
IF lnError = ERROR_SUCCESS AND lcBuffer <> CHR(0) 
lcUser = LEFT(lcBuffer, lnBufferSize - 1) 
ENDIF 
lnType = 0 
lcBuffer = SPACE(128) 
lnBufferSize = LEN(lcBuffer) 
lnError = RegQueryValueEx(lnResult, "RegisteredOrganization", lnReserved, ; 
@lnType, @lcBuffer, @lnBufferSize) 
IF lnError = ERROR_SUCCESS AND lcBuffer <> CHR(0) 
lcCompany = LEFT(lcBuffer, lnBufferSize - 1) 
ENDIF 
ENDIF 
=RegCloseKey(lnResult) 
OTHERWISE 
*-- 系统为Windows 3.X 版本 
lcRetVal = GetProStr("MS USER INFO", "DEFNAME", "", @lcBuffer, lnBufferSize) 
lcUser = LEFT(lcBuffer, lcRetVal)   
lcRetVal = GetProStr("MS USER INFO", "DEFCOMPANY", "", @lcBuffer, lnBufferSize) 
lcCompany = LEFT(lcBuffer, lcRetVal) 
ENDCASE 
If lnError = ERROR_SUCCESS 
=MessageBox("用户:" + lcUser + Chr(13) + "单位:" + lcCompany) 
Else 
=MessageBox("未找到用户及单位。") 
Endif

相关教程