ses dosyasını exe atma
Forum kuralları
Forum kurallarını okuyup, uyunuz!
Forum kurallarını okuyup, uyunuz!
-
- Üye
- Mesajlar: 99
- Kayıt: 24 Tem 2004 05:13
- Konum: kayseri
- İletişim:
ses dosyasını exe atma
iyi günler kullanmış olduğum ses dosyasın gözükmesini istemiyorum bunu exe nin içine atabilirmiyim yada sıkıştırılarak kullanma özelliğini kapata bilirmiyim
arşivimden :
How to store "EVERYTHING" in your EXE file
By supporting resource files, Delphi gives you a great way to store static file contents like animated cursors, AVI videos, pictures or other nice typa things inside your .EXE files. In the following example, the .AVI video file myavi.avi will be stored inside the .EXE file:
Define a constant to be used to refer to the AVI:
Create a resource file MyRes.RC. In the file, have the following line (you can repeat steps 1 & 2 to add multiple AVI's):
Compile the RC file to a RES with the command:
Include the resulting MyRes.RES file in your project:
Now we're going to add code to access the contained AVI video: put a TAnimate component on the form, and assign it a name (in this example, the AVI is named "AviClip"). Then, in the FormCreate() event, add the following to start playing the clip:
Well.. that's all !
After popular demand, here comes a similar procedure to load a JPEG file from a resource:
See the second parameter of the CreateFromID procedure of the TResourceStream component? It's simply the resource index. You can include more than one jpeg in your executable just by adding a line for each jpeg (with a different index) in the resource script (.RC) file.
And finally, a totally different procedure to play a WAVE file stored as resource:
Another use for this technique can be to use this technique for program loaders like Setup programs, self-patching or self-checking utilities.
Just add the second program to the first one as a RCDATA resource. When the first program is started, it automagically extracts the second program to a temp file and starts it. Here's the code for the magic:
In a DOS Window:
In first.dpr add the following line:
Then, whenever you want to save Second.Exe to file, do the following:
Optionally, you can use CreateProcess instead of WinExec. You can also use the API call GetTempFileName to make sure Second.EXE receives a unique filename in the directory returned by GetTempPath. Also, in the code above, I am presuming that the path returned by GetTempPath ends with a backslash ( \ ) character. You should also check for that.
How to store "EVERYTHING" in your EXE file
By supporting resource files, Delphi gives you a great way to store static file contents like animated cursors, AVI videos, pictures or other nice typa things inside your .EXE files. In the following example, the .AVI video file myavi.avi will be stored inside the .EXE file:
Define a constant to be used to refer to the AVI:
Kod: Tümünü seç
CONST
ID_AVI_FILE = 123; { buraya istediğin numarayı yazabilirsin, 123 olması şart değil.}
Create a resource file MyRes.RC. In the file, have the following line (you can repeat steps 1 & 2 to add multiple AVI's):
Kod: Tümünü seç
IDS_AVI_FILE AVI myavi.avi
Compile the RC file to a RES with the command:
Kod: Tümünü seç
BRC32 -r MyRes.RC
Include the resulting MyRes.RES file in your project:
Kod: Tümünü seç
{$R MyRes.RES}
Now we're going to add code to access the contained AVI video: put a TAnimate component on the form, and assign it a name (in this example, the AVI is named "AviClip"). Then, in the FormCreate() event, add the following to start playing the clip:
Kod: Tümünü seç
WITH AviClip DO BEGIN
ResID := IDS_AVI_FILE; { AVI'yi çağır }
ResHandle := hInstance;
Active := TRUE; { hemen oynat }
END;
Well.. that's all !
After popular demand, here comes a similar procedure to load a JPEG file from a resource:
Kod: Tümünü seç
procedure LoadJPEGfromEXE;
var
MyJPG : TJPEGImage; // JPEG object
ResStream : TResourceStream; // Resource Stream object
begin
try
MyJPG := TJPEGImage.Create;
ResStream := TResourceStream.CreateFromID(HInstance, 1, RT_RCDATA);
MyJPG.LoadFromStream(ResStream); // What!? Yes, that easy!
Canvas.Draw(12,12,MyJPG); // draw it to see if it really worked!
finally
MyJPG.Free;
ResStream.Free;
end;
end;
And finally, a totally different procedure to play a WAVE file stored as resource:
Kod: Tümünü seç
var
FindHandle, ResHandle: THandle;
ResPtr: Pointer;
begin
FindHandle:=FindResource(HInstance, '<Name of your Ressource>', 'WAVE');
if FindHandle<>0 then begin
ResHandle:=LoadResource(HInstance, FindHandle);
if ResHandle<>0 then begin
ResPtr:=LockResource(ResHandle);
if ResPtr<>Nil then
SndPlaySound(PChar(ResPtr), snd_ASync or snd_Memory);
UnlockResource(ResHandle);
end;
FreeResource(FindHandle);
end;
end;
Just add the second program to the first one as a RCDATA resource. When the first program is started, it automagically extracts the second program to a temp file and starts it. Here's the code for the magic:
Kod: Tümünü seç
-----SECOND.RC file listing
SECONDAPPEXE RCDATA "c:\Apps\Second\Second.EXE"
------ EOF
Kod: Tümünü seç
C:\>BRCC32 FIRST.RC
Kod: Tümünü seç
{$R SECOND.RES}
Kod: Tümünü seç
VAR
SecRes : TResourceStream;
pTemp : pchar;
TempPath : string;
BEGIN
SecRes := TResourceStream.Create(hInstance,'SECONDAPPEXE',RT_RCDATA);
pTemp := StrAlloc(MAX_PATH);
GetTempPath(MAX_PATH, pTemp);
TempPath := String(pTemp);
StrDispose(pTemp);
SecRes.SaveToFile(TempPath+'Second.EXE');
SecRes.Free;
WinExec(PChar(TempPath+'Second.EXE'), SW_SHOW);
END;
Gazete manşetleri
* DİKKAT :Lütfen forum kurallarını okuyalım ve uyalım...!
* Warez,crack vs. paylaşımı kesinlikle yasaktır.
Gömülü resmi bir türlü çağıramıyorum...
Hüseyin abinin metodu ile res dosyasının içerisine resmi gömüyorum.Ancak resmi bir türlü image nesnesinde çağıramadım...
Burada örnekte var ama örneğe nasıl uygularım.Resim jpeg formatında..
Yaptığım olay res dosyasını exe'nin bulunduğu yere atıyorum...
Mustafa hocamın arşivinde yer alan sesle ilgili yani res'den resim yüklemek için şöyle denedim..
Benim res uzantılı dosyamın ismi resim.
Ayrıca örnekte loadjpegfromexe diye bir procedure var.Bu procedure exe içerisinden kodla res uzantılı resim dosyasımı oluşturuyor.
Canvas ile çizim olayı yapılıyor.
Bana biraz konu ile ilgili açıklama yaparmısınız..
Res dosyasında gömülü resmi nasıl çağırırım...
Yani ben dosyayı çağırdığımda önce makineye bir yeremi atıyor..
Ordanda ismi ile çağırıyoruz..
Acil yardımınızı bekliyorum.
Burada örnekte var ama örneğe nasıl uygularım.Resim jpeg formatında..
Yaptığım olay res dosyasını exe'nin bulunduğu yere atıyorum...
Mustafa hocamın arşivinde yer alan sesle ilgili yani res'den resim yüklemek için şöyle denedim..
Kod: Tümünü seç
var
FindHandle, ResHandle: THandle;
ResPtr: Pointer;
begin
FindHandle:=FindResource(HInstance, 'resim', 'jpeg');
if FindHandle<>0 then begin
ResHandle:=LoadResource(HInstance, FindHandle);
if ResHandle<>0 then begin
ResPtr:=LockResource(ResHandle);
if ResPtr<>Nil then
UnlockResource(ResHandle);
end;
FreeResource(FindHandle);
end;
end;
Ayrıca örnekte loadjpegfromexe diye bir procedure var.Bu procedure exe içerisinden kodla res uzantılı resim dosyasımı oluşturuyor.
Canvas ile çizim olayı yapılıyor.
Bana biraz konu ile ilgili açıklama yaparmısınız..
Res dosyasında gömülü resmi nasıl çağırırım...
Yani ben dosyayı çağırdığımda önce makineye bir yeremi atıyor..
Ordanda ismi ile çağırıyoruz..
Acil yardımınızı bekliyorum.
Bilginin efendisi olmak için çalışmanın uşağı olmak şarttır...
BALZAC
Bana bir harf öğretenin kulu kölesi olurum..
HZ.ALİ
BALZAC
Bana bir harf öğretenin kulu kölesi olurum..
HZ.ALİ
İnternette gezinirken res dosya içinden resim yükleme ile ilgili aşağıdaki kodu buldum..
Arkadaşlar sanırım jpeg resim bu şekilde yükleniyor.
Ancak kodu çalıştırdığımda resource resim not found(Resource resim bulunamadı) hatası alıyorum.Res dosyasını exe ile aynı yere atıyorum..
Gerçi mustafa abinin örneğine benziyor..
Neden res hatası veriyor..
Kod: Tümünü seç
{$R MyRes.RES}//implemantation altına eklenmelidir..
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
MyRS: TResourceStream;
begin
try
MyRS:=TResourceStream.Create(HInstance, 'resim', RT_RCDATA);
Image1.Picture.LoadFromFile('image001.jpg');
if Image1.Picture.Graphic is TJPEGImage then
TJPEGImage(Image1.Picture.Graphic).LoadFromStream(MyRS);
finally
MyRS.Free;
end;
end;
Ancak kodu çalıştırdığımda resource resim not found(Resource resim bulunamadı) hatası alıyorum.Res dosyasını exe ile aynı yere atıyorum..
Gerçi mustafa abinin örneğine benziyor..
Neden res hatası veriyor..
Bilginin efendisi olmak için çalışmanın uşağı olmak şarttır...
BALZAC
Bana bir harf öğretenin kulu kölesi olurum..
HZ.ALİ
BALZAC
Bana bir harf öğretenin kulu kölesi olurum..
HZ.ALİ
{$R MyRes.RES}//implemantation altına eklenmelidir..
Bu satırı değiştirdinmi Res dosyanın adı bumu?
Kolay Gelsin...
Bu satırı değiştirdinmi Res dosyanın adı bumu?
Kolay Gelsin...
Gazete manşetleri
* DİKKAT :Lütfen forum kurallarını okuyalım ve uyalım...!
* Warez,crack vs. paylaşımı kesinlikle yasaktır.
res dosyası adı
Hüseyin abi res dosyasının adını derlemede oluşturduğumuz(BRCC32 isim.rc/isim.res olarak çıkar) ismi veriyoruz.
Bilginin efendisi olmak için çalışmanın uşağı olmak şarttır...
BALZAC
Bana bir harf öğretenin kulu kölesi olurum..
HZ.ALİ
BALZAC
Bana bir harf öğretenin kulu kölesi olurum..
HZ.ALİ