200分求助 delphi中调用外部FLASH文件(200分)

B

bitd

Unregistered / Unconfirmed
GUEST, unregistred user!
1、 delphi中如何调用外部FLASH文件进行播放,不要用ACTIVEX控件和EXE文件捆绑在一起,这样可执行文件会很大.

2、 有什么办法加密修改这个外部的FLASH文件,使它只能在这个delphi编的程序中运行。

 
在Delphi中播放 Flash




Tip Rating (44):
To make use of SWF files in your Delphi application you should have
the swf plugin installed then follow these steps:

Um SWF-Dateien in einer Delphi-Applikation gebrauchen zu k鰊nen, muss
das SWF-Plugin installiert sein.

{English}

In the Delphi IDE

- click on "Component", "Import ActiveX Control"
- chose "Shockwave Flash" and click on "install".

Now you have a TShockwaveFlash component in your IDE on the ActiveX tabsheet.
Place the TShockwaveFlash Component onto your form, resize it as needed but
for now do not assign a movie to it.

You will need to register the ocx file if it is not installed on the
target computer. So you should have a resource file with

- the swflash.ocx and your Flash ( *.swf) file.

- Copy swflash.ocx (from i.e. windows/system32/macromed/flash) and your
custom swf file to your project path.
- Create a textfile with a code like this:

SHOCKWAVEFILE RCDATA yourfile.swf
SHOCKWAVEOCX RCDATA swflash.ocx

(Where yourfile.swf is your swf-file)

- Save this file as flash.rc
- Goto Commandline, change to your project dir and enter the line:

"Brcc32 -r flash.rc"

- Now you have your new resource as flash.res file


{************************************************************}

uses
ShockwaveFlashObjects_TLB
// will be used automatically

implementation

{$R *.DFM}
{$R flash.res} // your new created resource
{...}

procedure TForm1.FormCreate(Sender: TObject);
var
SystemDir: array[0..MAX_PATH] of Char;
SWFDir, AppDir: string;
Fres: TResourceStream;
Ffile: TFileStream;
begin
GetSystemDirectory(@SystemDir, MAX_PATH);
SWFDir := SystemDir + '/macromed/flash/';
GetDir(0, AppDir)
// Get current directory

//check whether the sw-flash ocx is already installed
if FileExists(SWFDir + 'swflash.ocx') = False then
begin
//create directories if needed and extract file from resource.
{$i-} //compiler directive to suppress i/o error messages
MkDir(SystemDir + '/macromed');
MKDir(SystemDir + '/macromed/flash');
{$i+}
Fres := TResourceStream.Create(0, 'SHOCKWAVEOCX', RT_RCDATA);
Ffile := TFileStream.Create(SWFDir + 'swflash.ocx', fmCreate);
Ffile.CopyFrom(Fres, Fres.Size);
Fres.Free;
Ffile.Free;

//register ocx (simple but useful)
WinExec(PChar('regsvr32 /s ' + SWFDir + 'swflash.ocx'), SW_HIDE);
end;
// extract ShockwaveFile from resource to application directory
Fres := TResourceStream.Create(0, 'SHOCKWAVEFILE', RT_RCDATA);
Ffile := TFileStream.Create('flashmovie.swf', fmCreate);
Ffile.CopyFrom(Fres, Fres.Size);
Fres.Free;
Ffile.Free;

//Assign the extracted swf file to your TShockwaveFlash object
FlashMovie.Movie := AppDir + '/flashmovie.swf';
end;

(*
If you dont want to have the popup menu displayed on right click
you may chose menu property of TShockWave to false.
*)
 
1.不调用activeX肯定播放不了flash的。不知道你说的是不是这个意思
2.你可以把flash文件修改一下后存放,怎么修改随你了,比如把头三个字节改成AAA,文件名不叫.swf,别的程序就放不了了,flash播放器也放不了,你自己的程序播放这个flash时,先把头三个字节改回来,然后,再播放就可以了
3.别忘了给分,呵呵
 
用IE播放
uses shellapi
ShellExecute(0,'open','Explorer','F:/图象/BMP2/[0001].swf',nil,sw_hide);
//
加密的
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2593920
 
谢谢楼上的三位兄弟

xuhao1的代码我去试试
 
不会是用汇编改吧?!:)
 
好像还没有能播放swf的vcl控件,只能用active的
 
to xuhao1: 下面这一段不懂,是用来自定议SWF文件格式的吗?

- Create a textfile with a code like this:

SHOCKWAVEFILE RCDATA yourfile.swf
SHOCKWAVEOCX RCDATA swflash.ocx

(Where yourfile.swf is your swf-file)

- Save this file as flash.rc
- Goto Commandline, change to your project dir and enter the line:

"Brcc32 -r flash.rc"

- Now you have your new resource as flash.res file
 
to coolbaby: 对于你说的第二点,有代码参考吗?万分感谢
 
读出来
var
F:TFileStream;
passBuf:array[0..49]of byte;
I:INTEGER;
begin
memo1.Clear;
if not FileExists(Edit1.Text) then exit;
F:=TFileStream.Create(Edit1.Text,fmOpenRead);
try
F.Seek($42,soFromBeginning);
F.Read(passBuf,50);
finally
F.Free;
end;
for i:=0 to 49 do
memo1.lines.add(VarToStr(inttohex(passBuf,2)));
end;
再写进去的问题
将上面的read改为write,
F:=TFileStream.Create(Edit1.Text,fmOpenwrite)

抄来的。
 
to yangtsehua:你这个是是文本加密吧,我的是FLASH文件
 
学习,听听课
 
目前没有可以使用的vcl控件,但是可用activex控件实现。不过功能有限。
 
- Create a textfile with a code like this:

SHOCKWAVEFILE RCDATA yourfile.swf
SHOCKWAVEOCX RCDATA swflash.ocx

(Where yourfile.swf is your swf-file)

- Save this file as flash.rc
- Goto Commandline, change to your project dir and enter the line:

"Brcc32 -r flash.rc"

- Now you have your new resource as flash.res file

以上信息是建立一个资源文件.存放了控件和Flash文件到资源中.
 
存放了Flash文件到资源中
 
顶部