c++ - what is the proper method of using resource files in MFC project? -
c++ - what is the proper method of using resource files in MFC project? -
i have made mfc-based game , project includes images , sounds. want create installer setup in order distribute it.
i have used resources providing exact path in e.g
img->load(l"c:\\users\\ad33l's\\desktop\\block mania\\block mania\\res\\db.png"); mciwndcreate(null, null,ws_popup|mciwndf_noplaybar|mciwndf_nomenu,l"c:\\users\\ad33l's\\desktop\\block mania\\block mania\\res\\tick.wav");
1.can tell me way avoid hard-coding actual resource path these resource files not nowadays @ same exact path in other computers ?
2.also guide me handle these resource files during creation of standalone setup (i using advance installer )
(as actual answer).
do not utilize absolute path, utilize relative path; relative exe file 1 solution.
the exe path can found using getmodulefilename.
char apppath[maxfilenamelen]; getmodulefilename(null, apppath, maxfilenamelen);
(addendum) apppath name misleading, contains total name of application; need extract path total application name.
we this:
(edit create compilable in unicode)
tchar applicationpath[max_path]; getmodulefilename(null, applicationpath, max_path); cstring ssoundfile(applicationpath); pathremovefilespec(ssoundfile.getbuffer()); ssoundfile.releasebuffer();
from there, can (pseudocode-ish):
img.load( apppath + "//images//db.png" );
c++ visual-studio-2012 mfc advanced-installer
Comments
Post a Comment