php creatobject,创建 GUID CreateObject("Scriptlet.TypeLib") 拒绝的权限

时 间:2018-07-08 01:18:18

作 者:摘 要:过去 CreateObject("Scriptlet.TypeLib") 产生 GUID 的方法,因为安全理由,2017年7月的安全更新里,已经被屏蔽,还是要用微软建议的新方法。

正 文:

当您运行 Visual Basic for Applications 调用 CreateObject("Scriptlet.TypeLib") (VBA) 代码。GUID函数来创建 GUID (Word、Excel 等),则 Microsoft Office 应用程序中您会收到以下错误消息:

Run-time error '70':

Permission denied

此问题是由于。在 7 月 2017年安全更新、CreateObject("Scriptlet.TypeLib")。GUID被阻止的 Office VBA 中的恶意代码的安全防范。

新的方法是:

Private Type GUID_TYPE

Data1 As Long

Data2 As Integer

Data3 As Integer

Data4(7) As Byte

End Type

Private Declare PtrSafe Function CoCreateGuid Lib "ole32.dll" (guid As GUID_TYPE) As LongPtr

Private Declare PtrSafe Function StringFromGUID2 Lib "ole32.dll" (guid As GUID_TYPE, ByVal lpStrGuid As LongPtr, ByVal cbMax As Long) As LongPtr

Function newGUID()

Dim guid As GUID_TYPE

Dim strGuid As String

Dim retValue As LongPtr

Const guidLength As Long = 39 'registry GUID format with null terminator {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

retValue = CoCreateGuid(guid)

If retValue = 0 Then

strGuid = String$(guidLength, vbNullChar)

retValue = StringFromGUID2(guid, StrPtr(strGuid), guidLength)

If retValue = guidLength Then

' valid GUID as a string

newGUID = strGuid

End If

End If

End Function

b88e5f8047bb273b9b7b01f580960615.png

开发者你们好,这是地球信息思维开发者 dbaseIIIer (QQ325613888)

更多的 Access/VBA 互联网交互技术,可以参考

Access软件网QQ交流群(群号:39785885)

Access源码网店

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值