Office中国论坛/Access中国论坛

标题: 获取全球唯一编码(GUID)的方法 [打印本页]

作者: tmtony    时间: 2008-12-1 10:23
标题: 获取全球唯一编码(GUID)的方法
Private Type GUID
  Data1 As Long
  Data2 As Long
  Data3 As Long
  Data4(8) As Byte
End Type
Private Declare Function CoCreateGuid Lib "ole32.dll" ( _
  pguid As GUID) As Long
Private Declare Function StringFromGUID2 Lib "ole32.dll" ( _
  rguid As Any, _
  ByVal lpstrClsId As Long, _
  ByVal cbMax As Long) As Long

自定义一个函数
Public Function GetNewGuild() As String
Dim g As GUID
Dim b() As Byte
Dim lSize As Long
Dim lR As Long
CoCreateGuid g
lSize = 40
ReDim b(0 To (lSize * 2) - 1) As Byte
lR = StringFromGUID2(g, VarPtr(b(0)), lSize)
GetNewGuild = Left$(b, lR - 1)
End Function

也可使用Access本身字段类型中 选择 全球唯一识别码
作者: xaxxax    时间: 2009-3-30 14:31
kankan
作者: szblueidea    时间: 2009-4-29 04:36
可以说下在什么情况下会应用到吗,谢谢
作者: chenyingfengsx    时间: 2009-7-9 15:46
学习下!
作者: chaojianan    时间: 2009-10-7 03:15
谢谢分享。
作者: shines    时间: 2011-1-14 14:13
谢谢分享




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3