标题: 获取全球唯一编码(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