e股脑电脑教程网
  • 首 页
  • 操作系统
  • 应用软件
  • 下载工具
  • 影音视频
  • 办公软件
  • 媒体制作
  • 网站建设
  • 平面设计
  • 数据库
  • 程序开发
  • 视频教程
编辑推荐: | 文章搜索:
您现在的位置: e股脑 >> 程序开发 >> PowerBuilder教程 >> PB API调用原型 >> 教程正文
 
教程搜索
 
 
相关教程
  • 在PowerBuilder中利用DataStore实现查
  • 什么是“pbcat表?
  • 修改PB6的PBL,使之在PB5中可用
  • 使用日期格式时的一些问题
  • 如何存取二进制大对象(BLOBs)
  • 关于PowerBuilder的补丁包
  • 如果在isql中建立表或者增加表字段或者
  • PB高级开发环境配置
  • 动态设置Win95和NT的缺省打印机
  • PowerBuilder6.0运行环境文件列表
  • PowerBuilder、InfoMaker和HTML DataW
  • PB API调用原型
  • 如何用VC创建可在PB中调用的DLL
  • PB应用技巧——数据窗口自动折行
  • 为PB加入具有布局功能的容器组件
  • PB7.0通用选字段查询窗口的设计
 
 

图文教程


  • Windows抢了谁的饭碗 非主流操作系统To

  • 地球还是火星 平常心看“非主流”

  • 综合运用Office 2007批量制作奖状

  • 没有系统盘如何才能修复受损系统?

  • 巧妙运用Excel中边界的附加功能!
 
 
赞 助 商
 
 
PB API调用原型
  • 来源:e股脑
  • 点击次数:
  • 更新时间:2007-8-9
and in this particular case all of these elements would be converted to ULONG. If one of the elements within the structure was a nested structure or callback routine you would not be able to use this function within PB. In that case the only option would be to create a C DLL that makes the function call and call it from PB.


Step 6: Scripting the Function Call.

Now that you have the function declaration you need to pass it the proper arguments. Taking the function " GetFileVersionInfoA" listed in Step 4 the following script would be needed:

First you'll need to declare the datatypes. Keep in mind the variable names do not have to match the function declaration listed in step 4.

boolean lb_rtn // Return code

string ls_filename // 1st argument - filename

ulong lu_hand // 2nd argument - f_handle

ulong lu_len // 3rd argument - f_length

lpdata lpdata2 // Last argument - assigning an instance of a structure.

Next is the hardest part and that is assigning values to the arguments. This part may require use of the MSDN, API Bible or whatever reference is available that covers the function you are calling. In this particular case the information is contained within the MSDN.

The first argument " ls_filename ", should be set to the path and filename of the target file.

ls_filename = "c:\windows\calc.exe" // The calculator would be a good file to test against.

The second argument "lu_hand" according to the MSDN is ignored. This is probably reserved for a future version of Windows to use. To be safe the argument should be set to null.

setnull(lu_hand)

The third argument "lu_len" contains the size of the buffer that the information will be returned into. It is critical that the buffer size not be too small or the information may overflow into another part of memory causing a GPF or Dr. Watson error. In this particular case since the structure contains 13 elements that are all ulong, the number 256 should be sufficient to contain the information.


lu_len = 256

The last argument "lpdata2" is an instance of the structure "lpdata" and it will be populated by the function call.

The final script will appear as follows:

boolean lb_rtn

string ls_filename

ulong lu_hand, lu_len

lpdata lpdata2

ls_filename = "c:\windows\calc.exe" // The calculator would be a good file to test against.

setnull(lu_hand)

lu_len = 256

lb_rtn = GetFileVersionInfoA(ls_filename, lu_hand, lu_len, lpdata2)

// Viewing the output -------------------------------------------------------------

sle_1.text = string(lpdata2.dwSignature)

sle_2.text = string(lpdata2.dwStrucVersion)

sle_3.text = string(lpdata2.dwFileVersionMS)

sle_4.text = string(lpdata2.dwFileVersionLS)

sle_5.text = string(lpdata2.dwProductVersionMS)

sle_6.text = string(lpdata2.dwProductVersionLS)

sle_7.text = string(lpdata2.dwFileFlagsMask)

sle_8.text = string(lpdata2.dwFileFlags)

sle_9.text = string(lpdata2.dwFileOS)

sle_10.text = string(lpdata2.dwFileType)

sle_11.text = string(lpdata2.dwFileSubtype)

sle_12.text = string(lpdata2.dwFileDateMS)

sle_13.text = string(lpdata2.dwFileDateLS)

Messagebox("Return Code", string(lb_rtn))

// -----------------------------------------------------------------------------------------

Gotcha's to look out for:

1. Make sure the DLL you are referencing is the right bit level. This can sometimes be done by looking at the DLL's properties but most likely you'll need a third party product to determine this. Remember, a 16 bit application cannot make a 32 bit API call and visaversa.

2. Some functions are cap sensitive. "Findwindowa" might fail whereas "FindWindowA" works.

3. All handles in PowerBuilder 16 bit are UINT and 32 bit are ULONG. Using the datatypes INT or LONG may work but if the handle points to an area in high memory the latter two datatypes may not be able to support such a large number.

4. Make sure you have the correct function name. Under 32 bit many of the functions had an "A" (Whcih stands for Ascii) appended to the function name to make it unique from it's 16 bit counterpart. This allows developers to place both 16 bit and 32 bit function calls in the same application and then making the correct function call based on what bit platform the program is being run from. The real re

上一页  1 2 3 4 下一页
  • 上一篇教程: 如何用VC创建可在PB中调用的DLL
  • 下一篇教程: PowerBuilder、InfoMaker和HTML DataWindow的配置文件
  •  

    关于本站 | 广告联系 | 版权声明 | 使用帮助

    Copyright © 2004-2008 www.egunao.com All rights reserved.