How to retrieve path of Firefox user's profile? - Mozilla
This is a discussion on How to retrieve path of Firefox user's profile? - Mozilla ; Hello,
How to retrieve path of Firefox user's profile using Gecko SDK and XPCOM
in C++?
Seems nsIDirectoryServiceProvider can not propose such information. And
it does not work with keys from nsAppDirectoryServiceDefs.h.
With best regards,
Edward Yablonsky....
-
How to retrieve path of Firefox user's profile?
Hello,
How to retrieve path of Firefox user's profile using Gecko SDK and XPCOM
in C++?
Seems nsIDirectoryServiceProvider can not propose such information. And
it does not work with keys from nsAppDirectoryServiceDefs.h.
With best regards,
Edward Yablonsky.
-
Re: How to retrieve path of Firefox user's profile?
Edward Yablonsky пишет:
> Hello,
>
> How to retrieve path of Firefox user's profile using Gecko SDK and XPCOM
> in C++?
> Seems nsIDirectoryServiceProvider can not propose such information. And
> it does not work with keys from nsAppDirectoryServiceDefs.h.
>
> With best regards,
> Edward Yablonsky.
I have found solution. Here it is:
nsCOMPtr serviceManager;
NS_GetServiceManager(getter_AddRefs(serviceManager ));
nsCOMPtr directoryService;
serviceManager->GetServiceByContractID("@mozilla.org/file/directory_service;1",
NS_GET_IID(nsIDirectoryServiceProvider),
getter_AddRefs(directoryService));
nsCOMPtr properties =
do_QueryInterface(directoryService);
nsCOMPtr userMimeTypesFile;
properties->Get("UMimTyp", NS_GET_IID(nsIFile),
getter_AddRefs(userMimeTypesFile));
nsEmbedCString nativePath;
userMimeTypesFile->GetNativePath(nativePath);
With best regards,
Edward Yablonsky.
-
Re: How to retrieve path of Firefox user's profile?
Thanks Edward,
your post solved my question: How do I retrieve components installation
path?
void setLibraryLocation(void)
{
nsCOMPtr sm;
nsresult rv = NS_GetServiceManager(getter_AddRefs(sm));
if(!NS_FAILED(rv))
{
nsCOMPtr dirserv;
sm->GetServiceByContractID("@mozilla.org/file/directory_service;1",
NS_GET_IID(nsIDirectoryService), getter_AddRefs(dirserv));
nsCOMPtr props=do_QueryInterface(dirserv);
nsCOMPtr aPath;
props->Get("ComsD",NS_GET_IID(nsIFile),getter_AddRefs(aPath));
nsEmbedCString libloc;
aPath->GetNativePath(libloc);
#ifdef DO_DEBUG
alert(libloc.get());
#endif
libLocation = (char*)malloc(sizeof(char)*(libloc.Length()+13));
strcpy(libLocation,libloc.get());
char* slashpos=strchr(libLocation,'/');
if(slashpos && strchr(slashpos+1,'/'))
strcat(libLocation,"/");
else
strcat(libLocation,"\\");
strcat(libLocation,"printlib.so");
};
}