zoukankan
html css js c++ java
vb的GUID生成算法
源代码推荐:vb的GUID生成算法
'
RETURNS: GUID if successful; blank string otherwise.
'
Unlike the GUIDS in the registry, this function returns GUID
'
without "-" characters. See comments for how to modify if you
'
want the dash.
Public
Function
GUID()
As
String
Dim
lRetVal
As
Long
Dim
udtGuid
As
GUID
Dim
sPartOne
As
String
Dim
sPartTwo
As
String
Dim
sPartThree
As
String
Dim
sPartFour
As
String
Dim
iDataLen
As
Integer
Dim
iStrLen
As
Integer
Dim
iCtr
As
Integer
Dim
sAns
As
String
On
Error
GoTo
errorhandler
sAns
=
""
lRetVal
=
CoCreateGuid(udtGuid)
If
lRetVal
=
0
Then
'
First 8 chars
sPartOne
=
Hex
$(udtGuid.PartOne)
iStrLen
=
Len
(sPartOne)
iDataLen
=
Len
(udtGuid.PartOne)
sPartOne
=
String
((iDataLen
*
2
)
-
iStrLen,
"
0
"
) _
&
Trim
$(sPartOne)
'
Next 4 Chars
sPartTwo
=
Hex
$(udtGuid.PartTwo)
iStrLen
=
Len
(sPartTwo)
iDataLen
=
Len
(udtGuid.PartTwo)
sPartTwo
=
String
((iDataLen
*
2
)
-
iStrLen,
"
0
"
) _
&
Trim
$(sPartTwo)
'
Next 4 Chars
sPartThree
=
Hex
$(udtGuid.PartThree)
iStrLen
=
Len
(sPartThree)
iDataLen
=
Len
(udtGuid.PartThree)
sPartThree
=
String
((iDataLen
*
2
)
-
iStrLen,
"
0
"
) _
&
Trim
$(sPartThree)
'
Next 2 bytes (4 hex digits)
'
Final 16 chars
For
iCtr
=
0
To
7
sPartFour
=
sPartFour
&
_
Format$(
Hex
$(udtGuid.PartFour(iCtr)),
"
00
"
)
Next
'
To create GUID with "-", change line below to:
'
sAns = sPartOne & "-" & sPartTwo & "-" & sPartThree _
'
& "-" & sPartFour
sAns
=
sPartOne
&
sPartTwo
&
sPartThree
&
sPartFour
End
If
GUID
=
sAns
Exit
Function
errorhandler:
'
return a blank string if there's an error
Exit
Function
End Function
查看全文
相关阅读:
C++各大有名库的介绍——C++标准库
转换中文数字成为阿拉伯数字
nutch 写一个indexingfilter插件
nutch从网页中提取字段并索引_HtmlParseFilter
java csv操作类
简单的有限状态机
getResource()和getResourceAsStream的路径问题
eclipse修改整个工作空间的编码
批处理启动tomcat
java linq
原文地址:https://www.cnblogs.com/todd/p/104550.html
最新文章
又闻桂花香
俞敏洪演讲:不要为眼前的得失而抓狂(一生受用)
转:我的Java学习推荐书目
Java命名惯例的两个特殊情况
明天开题了
NetBeans Platform on standalone Swing applications
关于JxtaMulticastSocket
转:[XUBUNTU] VNC Server
转一个技术博客http://www.antonioshome.net/blog/
世嘉收购MMO游戏《螺旋骑士》开发商Three Rings
热门文章
生成deamon线程的executor
C++各大有名库的介绍——GUI
使用 OpenSSL API 进行安全编程,第 3 部分: 提供安全服务(三)
OpenSSL CSP Engine
OpenSSL对称加密算法中如何添加新算法
C++各大有名库的介绍——准标准库Boost
Linux 上的 PKCS #11 openCryptoki
使用 OpenSSL API 进行安全编程,第 2 部分: 安全握手(二)
OpenSSL生成正确显示中文证书的方法
openssl的man中文文档
Copyright © 2011-2022 走看看