用Delphi从内存流中判断图片格式的代码
利用内存流来判断文件的格式,其实判断文件的前几个字节就可以简单的判断这个文件是什么类型的文件。
procedure TFrm.CheckImgType(Sender: TObject);
var //声明变量
MyImage:TMemoryStream; //内存流对象
Buffer:Word;
i:integer;
begin
if OpenDialog1.Execute then //OpenDialog1是一个文件打开对话框
begin
MyImage:=TMemoryStream.Create; //建立内存流对象
try
MyImage.LoadfromFile(OpenDialog1.FileName); //把刚刚用户选择的文件载入到内存流中
MyImage.Position := 0; //移动指针到最开头的位置
if MyImage.Size = 0 then //如果文件大小等于0,那么
begin
ShowMessage('错误');
Exit;
end;
MyImage.ReadBuffer(Buffer,2); //读取文件的前2个字节,放到Buffer里面
if Buffer=$4D42 then //如果前两个字节是以4D42[低位到高位]
begin
ShowMessage('BMP'); //那么这个是BMP格式的文件
end
else if Buffer=$D8FF then //如果前两个字节是以D8FF[低位到高位]
begin
ShowMessage('JPEG'); //........一样 下面不注释了
end
else if Buffer=$4947 then
begin
ShowMess
相关文档:
在群里看到有人发了个别人发给他的
我看了写的比较生动 在这转给大家看看
好的 拾取物体函数写好了 下步是如何将代码注入到游戏进程中执行??
1) 小偷开门
PHND:= OpenProcess (PROCESS_ALL_ACCESS, False, PID);得到游戏窗口句柄获得权限
2)小偷在房间搞个放作案方案的地方
TAdd := VirtualAllocEx(PHND, nil, 4096, ......
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
&n ......
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls, StdCtrls, Buttons;
type
TDemoForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
GetButton: TBitBtn;
CloseButton: TBitBtn;
Bevel1: TBevel;
Label5: TLabel;
......
显示一个GIF动画
procedure ShowGIF( GIFFileName : String );
var TargetFrameName,PostData,Heads,Flags : OleVariant; URL : widestring; begin TargetFrameName := '';{指定Frame的空字符串时,则在当前Frame中打开动画文件} PostData := false;{不发送数据} Heads := '';{Header信息为空} Flags := 0;{Flags设为0} ......