c++ - what is the proper method of using resource files in MFC project? -


I have created an MFC based game and my project contains images and sounds. Now I have an installer setup to distribute it Want to make

I like my exact path like

  img-> gt; Load (L "C: \\ User \\ Ad33l \\ Desktop \ Block Mania \ Block Frenzy \ \ Res \\ db.png"); MCIWndCreate (NULL, NULL, WS_POPUP | MCIWNDF_NOPLAYBAR | MCIWNDF_NOMENU, L "C: \\ User \\ Ad33l \\ Desktop \ Block Frenzy \\ Block Frenzy \\ res \\ tick.wav");   

1. Can anyone tell me a way to avoid the hard-coding of the actual resource path because these resource files will not exist on this exact exact path in other computers?

2. Guideline to handle these resource files at standalone setup (I am using an advanced installer)

(as a genuine answer).

Do not use the full path, always use the relative path; There is a solution relative to your xi file.

The EXE path can be found by using GetModuleFileName.

  char apppath [MAXFILENAMELEN]; GetModuleFileName (NULL, Eppath, MAXFILENAMELEN);   

(Appendix) The name apple is misleading, it has the full name of the application; You need to remove the path with the full application name

We do something like this:

(edit it to make it compatible in Unicode)

  TCH application [MAX_PATH]; GetModuleFileName (NULL, App Path, MAX_PATH); CString sSoundFile (applicationPath); PathRemoveFileSpec (sSoundFile.GetBuffer ()); SSoundFile.ReleaseBuffer (); From there, you can do something like (pseudocode-ihes):  
  img.Load (appspace + "// images // db. Png ");    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -