unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    CheckBox1: TCheckBox;
    procedure CheckBox1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;implementation{$R *.dfm}
VAR
  hProcess1,ID,Gamehwnd1:cardinal;procedure TForm1.checkbox1Click(Sender: TObject);
var
  str1: array[0..11] of byte;
  nsize: cardinal;
begin
  Gamehwnd1:=FindWindow(nil,'Maplestory');
  GetWindowThreadProcessId(Gamehwnd1,ID);
  hProcess1:= OpenProcess(PROCESS_ALL_ACCESS, False, ID);
  If (Gamehwnd1 = 0) Then
  else
  begin
    if checkbox1.Enabled then
    begin
      str1[0] := $BC;
      str1[1] := $5F;
      str1[2] := $BA;
      str1[3] := $E4;
      str1[4] := $FE;
      str1[5] := $D2;
      str1[6] := $25;
      str1[7] := $C7;
      str1[8] := $7B;
      str1[9] := $90;
      str1[10] := $16;
      str1[11] := $52;
      WriteProcessMemory(hProcess1, pinteger($99CD5C),@str1[0],12,nsize);
    end
    else
    begin
      str1[0] := $99;
      str1[1] := $A8;
      str1[2] := $FB;
      str1[3] := $C1;
      str1[4] := $44;
      str1[5] := $DD;
      str1[6] := $F ;
      str1[7] := $CE;
      str1[8] := $8 ;
      str1[9] := $90;
      str1[10] := $EA;
      str1[11] := $71;
      WriteProcessMemory(hProcess1, pinteger($99CD5C),@str1[0],12,nsize);
    end;
  end;
end;
end.这是某游戏的delphi7的source.
里面有writeprocessmemory函数,
我是学vb的 现在想学delphi.
刚看了下这句代码。
有个疑问。。
怎么vb需要在通用那里声明API 而delphi却不用?

解决方案 »

  1.   

    delphi
    uses了Windows
    我也是一知半解
      

  2.   

    WriteProcessMemory 已经在Windows单元里声明过了
      

  3.   

    意思就是说在USES下面加上的 “windows” 就是微软的所有接口?
      

  4.   

    不是所有,是大多数.Delphi 封装的比较好,没VB那么白痴.即使调用未知的API,声明一下即可也很方便
      

  5.   

    大部分API都在Windows单元封装的。
      

  6.   

    那请问如果我使用的是其他API呢?
    windows里面没有的那些.
    那应该怎么声明 在哪声明?
      

  7.   

    随便在哪申明,API基本都是microsoft提供的dll里面的.
    格式:和申明某个dll中的函数,一样,就行了。