Results 1 to 9 of 9

Thread: need of some help

  1. #1
    Join Date
    Nov 2008
    Posts
    9
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Post need of some help

    Hi.

    I am new to the Qt environment,developing an application in Qt 4.4 under windows platform.i need my application to run everytime when my system starts or reboots.for this we have to keep the application files(.exe or .ini ) into the windows registry.can i have some code snippets for this application?

    Thanks & Regards,
    Srikanth

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: need of some help

    an i have some code snippets for this application?
    snippets of code of doing what?
    We can't solve your problem for you, but we can try and help you with specific problems.
    If you say what it is you tried and it didn't work for you, we might be able to help you with that.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Nov 2008
    Posts
    9
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: need of some help

    Hello,

    My application should run automatically whenever i started my system.For that,we can use Qsettings class and writeEntry() methods to load my application exe file into the windows registry.my code is as follows:


    QSettings settings;
    settings.writeEntry("HKEY_LOCAL_MACHINE\Software\M icrosoft\Windows\CurrentVersion\Run","Notepad");
    settings.writeEntry("HKEY_LOCAL_MACHINE\Software\M icrosoft\Windows\CurrentVersion\Run\notepad.exe",t rue);



    But it is not working.thats why i need some code...

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: need of some help

    the code you posted is registering notepad.exe.
    Is your application named notepad.exe?
    If it is, I would strongly suggest to use a different name, since windows has its own notepad program.
    Don't forget that the path to the application needs to be correct as well.

    Any way, an easy way of doing this is to add you application to the start menu under "autostart".
    Would that be an acceptable solution for you?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. The following user says thank you to high_flyer for this useful post:

    srikanthch (28th November 2008)

  6. #5
    Join Date
    Nov 2008
    Posts
    9
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: need of some help

    Thanks for you information,which helped me...
    I gave that name for examplet for better understanding.i need to register my application by executing some code in Qt only.So,i am in need of help for that code only.

  7. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: need of some help

    maybe if you show your real code we might help you better see where the error is.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  8. The following user says thank you to high_flyer for this useful post:

    srikanthch (28th November 2008)

  9. #7
    Join Date
    Nov 2008
    Posts
    9
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: need of some help

    My code is as follows :

    1)

    #include<QSettings.h>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QSettings settings;
    settings.writeEntry ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows \\CurrentVersion\\Run","C:\Windows\Notepad");
    settings.writeEntry("HKEY_LOCAL_MACHINE\\Software\ \Microsoft\\Windows\\CurrentVersion\\Run\\notepad. exe",true);

    re12 w;
    w.show();
    return a.exec();
    }


    2)



    #include<Qsettings.h>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QSettings settings;
    settings.setPath("HKEY_LOCAL_MACHINE\Software\Micr osoft","\Windows\CurrentVersion\Run\notepad", QSettings::User);
    settings.writeEntry("C:\Windows\Notepad.exe", true);
    reg13 w;
    w.show();
    return a.exec();
    }



    The above are two types of codes,executing without any errors but the key is not created in the registry editor...

    Thanks..

  10. #8
    Join Date
    Nov 2008
    Posts
    9
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: need of some help

    Hi

    Whts wrong with this code :::

    #include<Qsettings>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QSettings My_settings;
    My_settings.insertSearchPath( QSettings::Windows, "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Cur rentVersion\Run" );



    /*THIS IS ONE WAY OF REGISTERING THE KEY INTO REGISTRY EDITOR */

    My_settings.writeEntry("\Notepad","C:\Windows\Note pad.exe");
    My_settings.writeEntry("HKEY_LOCAL_MACHINE\Softwar e\Microsoft\Windows\CurrentVersion\Run\notepad",tr ue);


    /*THIS IS ANOTHER WAY OF REGISTERING THE KEY INTO REGISTRY EDITOR */

    /* My_settings.setPath("Microsoft", "Windows", QSettings::User);
    My_settings.writeEntry("/CurrentVersion/Run/notepad.exe", true);*/


    reg w;
    w.show();
    return a.exec();
    }

  11. #9
    Join Date
    Nov 2008
    Posts
    9
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Talking Re: Got the solution

    Hi Guys,

    I got the solution for my task.the code is as follows:



    #include<Qsettings>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QSettings My_settings;
    //Defining My_settings under QSettings Class
    My_settings.setPath("Microsoft", "Windows", QSettings::Global);
    //Searching the required path
    My_settings.writeEntry("\CurrentVersion\Run\Notepa d","C:\\WINDOWS\\NOTEPAD.EXE");
    //Entering the key into the path

    reg w;
    w.show();
    return a.exec();
    }

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.