views:

48

answers:

1

Hi,

I created a .properties file that contains a few simple key = value pairs. I tried it out from a sample c++ console application, using imported java classes, and I was able to access it, no problem.

Now, I am trying to use it in the same way, from a C++ dll, which is being called by another (unmanaged) c++ project.

For some reason, the file is not being accessed.

Maybe my file location is wrong. Where should I be storing it?

What else might be the issue?

TIA

+1  A: 

As you are mentioning "DLL" i guess, that you are using MS Windows. Finding a file there from a DLL, and independently from the logged on user is a restricted item. The best way is to store the file in a path assembled from the environment variable ALLUSERSPROFILE. This is the only location that is equal to all users and where all users usually have write access. Your applications data should reside in a private subdirectory named like < MyCompany > or < MyApplicationsName >. Type

echo %ALLUSERSPROFILE%

on a windows command line prompt to find out the actual location on a machine.

Store your data in i.e.:

%ALLUSERSPROFILE%\MyApp\

Your dll can then query the location of ALLUSERSPROFILE using getenv:

char *allUsersData = getenv("ALLUSERSPROFILE");
RED SOFT ADAIR
that worked. thanks a lot for your help!:)