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

📄 mainunit.pas

📁 DELPHI函数包 有很多程序员都需要的函数包
💻 PAS
字号:
unit MainUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Buttons;

type
  TMainForm = class(TForm)
    BAbout: TButton;
    Button2: TButton;
    Button3: TButton;
    bshowdatetime: TButton;
    GetCpuId: TButton;
    GetWindir: TButton;
    GetOSInfo: TButton;
    GetScreen: TButton;
    SpeedButton1: TSpeedButton;
    Button4: TButton;
    Button5: TButton;
    Button10: TButton;
    Button1: TButton;
    Button7: TButton;
    Button13: TButton;
    SpeedButton3: TSpeedButton;
    OpenDialog: TOpenDialog;
    procedure BAboutClick(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure GetCpuIdClick(Sender: TObject);
    procedure bshowdatetimeClick(Sender: TObject);
    procedure GetWindirClick(Sender: TObject);
    procedure GetOSInfoClick(Sender: TObject);
    procedure GetScreenClick(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button10Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure Button14Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;
  S:string;
  
implementation


//function GetScreen(IncludeCur:Boolean;FileName:string):boolean; external 'powerdll.dll';

{$R *.dfm}

procedure TMainForm.BAboutClick(Sender: TObject);
var
  PowerDLLabout:function:pchar;stdcall;
  Handle: THandle;
  begin
try
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @PowerDLLabout := GetProcAddress(Handle,'PowerDllAbout');
  if @PowerDLLabout <> nil then
  ShowMessage(PowerDLLabout);
  //FreeLibrary(Handle);
except end;
end;



procedure TMainForm.Button2Click(Sender: TObject);
Type Tkillprocess=Procedure (Param:PChar);
  var
  killprocess:tkillprocess;
  Handle: THandle;
  begin
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @killprocess := GetProcAddress(Handle,'killprocess');
  if @killprocess <> nil then
  killprocess('QQ');
  //FreeLibrary(Handle);
  end;

procedure TMainForm.Button3Click(Sender: TObject);
  var
  autorun:function(keyvalue:PChar;applicationname:PChar):boolean;
  Handle: THandle;
  begin
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @autorun := GetProcAddress(Handle,'autorun');
  if @autorun <> nil then
  if autorun('abc',PChar(application.exename)) then showmessage('ok')
  else  showmessage('no');
  //freelibrary(handle);
  //if autorun('abc',application.exename) then showmessage('已经成功加入注册表,下次将随WINDOWS的启动而启动!');
end;



procedure TMainForm.GetCpuIdClick(Sender: TObject);
var
  GetCPUID:function:longint;
  Handle: THandle;
begin
try
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  GetCPUID := GetProcAddress(Handle,'GetCPUID');
  if @GetCPUID <> nil then
  ShowMessage(IntToStr(GetCPUID));
  FreeLibrary(Handle);
except end;
end;


procedure TMainForm.bshowdatetimeClick(Sender: TObject);
var
  showdatetime:function:PChar;
  Handle: THandle;
  s:string;
begin
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @showdatetime := GetProcAddress(Handle,'GetDateTime');
  if @showdatetime <> nil then
  s:=showdatetime;
  showmessage(s);
  freelibrary(handle);
end;
  
procedure TMainForm.GetWindirClick(Sender: TObject);
var
  GetWinDir:function:pchar;
  Handle: THandle;
begin
try
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @GetWinDir:= GetProcAddress(Handle,'GetWinDir');
  if @GetWinDir <> nil then
  showmessage(GetWinDir);
  freelibrary(handle);
except  end;
end;

procedure TMainForm.GetOSInfoClick(Sender: TObject);
var
  GetOSInfo:function:PChar;
  Handle: THandle;
begin
try
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @GetOSInfo:= GetProcAddress(Handle,'GetOSInfo');
  if @GetOSInfo<> nil then
  showmessage(GetOSInfo);
  freelibrary(handle);
except end;
end;

procedure TMainForm.GetScreenClick(Sender: TObject);
var
  GetScreen:function(IncludeCur:Boolean;FileName:pchar):Boolean;stdcall;
  Handle: THandle;
begin
try
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @GetScreen:= GetProcAddress(Handle,'GetScreen');
  if @GetScreen<> nil then
  GetScreen(true,'c:\aaa.bmp');
  freelibrary(handle);
  ShowMessage('屏幕图像文件已经保存为:c:\aaa.bmp');
except end;
end;

procedure TMainForm.SpeedButton1Click(Sender: TObject);
var
  ShutDown:function:Boolean;stdcall;
  Handle: THandle;
begin
try
  if MessageDlg('确实要关机吗?',mtconfirmation,[mbyes,mbno],0)=mryes then
  begin
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @ShutDown:= GetProcAddress(Handle,'ShutDown');
  if @ShutDown<> nil then
  ShutDown;
  FreeLibrary(Handle);
  end;
except end;
end;

procedure TMainForm.SpeedButton2Click(Sender: TObject);
var
  LocalIP:function:PChar;stdcall;
  Handle: THandle;
begin
try
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @LocalIP:= GetProcAddress(Handle,'LocalIP');
  if @LocalIP<> nil then
  ShowMessage(LocalIP);
  //freelibrary(handle);
except end;
end;

procedure TMainForm.Button4Click(Sender: TObject);
var
  OpenCDRom:function(B:Byte):Boolean;stdcall;
  Handle: THandle;
begin
try
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @OpenCDRom:= GetProcAddress(Handle,'OpenCDRom');
  if @OpenCDRom<> nil then
  OpenCDRom(1);
  //freelibrary(handle);
except end;
end;

procedure TMainForm.Button5Click(Sender: TObject);
var
  OpenCDRom:function(B:Byte):Boolean;stdcall;
  Handle: THandle;
begin
try
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @OpenCDRom:= GetProcAddress(Handle,'OpenCDRom');
  if @OpenCDRom<> nil then
  OpenCDRom(0);
  //freelibrary(handle);
except end;
end;

procedure TMainForm.Button10Click(Sender: TObject);
var
  GetDiskNumber:function:PChar;Stdcall;
  Handle: THandle;
begin
try
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @GetDiskNumber:=GetProcAddress(Handle,'GetDiskNumber');
  if @GetDiskNumber<> nil then
  showmessage(GetDiskNumber);
  freelibrary(handle);
except end;
end;

procedure TMainForm.Button1Click(Sender: TObject);
var
  LockReg:function(B:Boolean):boolean;stdcall;
  Handle: THandle;
begin
try
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @LockReg:= GetProcAddress(Handle,'LockReg');
  if @LockReg<> nil then
  LockReg(True);
  //freelibrary(handle);
  MessageBox(0,'OK.','',0);
except end;
end;

procedure TMainForm.Button7Click(Sender: TObject);
var
  LockReg:function(B:Boolean):boolean;stdcall;
  Handle: THandle;
begin
try
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @LockReg:= GetProcAddress(Handle,'LockReg');
  if @LockReg<> nil then
  LockReg(False);
  //freelibrary(handle);
  MessageBox(0,'OK.','',0);
except end;
end;

procedure TMainForm.SpeedButton3Click(Sender: TObject);
var
  GetIPAddress:function:PChar;stdcall;
  Handle: THandle;
begin
try
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @GetIPAddress:= GetProcAddress(Handle,'GetIPAddress');
  if @GetIPAddress<> nil then
  ShowMessage(GetIPAddress);
  freelibrary(handle);
except end;
end;

procedure TMainForm.Button14Click(Sender: TObject);
var
  DefautlAll:function:Boolean;stdcall;
  Handle: THandle;
begin
try
  Handle := LoadLibrary('PowerDLL.dll');
  if Handle <> 0 then
  @DefautlAll:= GetProcAddress(Handle,'DefautlAll');
  if @DefautlAll<> nil then
  DefautlAll;
  freelibrary(handle);
except end;
end;

end.

⌨️ 快捷键说明

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