Starting from registry -> files are not found (MSW)

sbVB Sergio Barbosa Villas-Boas sbvb at sbvb.com.br
Thu Sep 6 08:41:07 PDT 2007


You're probably loading the files using non-complete file names
(file names based on current directory).
When you run your program from registry, the current directory
is not what you expect, so the program doesn't work.

You can solve this by loading files using complete file names
// example
ifstream myFile("C:/Program Files/mySoftware/someDirectory/file.jpg");

To make things more maintainable, you can store in some registry
the path of everything. Load it to a variable and do the concatenation 
by yourself

wxString myPath  = getFromRegistry(registryName);
// to get a registry value is not exactly like
// this, but you can fix that easily.
// myPath = "C:/Program Files/mySoftware/someDirectory/";
wxString completeFileName = myPath + "file.jpg";
ifstream myFile(completeFileName.c_str());

[]'s

----------------------------------------------------
 +------+  Sergio Barbosa Villas-Boas
/------/|  sbVB at sbVB.com.br
| sbVB |/  http://www.sbVB.com.br
+------+   Skype: sbvbsbvb



Chris wrote:
> Hi,
>
> under MSW my program loads several files (bitmaps and settings files)
> at startup. These live in the same directory as the program itself.
> When I start the program directly (double click the exe), everything
> works fine. Creating a shortcut works fine, too. Using Start->Run,
> works as well.
> But when I put the program into the autorun path in the registry, the
> files are not found.
> Loading the files is done just with the filename and no path part. The
> registry path I use is: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows
> \CurrentVersion\Run.
>
> Any thoughts on how to fix this?
> Regards,
> Chris
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
>
>
>
>
>   





More information about the wx-users mailing list