⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 o28.htm

📁 C++Builder教学大全
💻 HTM
📖 第 1 页 / 共 2 页
字号:
        成 初 始 化 之 前, 先 调 用 一 幅 画 面 做 为 封 面, 通 常 是1/4 屏 幕 大 小, 显 示 一 下 软 件 的 名     

        称、 作 者、 版 本 等 信 息。 要 用C++ Builder 实 现 这 样 的 功 能, 方 法 很 简 单: ① 自 定 义 一     

        窗 体 类TSplashForm, 将 其 设 置 成" 透 明 窗 口", 即BorderIcons 下 的 所 有 选 项 均 置 成false,BorderStyle=bsNone,FormStyle=fsStayOnTop,Position=poScreenCenter;     

        ② 在TSplashForm 窗 体 上 放 置 一TPanel( 相 当 于 图 形 的 镜 框); ③ 在TPanel 上 放 置 一TImage     

        控 件, 调 入 所 需 要 的 图 形; ④ 对WinMain 函 数 稍 加 修 改, 加 入 如 下 所 示 代 码 即 可。 需 要     

        指 出 的 是, 这 段 代 码 通 过 函 数FindWindow, 搜 索 内 存 中 是 否 有 窗 口 标 题 为"Demo" 应     

        用 程 序 存 在, 若 存 在, 则 退 出 程 序 的 运 行。 该 功 能 可 防 止 程 序 的 再 次 运 行。 在 某 些 场     

        合 这 样 设 计 是 必 须 的。</font> </p>    

      <pre><font color="#000000">

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)



{



    try



    {



        if(FindWindow(NULL,&quot;Demo&quot;)!=0)



        {



            Application- &gt;MessageBox



        (&quot; 程 序 已 经 运 行!&quot;,&quot; 警 告&quot;,MB_ICONSTOP);



            return 0;



        }







        TSplashForm *splash=new TSplashForm(Application);



        splash- &gt;Show();



        splash- &gt;Update();







        Application- &gt;Initialize();



        Application- &gt;CreateForm(__classid(TForm1), &amp;Form1);







        splash- &gt;Close();



        delete splash;







        Application- &gt;Run();



    }



    catch (Exception &amp;exception)



    {



        Application- &gt;ShowException(&amp;exception);



    }



    return 0;



}



</font></pre>   

      <p><font color="#000000">---- <b>六、 如 何 永 久 清 除DBF 中 的 已 被 删 除 的 记     

        录</b> </font> </p>    

      <p><font color="#000000">---- 用table- &gt;Delete() 删 除 的DBF 记 录, 并     

        没 有 真 正 从DBF 数 据 库 中 被 删 除, 而 仅 仅 是 做 上 了 一 个 删 除 标 记。 如 何 实 现 类 似dBase     

        中 的Pack 命 令 的 功 能 呢 ? 请 看 下 面 的 代 码。</font> </p>    

      <pre><font color="#000000">

table- &gt;Close();



for(;;)



try



    {



    		table- &gt;Exclusive=true;



        table- &gt;Open();



        break;



    }



    catch(...)



{



}







if(DbiPackTable(table- &gt;DBHandle,table- &gt;



     Handle,NULL,szDBASE,true)!=DBIERR_NONE)



Application- &gt;MessageBox(&quot; 不 能 删 除 记 录&quot;,



  &quot; 错 误&quot;,



  MB_ICONSTOP);



