Results 1 to 7 of 7

Thread: Difficulty in reading Network List and login time & logout time from the registry

  1. #1
    Join Date
    Jun 2015
    Posts
    11
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Difficulty in reading Network List and login time & logout time from the registry

    I am doing small application using QT4 which can display the list of the network accessed by the user, for that i have to read Network List key and its values from the registry but i am unable to read its value.I have read other keys using Qsettings , but could not do so for NetworkList available in HKLM and the users logged on onto the system.
    Also I am facing difficulty in reading the last login time and shutdown time of the user.

    Please respond to this.
    Thanks

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Difficulty in reading Network List and login time & logout time from the registry

    I have read other keys using Qsettings , but could not do so for NetworkList available in HKLM
    What have you done, and what is the debugger telling you when you ask for one of these keys? Does you account have the admin authority to read these keys?

    Edit: from QSettings docs:

    On Windows, NativeFormat settings are stored in the following registry paths:

    HKEY_CURRENT_USER\Software\MySoft\Star Runner
    HKEY_CURRENT_USER\Software\MySoft\OrganizationDefa ults
    HKEY_LOCAL_MACHINE\Software\MySoft\Star Runner
    HKEY_LOCAL_MACHINE\Software\MySoft\OrganizationDef aults
    This implies that you cannot access an arbitrary location in the Registry using QSettings, but only one of these four locations ("MySoft" and "StarRunner" are just example names), depending on the user's access rights and whether SystemScope or UserScope is requested.

    Further edit:

    Accessing the Windows Registry Directly

    On Windows, QSettings lets you access settings that have been written with QSettings (or settings in a supported format, e.g., string data) in the system registry. This is done by constructing a QSettings object with a path in the registry and QSettings::NativeFormat.

    For example:

    QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\ Office",
    QSettings::NativeFormat);
    But this implies that you can access arbitrary keys. So I go back to my original question - what is the debugger telling you?
    Last edited by d_stranz; 15th June 2015 at 22:40.

  3. #3
    Join Date
    Jun 2015
    Posts
    11
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Difficulty in reading Network List and login time & logout time from the registry

    Thanks d_stranz for replying .
    Debugger does not give any message, no errors but i do not get any result in the list box or in the line edits. But at the same time for other keys i am getting their details.
    Is it due to acess limitation?
    if so then how to overcome it.
    Also i wanted to get last login time and shutdown time of the user using QT4 and display it on the lineEdits , is there any way of getting it?
    Please response to this.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Difficulty in reading Network List and login time & logout time from the registry

    Is it due to access limitation?
    Possibly. I do not know how QSettings opens the Registry. If it opens and asks for read / write access and the key is restricted by Windows, then it could fail (which makes sense, since the area you are looking at is probably under the control of the network services).

    Did you check QSettings::status() after creating your QSettings instance and after trying to read a setting?

    Also i wanted to get last login time and shutdown time of the user using QT4 and display it on the lineEdits , is there any way of getting it?
    No idea. You might have to dip into the Windows API to do this. Once you have a string, you can convert it to a QString and display it.

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

    dinesh123 (23rd June 2015)

  6. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Difficulty in reading Network List and login time & logout time from the registry

    Network interfaces. QNetworkInterface, no need for Windows specific coding. If you do not wish to use the Qt class then the correct way to do it is the Windows API calls GetInterfaceInfo and/or GetAdaptersInfo (NOT reading the registry which is annoyingly variable across Win versions).

    On Windows the last login time can be had from Windows command line:
    Qt Code:
    1. rem For a local user
    2. C:\> net user dinesh123 | findstr /B /C:"Last logon"
    3. rem or if a domain is involved
    4. C:\> net user dinesh123 /domain | findstr /B /C:"Last logon"
    To copy to clipboard, switch view to plain text mode 
    You could get at this with QProcess (parse the net user command output in C++).
    Last edited by ChrisW67; 20th June 2015 at 03:57.

  7. The following user says thank you to ChrisW67 for this useful post:

    dinesh123 (23rd June 2015)

  8. #6
    Join Date
    Jun 2015
    Posts
    11
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Difficulty in reading Network List and login time & logout time from the registry

    Thanks once again. I have to check QSettings::status().

    Thanks Chris
    I will have to try it on QT4.

  9. #7
    Join Date
    Jun 2015
    Posts
    11
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Difficulty in reading Network List and login time & logout time from the registry

    I think these are the commands on the cmd.exe.
    I tried them in the QT program but they does not work.

Similar Threads

  1. Replies: 3
    Last Post: 20th August 2014, 09:27
  2. QaudioOutput play buffer audio real time disconnect network ?
    By Thành Viên Mới in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2011, 12:20
  3. Best way in Qt to plot curve per real-time reading?
    By Sheng in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2009, 22:33
  4. QSqlDatabase Time out no network to long....
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 10th March 2007, 00:41

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.