Delpi ile Flash Kullanımı

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
compu-turk
Üye
Mesajlar: 2
Kayıt: 23 Haz 2003 04:02

Delpi ile Flash Kullanımı

Mesaj gönderen compu-turk »

Herkese merhaba,

Ufacık bi sorunum var arkadaşlar, Flash (swf) dosyasını derlenen exe dosyanın içine gizleme olanağı varmı?

yardımlarınız ve ilginiz için şimdiden teşekkürler.
mavsar

Mesaj gönderen mavsar »

Merhaba,

SWFLASH.OCX dosyasını Component --> Import ActiveX yönergesi ile Delphi ye import edin. Böylece flash dosyalarını görüntüleme imkanına kavuşacaksınız.

Notepad de aşağıdaki satırların olduğu bir dosya oluşturun ve FlashOCX.rc gibi bir isimle kaydedin.

Kod: Tümünü seç

Flash RCDATA "SWFLASH.OCX"
Ardından

Kod: Tümünü seç

Brcc32 FlashOCX.rc
şeklinde dos promptundan resource file'ı derleyin. Ardından elde edeceğiniz dosyayı şeklinde include edin.

Kod: Tümünü seç

{$R *.RES}
{$R FLASHOCX.RES}
En son olarak örnek bir proje yolluyorum.

Kod: Tümünü seç

program FlashPlayer;

uses
 Forms, Dialogs, comobj, windows, classes, sysutils,
 uMain in 'uMain.pas' {Form1};

{$R *.RES}
{$R FLASHOCX.RES}

type
 TRegFunc = function : HResult; stdcall;

function WinExecAndWait32( FileName: String; Visibility  : Integer ) :
Cardinal;
var { by Pat Ritchey }
   zAppName     : array[0..512] of char;
   zCurDir      : array[0..255] of char;
   WorkDir      : String;
   StartupInfo  : TStartupInfo;
   ProcessInfo  : TProcessInformation;
begin
   StrPCopy( zAppName, FileName );
   GetDir  ( 0,        WorkDir  );
   StrPCopy( zCurDir,  WorkDir  );

   FillChar( StartupInfo, Sizeof( StartupInfo ), #0 );

   StartupInfo.cb          := Sizeof( StartupInfo );
   StartupInfo.dwFlags     := STARTF_USESHOWWINDOW;
   StartupInfo.wShowWindow := Visibility;

   if ( not CreateProcess( nil,
                           zAppName, { pointer to command line string }
                           nil, { pointer to process security attributes }
                           nil, { pointer to thread security attributes }
                           false, { handle inheritance flag }
                           CREATE_NEW_CONSOLE or { creation flags }
                           NORMAL_PRIORITY_CLASS,
                           nil, { pointer to new environment block }
                           zCurDir, { pointer to current directory name }
                           StartupInfo, { pointer to STARTUPINFO }
                           ProcessInfo ) ) then
   begin
       Result := $FFFFFFFF; { pointer to PROCESS_INF }
       MessageBox( Application.Handle, PChar( SysErrorMessage(
GetLastError ) ), 'Yipes!', 0 );
   end
   else
   begin
       WaitforSingleObject( ProcessInfo.hProcess, INFINITE );
       GetExitCodeProcess ( ProcessInfo.hProcess, Result   );
       CloseHandle        ( ProcessInfo.hProcess           );
       CloseHandle        ( ProcessInfo.hThread            );
   end;
end;

var
 aSystemDirZ : array[0..2047] of Char;
 aShortPath  : array[0..2047] of Char;
 fSystemDir  : String;
 aCommand    : String;
 aHandle     : Cardinal;
 aFunc       : TRegFunc;
 ResStream   : TResourceStream;
 FileStream  : TFileStream;
begin

 GetSystemDirectory ( aSystemDirZ, 2047      );
 fSystemDir := aSystemDirZ;
 Application.Initialize;
 try
 Application.CreateForm(TForm1, Form1);
 except
   On EOleSysError Do
   begin
     ResStream := TResourceStream.Create(0, 'Flash', RT_RCDATA);
       try
         FileStream := TFileStream.Create(fSystemDir+'SWFLASH.OCX',
fmCreate);
         try
           FileStream.CopyFrom(ResStream, 0);
         finally
           FileStream.Free;
         end;
       finally
         ResStream.Free;
       end;

     try
       {Register the OCX File}
       aHandle := LoadLibrary( PChar( fSystemDir+'SWFLASH.OCX' ) );
       if ( aHandle >= 32 ) then
       begin
           aFunc := GetProcAddress( aHandle, 'DllRegisterServer' );
           if ( Assigned( aFunc ) = TRUE ) then
           begin
               GetShortPathName( PChar( fSystemDir+'SWFLASH.OCX' ),
aShortPath, 2047 );
               aCommand := Format( '%s
egsvr32.exe /s %s', [fSystemDir, aShortPath] );
               WinExecAndWait32( aCommand, SW_HIDE );
           end;
           FreeLibrary( aHandle );
       end;

       //Try Creating the Form Again
       try
         Application.CreateForm(TForm1, Form1);
       except
         ShowMessage('Unable to find Macromedia Shockwave Flash.');
       end;

     except
       ShowMessage('Unable to register Macromedia Shockwave Flash.');
     end;
       {End of Registering the OCX File}
   end;
 end;
 Application.Run;
end.
Umarım yardımcı olabilmişimdir.

Mehmet
compu-turk
Üye
Mesajlar: 2
Kayıt: 23 Haz 2003 04:02

swf dosya hakkında

Mesaj gönderen compu-turk »

ilginiz için çok teşekkür ederim, bu şekilde swf dosya çalışıyor fakat benim asıl sorunum, swf dosyayı derlenen exe dosyanın içine gömmek. Bu şekilde exe dosya ile birlikte swf dosyayı da göndermek zorunda kalıyorum. bu konuda bi bilginiz varsa çok makbule geçecek.

teşekkürler, iyi çalışmalar.
mavsar

Mesaj gönderen mavsar »

Merhaba verdiğim örnek projede zaten bahsettiğiniz sonuç bilgisi var. Yapmanız gereken resource file'a SWF dosyanızı ekleyip stream ile dosyayı okumak. İsterseniz aşağıda linkini verdiğim örnek projeyi download edip çalıştırın. Orada işlemler RTF (Rich Text File) için yapılmış sizde onu SWF ye çevirin.

http://www.undu.com/LIBS/LoadRes.zip

Kolay gelsin,

Mehmet
Cevapla