</font></pre>   

      <p><font color="#000000">---- <b>七、I/O 端 口 读 写 的 实 现</b> </font> </p>    

      <p><font color="#000000">---- 细 心 的 读 者 会 发 现,C++ Builder 不 再 支 持 如inportb()、outportb()     

        一 类I/O 端 口 读 写 指 令 了。 准 确 地 说, 在Windows 环 境 下,Borland C++ 仅 支 持16 位 应     

        用 程 序 的 端 口 操 作, 对32 位 应 用 程 序 的 端 口 操 作 不 再 支 持, 而C++ Builder 开 发 出 来     

        的 程 序 是32 位 的。 我 个 人 以 为, 这 是C++ Builder 设 计 者 的 败 笔。 因 为PC 机 中,I/O 地     

        址 空 间 与 内 存 地 址 空 间 从 来 都 是 各 自 独 立 的。 看 看Delphi, 不 就 通 过Port 数 组 实 现     

        了 对I/O 端 口 的 访 问 了 吗 ? 搞 不 清 楚 为 什 么C++ Builder 就 没 有 提 供 类 似 的 机 制 ?     

        下 面 这 几 个 函 数 是 笔 者 从 网 上 淘 下 来 的, 经 过 验 证, 在Windows95 环 境 下, 的 确 可 实     

        现 对I/O 端 口 的 读 写。 读 者 可 以 借 鉴 使 用。</font> </p>    

      <pre><font color="#000000">

void outportb(unsigned short 



int port, unsigned char value)



{



       // mov edx, *(&amp;port);



       __emit__(0x8b, 0x95, &amp;port);



       // mov al, *(&amp;value);



       __emit__(0x8a, 0x85, &amp;value);



       // out dx, al;



       __emit__(0x66, 0xee);



}







void outportw(unsigned short 



int port, unsigned short int value)



{



       // mov edx, *(&amp;port);



       __emit__(0x8b, 0x95, &amp;port);



       // mov ax, *(&amp;value);



       __emit__(0x66, 0x8b, 0x85, &amp;value);



       // out dx, ax;



       __emit__(0xef);



}







unsigned char inportb(unsigned short int port)



{



       unsigned char value;



       // mov edx, *(&amp;port);



       __emit__(0x8b, 0x95, &amp;port);



       // in al, dx;



       __emit__(0x66, 0xec);



       // mov *(&amp;value), al;



       __emit__(0x88, 0x85, &amp;value);



       return value;



}







unsigned short int inportw(unsigned short int port)



{



       unsigned short int value;



       // mov edx, *(&amp;port);



       __emit__(0x8b, 0x95, &amp;port);



       // in ax, dx



       __emit__(0xed);



       // mov *(&amp;value), ax



       __emit__(0x66, 0x89, 0x85, &amp;value);



       return value;



}



</font></pre>   

      <p><font color="#000000">---- <b>八、 软 件 的 分 发</b> </font> </p>    

      <p><font color="#000000">---- 在Windows 下 开 发 的 应 用 程 序 一 般 都 比 较 庞     

        大, 程 序 的 运 行 往 往 离 不 开 一 大 堆 不 知 名 的 系 统DLL 文 件。 为 了 生 成 能 脱 离C++ Builder     

        环 境、 独 立 运 行 的 应 用 程 序, 读 者 须 对 编 译 器 进 行 一 定 的 设 置。 方 法 是: 置Project/Option/Packages/Run     

        with runtime packages 为Disable, 置Project/Option/Linker/Uses dynamic RTL     

        为Disable, 重 新 编 译 一 遍 程 序, 这 样 生 成 的EXE 文 件 就 可 以 脱 离C++ Builder 环 境 运     

        行 了。 但 如 果 你 的 程 序 中 应 用 了 数 据 库, 仅 有 上 述 的 操 作 是 不 够 的-- 因 为, 你 还 得 安     

        装BDE(Borland Database Engineer)。BDE 的 安 装 比 较 麻 烦, 读 者 最 好 是 用C++ Builder3.0     

        附 带 的InstallShield Express 来 制 作 安 装 盘, 把 应 用 程 序 和BDE 打 包 在 一 起。 如 果     

        找 不 到, 也 可 用Delphi3.0 附 带 的InstallShield Express 来 制 作。InstallShield 的     

        使 用 方 法, 限 于 篇 幅, 不 再 介 绍。 有 条 件 的 读 者 可 上 网 查 到 有 关 资 料。</font> </p>    

     </td>    

  </tr>    

</table>    

<br>    

</body>    

</html>    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -