如何生成35位的全球唯一的字符窜?

goneswing 2002-07-18 11:16:42
如何生成35位的全球唯一的字符窜?例如“FDF59C28-DD7A-4CB3-B4E384A488FE9F9B”
我想用这样的字符窜作为表的主键,在pb中有这样的函数吗?有类似createuuid()这样的函数吗?
...全文
47 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
jeking 2002-07-18
  • 打赏
  • 举报
回复
全球唯一?
可能吗?

要不全取硬件id来构成,那样不太可能重复。不敢保证,世间事情事事难料
byfq 2002-07-18
  • 打赏
  • 举报
回复
需要这样的主键吗?
flymeng 2002-07-18
  • 打赏
  • 举报
回复
可以先获取机器的网卡号,再获取硬盘号,就能凑的差不多了。
Methodor 2002-07-18
  • 打赏
  • 举报
回复
所谓全球唯一,只是统计概念~
你说的应该是GUID吧~
pb有个产生GUID的工具~
做主键则随意了~
算法很多~
35位你想重复都难~
baby_hhh 2002-07-18
  • 打赏
  • 举报
回复
最简单的就是用当前时间,精确到毫秒!!!
liulee 2002-07-18
  • 打赏
  • 举报
回复
sql server 2k有newid()函数。36位全球唯一编码。
jianghuxing 2002-07-18
  • 打赏
  • 举报
回复
命 _______________(真( )苦) @_@(看) 不懂。


研究。。。。。。。。。。。。。。。。。。。。。。。 研究
chinalht 2002-07-18
  • 打赏
  • 举报
回复
我是用delphi写dll实现的,很简单,编译成dll调用即可,其他的函数是压缩blob用的。可以去掉
library pb_zlib;

uses
zlib,windows,Sysutils, comobj;

{$R *.RES}
//压缩数据返回长度
var
TempBuf:Pointer;
TempLen:Integer;
function Compress(InBuf:Pointer;InBytes:Integer):Integer;stdcall;
begin
if TempLen > 0 then FreeMem( TempBuf, TempLen );
CompressBuf( inbuf, inbytes, TempBuf, TempLen);
Result:=TempLen;
end;
procedure GetCompressData(OutBuf:Pointer);stdcall;
begin
CopyMemory(outbuf,tempbuf, templen);
FreeMem(tempbuf,templen);
TempLen:=0;
end;
function Decompress(inBuf:pointer;inbytes:Integer):Integer;stdcall;
begin
if TempLen > 0 then FreeMem( TempBuf, TempLen );
DecompressBuf(inbuf,inbytes,0,tempbuf,templen);
Result:=templen;
end;
procedure ClearTemp;stdcall;
begin
if TempLen > 0 then FreeMem( TempBuf, TempLen );
end;
//获得GUID
Procedure GetGUID( as_guid:PChar);stdcall;
begin
StrPCopy( as_guid, CreateClassID );
end;
exports
GetGUID,
Compress,
GetCompressData,
Decompress,
ClearTemp;

begin
TempLen:=0;
end.
//
subroutine GetGUID( ref string ls) library "pb_zlib"

ls = spcae( 40 )
GetGUID( ls )
messagebox( '', ls )
人生如梦 2002-07-18
  • 打赏
  • 举报
回复
机器的网卡号,再获取硬盘还有当前时间(精确到微秒)~~`,差不多可以了~~~

1,075

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