[Qt-interest] copy of windows registry file
navid navid
n_nnavid at yahoo.com
Sun Dec 6 04:34:26 CET 2009
thanks
--- On Sat, 12/5/09, Stephen Jackson <spjackson42 at gmail.com> wrote:
> From: Stephen Jackson <spjackson42 at gmail.com>
> Subject: Re: [Qt-interest] copy of windows registry file
> To: qt-interest at trolltech.com
> Date: Saturday, December 5, 2009, 8:44 AM
> 2009/12/5 navid navid :
> >
> > how can I prepare a copy from windows registry
> file?
> > the following code does not work:
> >
> > [CODE]
> > QSettings _qsetsettings("ORG_NAME", "APP_NAME");
> > ...
> > bool _bres = QFile::copy(_qsetsettings.fileName(),
> _qsname);
> > qDebug()<<"source:
> "<<_qsetsettings.fileName()
> > <<" dest: "<<_qsname
> > <<" Res: "<<_bres;
> > [/CODE]
> >
> >
> > Application output:
> > source:
> "\HKEY_CURRENT_USER\Software\ORG_NAME\APP_NAME" dest:
> "G:/qt/prj/debug/settings.txt" Res: false
> >
>
> QFile::copy won't work because _qsetsettings.fileName() "a
> system
> registry path, not a file path". I don't think there is a
> way to do
> this without copying the individual keys yourself, e.g.
>
> #include <QtGui>
>
> int main()
> {
> QSettings input("ORG_NAME",
> "APP_NAME");
> QSettings output("./foo.ini",
> QSettings::IniFormat);
> QStringList keys = input.allKeys();
>
> foreach( QString key, keys )
> {
> output.setValue(key,
> input.value(key));
> }
>
> return 0;
> }
>
> --
> Cheers,
>
> Stephen Jackson
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
More information about the Qt-interest-old
mailing list