|
一个程序里有两个一样的函数
[ZT] Delphi 调用协定 32位的Delphi 中增加了新的参数传递方法,称为fastcall:只要有可能,传递到CPU寄存器的参数能多达三个,使函数调用操作更快。这种快速调用协定(Delphi 3确省方式)可用register 关键字标示。 问题是这种快速调用协定与Windows不兼容,Win32 API 函数必须声明使用stdcall 调用协定。这种协定是Win16 API使用的原始Pascal 调用协定和C语言使用的cdecl 调用协定的混合体。 除非你要调用外部Windows函数或定义Windows 回调函数,否则你没有理由不用新增的快速调用协定。 在后面你会看到使用stdcall 协定的例子,在Delphi帮助文件的Calling conventions 主题下,你能找到有关Delphi调用协定的总结内容。 什么是方法? 如果你使用过Delphi 或读过Delphi 手册,大概已经听说过“方法”这个术语。方法是一种特殊的函数或过程,它与类这一数据类型相对应。在Delphi 中,每处理一个事件,都需要定义一个方法,该方法通常是个过程。不过一般“方法”是指与类相关的函数和过程。 你已经在本章和前几章中看到了几个方法。下面是Delphi 自动添加到窗体源代码中的一个空方法: procedure TForm1.Button1Click(Sender: TObject); begin {here goes your code}end; Forward 声明 当使用一个标识符(任何类型)时,编译器必须已经知道该标识符指的是什么。为此,你通常需要在例程使用之前提供一个完整的声明。然而在某些情况下可能做不到这一点,例如过程A调用过程B,而过程B又调用过程A,那么你写过程代码时,不得不调用编译器尚未看到其声明的例程。 欲声明一个过程或函数,而且只给出它的名字和参数,不列出其实现代码,需要在句尾加forward 关键字: procedure Hello; forward; 在后面应该补上该过程的完整代码,不过该过程代码的位置不影响对它的调用。下面的例子没什么实际意义,看过后你会对上述概念有所认识: procedure DoubleHello; forward; procedure Hello; begin if MessageDlg ('Do you want a double message?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then DoubleHello else ShowMessage ('Hello'); end; procedure DoubleHello; begin Hello; Hello; end; 上述方法可用来写递归调用:即DoubleHello 调用Hello,而Hello也可能调用DoubleHello。当然,必须设置条件终止这个递归,避免栈的溢出。上面的代码可以在例DoubleH 中找到,只是稍有改动。 尽管 forward 过程声明在Delphi中不常见,但是有一个类似的情况却经常出现。当你在一个单元(关于单元的更多内容见下一章)的interface 部分声明一个过程或一个函数时,它被认为是一个forward声明,即使没有forward关键字也一样。实际上你不可能把整个例程的代码放在interface 部分,不过你必须在同一单元中提供所声明例程的实现。 类内部的方法声明也同样是forward声明,当你给窗体或其组件添加事件时, Delphi会自动产生相应的代码。在TForm 类中声明的事件是forward 声明,事件代码放在单元的实现部分。下面摘录的源代码中有一个Button1Click 方法声明: type TForm1 = class(TForm) ListBox1: TListBox; Button1: TButton; procedure Button1Click(Sender: TObject); end; |
|
软件安全杂志团队招募成员
报名,撰稿! |
|
[分享]中秋好礼相送,电子杂志《软件安全》01期
支持,来晚了! |
|
|
|
|
|
|
|
|
|
|
|
如何调用右键菜单,请教高手
VB中应该更方便实现了! |
|
如何调用右键菜单,请教高手
具体例子: (****************************************************************************** * CopyRight (c) By 姚佩云 2004 * All Right Reserved * Email : i_rock_1001@163.com www.jynx.com.cn * Date : * New Develop : 2004-4-8 * Description : * 这是一个禁用、启用网卡的例子,实际上通过shell可以控制整个界面,参考的网上资料 * 需要先引用 Microsoft Shell Controls And Automation(Shell32.dll)对应delphi声明 Shell32_TLB.pas * Export : * GetNetLinkList * ExcNetLinkMenu * 首发大富翁(www.delphibbs.com)blog,转载请保留 ******************************************************************************) unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,Shell32_TLB, StdCtrls, Menus; type TForm1 = class(TForm) Button1: TButton; ComboBox1: TComboBox; Button2: TButton; Button3: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} {++ Routine Description: 取本机所有网络链接列表 Arguments: OUT list - 取得的网络链接列表 Return Value: BOOLEAN - 执行是否成功 --} function GetNetLinkList(var list:TStrings):BOOLEAN; var Shell:TShell; ControlPanel:Folder; Item:FolderItem; i:integer; begin Result:= FALSE; if list = nil then exit; Shell:=TShell.Create(Application); if Shell = nil then exit; ControlPanel:=Shell.NameSpace(ssfCONTROLS); for i:=0 to ControlPanel.items.Count -1 do begin Item:=ControlPanel.items.Item(i); if (Item.Name = '网络和拨号连接') then //如果是英文的windows则Name也需是英文的 begin ControlPanel:=Folder(Item.GetFolder); break; end; end; for i:=0 to ControlPanel.items.count-1 do begin Item:= ControlPanel.items.Item(i); List.Add(Item.Name); end; FreeAndNil(shell); Result:= TRUE; end; {++ Routine Description: 执行 本地网络链接 的菜单命令(包括禁用、启用) Arguments: IN AdapterName - 网络链接名称 IN MenuName - 菜单名称 Return Value: BOOLEAN - 执行是否成功 --} function ExcNetLinkMenu(const AdapterName,MenuName:String):BOOLEAN; var Shell:TShell; ControlPanel:Folder; Item:FolderItem; i,j:integer; Verb:FolderItemVerb; begin Result:= FALSE; Shell:=TShell.Create(Application); if Shell = nil then exit; ControlPanel:=Shell.NameSpace(ssfCONTROLS); for i:=0 to ControlPanel.items.Count -1 do begin Item:=ControlPanel.items.Item(i); if (Item.Name = '网络和拨号连接') then //如果是英文的windows则Name也需是英文的 begin ControlPanel:=Folder(Item.GetFolder); break; end; end; for i:=0 to ControlPanel.items.count-1 do begin Item:=ControlPanel.items.Item(i); if (Item.Name = AdapterName) then //如果是英文的windows则Name也需是英文的 begin for j:=0 to Item.Verbs.Count -1 do begin Verb:=Item.Verbs.Item(j); if (Verb.Name = MenuName) then begin Verb.DoIt ; Result:=TRUE; break; end; end; break; end; end; FreeAndNil(shell); end; procedure TForm1.Button1Click(Sender: TObject); var list:TStrings; begin List:=TStringList.Create ; GetNetLinkList(List); ComboBox1.Items:=List; FreeAndNil(List); end; procedure TForm1.Button2Click(Sender: TObject); begin ExcNetLinkMenu('本地连接 2','启用(&A)'); end; procedure TForm1.Button3Click(Sender: TObject); begin ExcNetLinkMenu('本地连接 2','禁用(&B)'); end; end. |
|
如何调用右键菜单,请教高手
引用 Microsoft Shell Controls And Automation(Shell32.dll) |
|
|
|
[求助]jbe是?
JA rel8 77 cb 高于(CF=0 and ZF=0) 条件转移指令 JAE rel8 73 cb 高于等于(CF=0) JB rel8 72 cb 低于(CF=1) JBE rel8 76 cb 低于等于(CF=1 or ZF=1) JC rel8 72 cb 有进位(CF=1) JCXZ rel8 E3 cb CX=0则跳 JECXZ rel8 E3 cb ECX=0则跳 JE rel8 74 cb 等于(ZF=1) JG rel8 7F cb 大于(ZF=0 and SF=OF) JGE rel8 7D cb 大于等于(SF=OF) JL rel8 7C cb 小于(SF<>OF) JLE rel8 7E cb 小于等于(ZF=1 or SF<>OF) JNA rel8 76 cb 不高于(CF=1 or ZF=1) JNAE rel8 72 cb 不高等于(CF=1) JNB rel8 73 cb 不低于(CF=0) JNBE rel8 77 cb 不低等于(CF=0 and ZF=0) JNC rel8 73 cb 无进位(CF=0) JNE rel8 75 cb 不等于(ZF=0) JNG rel8 7E cb 不大于(ZF=1 or SF<>OF) JNGE rel8 7C cb 不大等于(SF<>OF) JNL rel8 7D cb 不小于(SF=OF) JNLE rel8 7F cb 不小等于(ZF=0 and SF=OF) JNO rel8 71 cb 无溢出(OF=0) JNP rel8 7B cb 非偶数(PF=0) JNS rel8 79 cb 非负数(SF=0) JNZ rel8 75 cb 非零(ZF=0) JO rel8 70 cb 溢出(OF=1) JP rel8 7A cb 偶数(PF=1) JPE rel8 7A cb 偶数(PF=1) JPO rel8 7B cb 奇数(PF=0) JS rel8 78 cb 负数(SF=1) JZ rel8 74 cb 为零(ZF=1) JA rel16/32 0F 87 cw/cd 高于(CF=0 and ZF=0) JAE rel16/32 0F 83 cw/cd 高于等于(CF=0) JB rel16/32 0F 82 cw/cd 低于(CF=1) JBE rel16/32 0F 86 cw/cd 低于等于(CF=1 or ZF=1) JC rel16/32 0F 82 cw/cd 有进位(CF=1) JE rel16/32 0F 84 cw/cd 等于(ZF=1) JZ rel16/32 0F 84 cw/cd 为零(ZF=1) JG rel16/32 0F 8F cw/cd 大于(ZF=0 and SF=OF) |
|
关于CPU主频。。。。
最初由 lemony 发布 楼主问的是不是就一种途径,CPUID谁不知道啊,真是的! |
|
[求助] 请问安装m32v9r完成,是否23.1M吗?
如果你masm安装到了c:\masm32\,程序中定义为: .586 .model flat,stdcall option casemap:none include \masm32\include\windows.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc include \masm32\include\comctl32.inc include \masm32\include\shell32.inc includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib includelib \masm32\lib\comctl32.lib includelib \masm32\lib\shell32.lib 然后建立个bat文件,里面大概内容如下就可以了: @echo off c:\MASM32\BIN\Ml.exe /c /coff xxx.asm c:\MASM32\BIN\Link.exe /SUBSYSTEM:WINDOWS xxx.obj dir %1 pause |
|
关于CPU主频。。。。
[ZT] unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} function GetCpuSpeed: Comp; { function to return the CPU clock speed only.} { Usage: MessageDlg(format('%.1f MHz', [GetCpuSpeed]), mtConfirmation, [mbOk], 0); } var t: DWORD; mhi, mlo, nhi, nlo: DWORD; t0, t1, chi, clo, shr32: Comp; begin shr32 := 65536; shr32 := shr32 * 65536; t := GetTickCount; while t = GetTickCount do begin end; asm DB 0FH DB 031H mov mhi,edx mov mlo,eax end; while GetTickCount < (t + 1000) do begin end; asm DB 0FH DB 031H mov nhi,edx mov nlo,eax end; chi := mhi; if mhi < 0 then chi := chi + shr32; clo := mlo; if mlo < 0 then clo := clo + shr32; t0 := chi * shr32 + clo; chi := nhi; if nhi < 0 then chi := chi + shr32; clo := nlo; if nlo < 0 then clo := clo + shr32; t1 := chi * shr32 + clo; Result := (t1 - t0) / 1E6; end; procedure TForm1.Button1Click(Sender: TObject); begin MessageDlg(format('%.1f MHz', [GetCpuSpeed]),mtConfirmation, [mbOk], 0); end; end. |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值