-
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
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
最新更新
显示/隐藏Excel网格线
用NPOI操作EXCEL--锁定列
组合行、列
用NPOI操作EXCEL--设置密码
用NPOI操作EXCEL--调整表单显示比例
打印相关设置
用NPOI操作EXCEL--插入图片
用NPOI操作EXCEL--画Grid
用NPOI操作EXCEL--画圆形
用NPOI操作EXCEL--画矩形
MySql索引原理与使用大全
Mysql命令大全(完整版)
Mysql常用命令行大全
mysql 索引类型以及创建
mysql命令详解
mysql的下载和命令行简单操作
mysql常用管理命令
MySQL命令大全
mysql命令行登录容易出现的错误
解决mysql的cmd命令错误及2003连接错误
数据类型之对象
数据类型之布尔型、整型、浮点型和字符
php教程之数据类型之数组
php教程之PHP 常量
php教程之变量
php教程之语法
PHP简介与安装
phpMyAdmin配置安装全攻略
PHP是什么
win2003 iis整合php后 环境变量无法读取到