• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: 小 中 大 | 推荐给好友 上一篇 | 下一篇

pb中使用winapi生成唯一的永不重复字符串(UUID)

发布: 2007-7-02 11:08 | 作者: admin | 来源: | 查看: 47次 | 进入软件测试论坛讨论

领测软件测试网
1、定义结构及外部函数

global type uuid from structure ulong  data1 uint  data2 uint  data3 character  data4[8]end type

Function ulong UuidCreate(ref uuid lpUUID) LIBRARY "rpcrt4"Function ulong UuidToString (ref uuid lpUUID, ref long lpUUIDString)  LIBRARY "rpcrt4" Alias for "UuidToStringA"Function ulong RpcStringFree(long lpUUIDString) LIBRARY "rpcrt4"  Alias for "RpcStringFreeA"

2、函数主体

CONSTANT Long  RPC_S_OK = 0CONSTANT Long  RPC_S_UUID_LOCAL_ONLY = 1824

Long ll_rtnuuid ull_rtn = uuidcreate(u)  //Create a new UUIDIF 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

     RpcStringFree(ll_pointer)//Remove the string from the memory     RETURN ls_uuidELSE     RETURN ""END IF

注:发布时候可能需要rpcrt4.dll



附:另外一种生成guid的方法

oleObject PBObjectstring ls_GUIDlong 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 IFDestroy PBObject

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

第二种方法在程序发布时候需要在客户端进行配置:

pbapl80.dllpbaen80.tlbrpcrt4.dll

修改注册表如下

Windows Registry Editor Version 5.00

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PBAPPL.REG;; Registration information for PowerBuilder.Application.8;; All rights reserved.  No portion of this material may be copied in any way; without prior written consent from Powersoft Corporation.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Version independent ProgID entries

[HKEY_CLASSES_ROOT\PowerBuilder.Application]@="PowerBuilder Automation"

[HKEY_CLASSES_ROOT\PowerBuilder.Application\CLSID]@="{88880001-8888-1000-8000-080009AC61A9}"

[HKEY_CLASSES_ROOT\PowerBuilder.Application\CurVer]@="PowerBuilder.Application.8"

[HKEY_CLASSES_ROOT\PowerBuilder.Application\NotInsertable]@=""

; Version specific ProgID entries[HKEY_CLASSES_ROOT\PowerBuilder.Application.8]@="PowerBuilder 8.0 Automation"

[HKEY_CLASSES_ROOT\PowerBuilder.Application.8\CLSID]@="{88880001-8888-1000-8000-080009AC61A9}"

[HKEY_CLASSES_ROOT\PowerBuilder.Application.8\NotInsertable]@=""

; CLSID entries[HKEY_CLASSES_ROOT\CLSID\{88880001-8888-1000-8000-080009AC61A9}]@="PowerBuilder Automation"

[HKEY_CLASSES_ROOT\CLSID\{88880001-8888-1000-8000-080009AC61A9}\InProcServer32]@="d:\\Program Files\ ybase\ hared\\PowerBuilder\\pbvm80.dll""ThreadingModel"="Apartment"

[HKEY_CLASSES_ROOT\CLSID\{88880001-8888-1000-8000-080009AC61A9}\NotInsertable]@=""

[HKEY_CLASSES_ROOT\CLSID\{88880001-8888-1000-8000-080009AC61A9}\ProgID]@="PowerBuilder.Application.8"

[HKEY_CLASSES_ROOT\CLSID\{88880001-8888-1000-8000-080009AC61A9}\Programmable]@=""

[HKEY_CLASSES_ROOT\CLSID\{88880001-8888-1000-8000-080009AC61A9}\TypeLib]@="{88880002-8888-1000-8000-080009AC61A9}"

[HKEY_CLASSES_ROOT\CLSID\{88880001-8888-1000-8000-080009AC61A9}\VersionIndependentProgID]@="PowerBuilder.Application"

; Type library registration entries[HKEY_CLASSES_ROOT\TypeLib\{88880002-8888-1000-8000-080009AC61A9}]

[HKEY_CLASSES_ROOT\TypeLib\{88880002-8888-1000-8000-080009AC61A9}\1.0]@="PowerBuilder Automation Type Library"

[HKEY_CLASSES_ROOT\TypeLib\{88880002-8888-1000-8000-080009AC61A9}\1.0\0]

[HKEY_CLASSES_ROOT\TypeLib\{88880002-8888-1000-8000-080009AC61A9}\1.0\0\Win32]@="d:\\Program Files\ ybase\ hared\\PowerBuilder\\PBAEN80.TLB"

[HKEY_CLASSES_ROOT\TypeLib\{88880002-8888-1000-8000-080009AC61A9}\1.0\9]

[HKEY_CLASSES_ROOT\TypeLib\{88880002-8888-1000-8000-080009AC61A9}\1.0\9\Win32]@="d:\\Program Files\ ybase\ hared\\PowerBuilder\\PBAEN80.TLB"

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:[email protected] 电话:010-51297073

软件测试 | 领测国际 | ISTQB | ISTQB官网 | TMMi | TMMi认证 | 国际软件测试工程师认证 | 领测软件测试网