w> I saved a midi file as a resource in my .exe file
w> and I know it's in there. Now I want to play it
w> with the TMediaPlayer component while my program
w> runs.
well, here is the complete procedure (maybe u do it a bit different)
1) create a resources file for compilation
mymidicollection.rc
put the following line into it:
MyMidiRes MIDI "C:\myfavmidifile.mid"
2) compile it with resources comipler brcc32.exe
> brcc32.exe mymidicollection.rc
it will created compiled resources file mymidicollection.res
3) include mymidicollection.res file into your program by means of {$R
directive:
{$R mymidicollection.res}
4) put the following function in your code
procedure ExtractRes( const ResType, ResName, ExtractedResFileName : String);
var Resur:TResourceStream;
begin
Resur := TResourceStream.Create( hInstance, ResName, pCHAR(ResType) );
try
Resur.SaveToFile(ExtractedResFileName);
finally
Resur.Free;
end;
end;
5) then to extract your resources u can call this command:
ExtractRes( 'MIDI', 'MyMidiRes', 'D:\myfavmidifile.mid');
Note: It is important that 'MIDI', 'MyMidiRes' in your ExtractRes
procedure call be the same u use in your *.rc file
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk