Who am I? How to use Microsoft Office Permission/UserPermission

前端 未结 3 389
孤城傲影
孤城傲影 2021-01-02 16:41

Microsoft Office documents, im my case: PowerPoint presentations, can have restricted permissions. How can I find out, programmatically, which permissions my code has on a g

3条回答
  •  醉酒成梦
    2021-01-02 17:24

    Try one of the functions GetUserName(), GetUserNameW() or GetUserNameA() and declare it thusly:

    Private Declare Function GetUserName Lib "advapi32.dll" Alias _
        "GetUserName" (ByVal lpBuffer As String, nSize As Long) As Long
    

    Also see MSDN about GetUserName.

    You need to dim a string with length 255 and pass 254 as parameter nSize. This string is passed ByVal back to the caller. Perhaps you need to left() the string before you can use it to compare it with uperm.UserId.

提交回复
热议问题