-
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
最新更新
nodejs爬虫
Python正则表达式完全指南
爬取豆瓣Top250图书数据
shp 地图文件批量添加字段
爬虫小试牛刀(爬取学校通知公告)
【python基础】函数-初识函数
【python基础】函数-返回值
HTTP请求:requests模块基础使用必知必会
Python初学者友好丨详解参数传递类型
如何有效管理爬虫流量?
SQL SERVER中递归
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比
一款纯 JS 实现的轻量化图片编辑器
关于开发 VS Code 插件遇到的 workbench.scm.
前端设计模式——观察者模式
前端设计模式——中介者模式
创建型-原型模式