Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to play an AVI file from a resource DLL Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
Multimedia
Language
Delphi 5.x
Views
151
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I have an AVI as a resource that I want to play using TAnimate. In a standalone 
executable this works fine, but fails with a "Cannot Open AVI." error message. 
According to MSDN I should set the TAnimate ResHand to the instance handle of the 
DLL. How do I find this?

Answer:

It appears that trying to load an AVI from a resource causes an exception on the 
first attempt, so I gave it another go and it worked. Here's the code:


1   procedure TSplash.ShowSplash;
2   var
3     ResHandle: Integer;
4   begin
5     try
6       ResHandle := LoadAviAsResource(Animate1, 'MyDll.dll', 'SPLASHAVI');
7       { causes exception }
8     except
9       ResHandle := LoadAviAsResource(Animate1, 'MyDll.dll', 'SPLASHAVI');
10      { this time it works }
11    end;
12    if ResHandle > 0 then
13    begin
14      Animate1.Visible := True;
15      Animate1.Repetitions := -1;
16      Animate1.Active := True
17    end
18    else
19    begin
20      Animate1.Visible := False;
21      Animate1.Active := False;
22      { Show a static bitmap or something if AVI cannot be displayed }
23    end;
24    Show;
25  end;
26  
27  function TSplash.LoadAviAsResource(const AviName: TObject; DllName,
28    ResourceName: string): Integer;
29  var
30    ResourceHandle: THandle;
31  begin
32    ResourceHandle := LoadLibrary(Pchar(DllName));
33    TAnimate(AviName).ResName := ResourceName;
34    TAnimate(AviName).ResHandle := ResourceHandle;
35    FreeLibrary(ResourceHandle);
36    result := ResourceHandle;
37  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC