2007年11月1日 星期四

BCB use .rc file


sometime we have to call exetrnal exe file or include multimedia files in BCB, here is a easy method to do it.


make a rc file with ultraedit or text editor.


below is the format:


name format filename


E11 EXEFILE jhead.exe


im1 ICON 000.jpg



char exefile[100], tmppath[100] ;
unsigned long ret ;
//check exist of jhead.exe
GetTempPath( 100, tmppath ) ;
strcpy( exefile ,(AnsiString(tmppath)+
AnsiString("\\jhead.exe") ).c_str() ) ; //under same folder using \\
ret = GetFileAttributes( exefile ) ;
if( ret == 0xffffffff )
{ //not exist, save jhead.exe
TResourceStream &rs = *new TResourceStream( (int)Hinstance, AnsiString("E11"),"EXEFILE" ) ;
rs.SaveToFile( AnsiString(exefile) ) ;
delete &rs ;
}
//run jhead.exe
ShellExecute(Hinstance, "open", exefile, "","", SW_HIDE ) ;




沒有留言: