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

The tens of thousands of function calls in the Windows environment can be helpful to PowerBuilder users, but documenting them is nearly impossible. After hundreds of user inquiries, Powersoft Technical Support compiled these technical tips to enable PowerBuilder developers to translate standard Microsoft function calls into PowerBuilder syntax, and to empower developers to use any of the external API calls within their owerBuilder environments..

The following information will help you translate and Windows SDK call to a PowerBuilder API function call. It doesn't matter whether you're using PowerBuilder 4.0, 5.0, 6.0, 7.0 or 8.0 but there are important differences between the 16- and 32-bit versions, as we'll discuss below.

Step 1: Converting an SDK Call to a PowerBuilder API Call.

First you need to get the syntax that wil be converted. This can be obtained from either a Windows API Bible or the MSDN (Microsoft Developers Network).

Step 2: Determining Whether it is a Function or a Subroutine.

Function calls return a value; subroutines do not.

Here is an example of a Microsoft function:

BOOL GetFileVersionInfo( LPTSTR lptstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData );

Here is an example of a Microsoft subroutine:

VOID GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer);

Step 3: Converting the datatypes from Microsoft to PowerBuilder. MICROSOFT

PB(16Bit) PB(32Bit) Bool Boolean Boolean Char* Ref string Ref String Colorref Uint Ulong Dword Uint Ulong Handle Uint Ulong Hdc Uint Ulong Hfile Uint Ulong Hinstance Uint Ulong Hwnd Uint Ulong Int Int Int Lparam Uint Ulong Lpbyte Ref Int Ref Long Lpdword Ref Uint Ref Ulong Lpfiletime Ref Time Ref Time Lpint Ref Int Ref Long Lpstr,Lpststr Ref String Ref String Lpvoid Ref Structstruct_inst Ref Struct struct_inst Mcierror Long Long Lpstr,Lpststr Ref String Ref String Lpvoid Ref Structstruct_inst Ref Struct struct_inst Pbyte Ref Int[#] Ref Long[#] Short Int Int Structure Ref Struct struct_inst Ref Struct Struct_inst Uint Uint Uint Void** SUBROUTINE SUBROUTINE Word Int Ulong Wparam Uint Ulong Most of the datatypes are listed above, but some may be missing. When in doubt read the datatype description first. If still unsure, it is usually safe to assume a 16 bit datatype is a "uint" and a 32 bit datatype is a "ulong", since they are the most common. *If the word "Callback appears as a datatype, it cannot be performed by PowerBuilder. Callback routines are functions that are called from within functions. Step 4: Coding the Global/Local External Function:

This is a Microsoft function:

BOOL GetFileVersionInfo( LPTSTR lptstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData );

The BOOL represents a boolean return code, which is translated to "Boolean" in PB for both 16 and 32 bit. A LPCTSTR means a pointer to a string (see step 3). In PowerBuilder, simply use the word "ref" before declaring the string in either 16- or 32-bit platofrms. DWORD is translated to "uint" for 16 bit and "ulong" for 32 bit. An LPVOID indicates that a structure is being used. In PowerBuilder, create a structure, assign it to an instance variable of that structure and pass it by reference. As a result, the following function declarations can be derived:


PowerBuilder 16 bit:

FUNCTION boolean GetFileVersionInfo(ref string filename, uint f_handle, uint f_length, ref lpdata lpdata2) LIBRARY "ver.dll"

PowerBuilder 32 bit:

FUNCTION boolean GetFileVersionInfoA(ref string filename, ulong f_handle, ulong f_length, ref lpdata lpdata2) LIBRARY "version.dll"

Note: In the "gotchas" section listed below, you'll get a further explanation why an "A" is appended to the 32-bit function. You'll also find a handy technique to help you locate function calls within the DLLs.

Step 5: Creating a Structure

In this particular example a structure is needed so you'll need information on what elements are contained within this structure. The MSDN provides this information since the function being called is a Windows function.

In the MSDN the structure appears like this:

LPDATA = { DWORD dwSignature ; DWORD dwStrucVersion ; DWORD dwFileVersionMS ; DWORD dwFileVersionLS ; DWORD dwProductVersionMS ; DWORD dwProductVersionLS ; DWORD dwFileFlagsMask ; DWORD dwFileFlags ; DWORD dwFileOS ; DWORD dwFileType ; DWORD dwFileSubtype ; DWORD dwFileDateMS ; DWORD dwFileDateLS }

In PB you would go into the structure painter

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

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

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