PowerBuilder生成GUID

pb生成全球唯一编码的方法三种:

方法一:

string of_guid

of_guid = trim(gs_login_user)+string(gf_getdate(),"yyyy-mm-dd hh:mm:ss:ms ")+string(rand(1000))

of_guid = f_guid()

return of_guid

方法二:

编译后脱离开发环境不知道需要哪些dll文件,有人在我的异常网上问过,没解答,所以也放弃

oleObject PBObject

string ls_GUID

long ll_result

PBObject = CREATE oleObject

ll_result = PBObject.ConnectToNewObject &

   ("PowerBuilder.Application")

IF ll_result < 0 THEN

 messagebox("","连接失败:与PowerBuilder.Application连接出错!")

 Destroy PBObject

   return ""

ELSE

   ll_result = PBObject.GenerateGUID(REF ls_GUID)

END IF

Destroy PBObject

return Mid(ls_GUID,2,len(ls_GUID) - 2)

方法三:

需要rpcrt4.lib,需要定义一个结构

unsignedlong    data1

unsignedinteger   data2

unsignedinteger   data3

character              data4[8]

 

pb9生成guid的方法
函数内容:

Constant Long  RPC_S_OK = 0

Constant Long  RPC_S_UUID_LOCAL_ONLY = 1824

Long ll_rtn

uuid u

ll_rtn = uuidcreate(u) //Create a new UUID

IF ll_rtn = RPC_S_OK Or ll_rtn = RPC_S_UUID_LOCAL_ONLY THEN

 Long ll_pointer

 String ls_uuid

 ll_rtn = UuidToString(u,ll_pointer)

 ls_uuid = Upper(String (ll_pointer,"Address")) //Convert it to a string  

 RETURN ls_uuid

ELSE

 RETURN ""

END IF

 

方法二的实操过程:

首先定义一个函数:File/new/Function

然后在function中编写如下内容:

最后 在需要的地方调用时:f_get_guid(1)

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页