设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 4901|回复: 4
打印 上一主题 下一主题

How to Get the Network Log In Name and Computer Name of the Currently Logged

[复制链接]

点击这里给我发消息

跳转到指定楼层
1#
发表于 2005-8-5 20:02:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
标题:How to Get the Network Log In Name and Computer Name of the Currently Logged In User

原作者:ATTAC Consulting Group

Two easy API calls can provide you with network log in name of the current user of the workstation and the network name of the computer itself for use in your Access application. Declare the following functions in your module and add the following function:     Private Declare Function api_GetUserName Lib "advapi32.dll" Alias _

          "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

    Private Declare Function api_GetComputerName Lib "Kernel32" Alias _

          "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long



    Public Function CNames(UserOrComputer As Byte) As String

    'UserorComputer; 1=User, anything else = computer

    Dim NBuffer As String

    Dim Buffsize As Long

    Dim wOK As Long

        

    Buffsize = 256

    NBuffer = Space$(Buffsize)

      

    If UserOrComputer = 1 Then

        wOK = api_GetUserName(NBuffer, Buffsize)

         CNames = Trim$(NBuffer)

    Else

        Wok = api_GetComputerName(NBuffer, Buffsize)

        CNames = Trim$(NBuffer)

    End If

End Function



Our System Information sample mdb in the Free file library contains this an other useful system api functions.
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2005-8-9 02:27:00 | 只看该作者
翻译:

标题:怎么取得网络注册名和当前登录的用户的计算机名称?

在你应用ACCESS时,调动两个API函数,就可以轻而易举的取得当前网络工作站用户的注册名和计算机的网络名。在您的模块里添加以下两个声明和过程:Private Declare Function api_GetUserName Lib "advapi32.dll" Alias _

          "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

    Private Declare Function api_GetComputerName Lib "Kernel32" Alias _

          "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long



    Public Function CNames(UserOrComputer As Byte) As String

    'UserorComputer; 1=User, anything else = computer

    Dim NBuffer As String

    Dim Buffsize As Long

    Dim wOK As Long

        

    Buffsize = 256

    NBuffer = Space$(Buffsize)

      

    If UserOrComputer = 1 Then

        wOK = api_GetUserName(NBuffer, Buffsize)

         CNames = Trim$(NBuffer)

    Else

        Wok = api_GetComputerName(NBuffer, Buffsize)

        CNames = Trim$(NBuffer)

    End If

End Function



在我们免费的系统信息例子里就包括这样一些有用的系统API函数。

附例:[em01]



[此贴子已经被作者于2005-8-17 12:16:35编辑过]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-3 09:25 , Processed in 0.081484 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表