大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> 程序开发 -> Win32 API 使用的特殊情况

Win32 API 使用的特殊情况

时间: 2021-07-31 作者:daque

    我部分觉得,delphi 是现在最佳的 windows 可视化开拓东西。其各类特性令开拓锦上添花。但要想表现出 delphi 真实的内含本能比方开拓控件,实行少许特出的功效,就必需径直挪用 win32 api。win32 api 重要包括在 windows95/98/nt/2k 的体例动静贯穿库中如 kernel32.dll、user32.dll、gdi32.dll、shell32.dll 之类    常常情景下 咱们只有在代码的 uses 局部介入 windows 等单位的证明即可像运用 delphi 内置因变量一律的运用 win32 api 因变量,格外简单。    然而,如许运用有功夫会带来少许预见不到的烦恼。简直如次:妇孺皆知,windows 的本子格外多,仅 win95 就有 win95a,win95b之类,而它们对 win32 api 的实行是有纤细差其余,纵然它们都是win32 平台。有少许 win32 api 因变量在一定的 windows 本子中称呼有些许各别,大概基础即是是不生存的。    如许就带来了题目: delphi 的 windows 等单位是与其时最新的win32 api 总集对应的,delphi 在编写翻译的功夫老是动静贯穿 windows 因变量库(一切的 windows 编写翻译型开拓东西都是如许的)。编写翻译时毫无题目的代码,其可实行文献在一定的 windows 平台上就没辙运用。    因为 windows 的可实行文献加载体制,在 delphi 集成情况中是没辙盯梢如许的潜伏题目的。底下举两个例子:    例一:    win32 api 证明:    function broadcastsystemmessage; external user32       name 'broadcastsystemmessagea';     (来自 delphi 5 enterprise windows.pas :29408)提防,运用这个因变量编写翻译后,步调在 win95 的早期本子中没辙运用(犹如是 win95a)    将因变量证明改为如次后,题目处置:    function broadcastsystemmessage; external user32       name 'broadcastsystemmessage'; //提防这边!!    例二:    win32 api 证明:    function shgetspecialfolderpath; external shell32       name 'shgetspecialfolderpatha'    (来自 delphi 5 enterprise shlobj.pas :3333) 提防,运用这个因变量编写翻译后,步调在 win95 某本子中没辙运用(shell32.dll 本子:4.00.1111),由于这个因变量基础就不生存!!暂时我尚无处置计划    要制止如许的题目的展示,有两个本领:    一:不径直运用 win32 api,找第三方控件(这个本领犹如是空话)    二:动静加在因变量。本领如次:以 win2k 中的 animatewindow 为例(对于 animatewindow 因变量的精细计划,请到 www.csdn.net 文书档案,vb搜索要害字 animatewindow,感动: iprogram)unit xxxx;.....type   fanimatewindow = function(                       const hwnd : hwnd;       //仅对窗口灵验                       const dwtime : dword;    //动画连接功夫,默许200ms                       const dwflags : dword): dword; stdcall;   function animatewindow(const hwnd : hwnd; const dwtime : dword;                       const dwflags : dword): dword;implementationfunction animatewindow(const hwnd : hwnd; const dwtime : dword;                       const dwflags : dword): dword;var   dllhandle : thandle;   animatewindow : fanimatewindow;begin   result := 0;   dllhandle := loadlibrary('user32.dll');   @animatewindow := getprocaddress(dllhandle,'animatewindow');   result := animatewindow(hwnd, dwtime, dwflags);end;.....end.如何样,是有些烦恼吧,很值的。    即使你不想让本人的步调挑三拣四,    即使你不想让本人被称为宝物步调员,呵呵,试一下吧。

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.