Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. The Lounge
  4. this program will self-destruct in 5 seconds...
Forum Updated to NodeBB v4.3 + New Features

this program will self-destruct in 5 seconds...

Scheduled Pinned Locked Moved Solved The Lounge
36 Posts 5 Posters 8.8k Views 5 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    ...well, no, not really.

    I have a customer asking for some inconsistent functionality (he's basically saying "can you allow the end user to do X without letting him do X?"). After mind-wrestling with him a bit, we've decided to consider writing a program that allows X, but only for a short time (like 3 days).

    I realize this probably sounds crude and problem-prone, and I don't disagree, but I'm willing to give it a go. I can get current time from NTP; is there a way to embed current time into an executable at the time it's built? I was looking at resource files, but that seems rather indirect for what I'm doing.

    If this sounds crazy, I can scrap this idea and tell the customer he needs to buy some license management software for us.

    J.HilkJ 1 Reply Last reply
    0
    • mzimmersM mzimmers

      ...well, no, not really.

      I have a customer asking for some inconsistent functionality (he's basically saying "can you allow the end user to do X without letting him do X?"). After mind-wrestling with him a bit, we've decided to consider writing a program that allows X, but only for a short time (like 3 days).

      I realize this probably sounds crude and problem-prone, and I don't disagree, but I'm willing to give it a go. I can get current time from NTP; is there a way to embed current time into an executable at the time it's built? I was looking at resource files, but that seems rather indirect for what I'm doing.

      If this sounds crazy, I can scrap this idea and tell the customer he needs to buy some license management software for us.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @mzimmers
      do you wan‘t a time stamp on build—compilation— or when the user first started your program?


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      mzimmersM 1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        @mzimmers
        do you wan‘t a time stamp on build—compilation— or when the user first started your program?

        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        @J.Hilk honestly, this idea is so schlock that I'm happy to go with the timestamp of when the image was built. The first-opened would be nice, but then I'm looking at a more elaborate implementation, and I don't feel like spending a lot of time on something I already think is lame (I much prefer spending a lot of time on something, THEN deciding it's lame).

        J.HilkJ 1 Reply Last reply
        0
        • mzimmersM mzimmers

          @J.Hilk honestly, this idea is so schlock that I'm happy to go with the timestamp of when the image was built. The first-opened would be nice, but then I'm looking at a more elaborate implementation, and I don't feel like spending a lot of time on something I already think is lame (I much prefer spending a lot of time on something, THEN deciding it's lame).

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @mzimmers to be honest,
          so kost easy way, on Windows at leasr, would be using QSettings with native format,

          that creates a regestry entry. If you use a some what cryptic key, you should be set.

          low key, not much effort, presistent even after reinstall


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          1
          • mzimmersM Offline
            mzimmersM Offline
            mzimmers
            wrote on last edited by
            #5

            I forgot to mention, this needs to run on MacOS.

            JonBJ 1 Reply Last reply
            0
            • mzimmersM mzimmers

              I forgot to mention, this needs to run on MacOS.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @mzimmers
              Let me get this right. You want a way to know the datetime when an executable was built, in as simple a way as possible? Approximate will do. We don't want to put a timestamp into the code at build time. So what about just looking at the last-modified time of your actual executable application file at runtime?

              mzimmersM 1 Reply Last reply
              2
              • JonBJ JonB

                @mzimmers
                Let me get this right. You want a way to know the datetime when an executable was built, in as simple a way as possible? Approximate will do. We don't want to put a timestamp into the code at build time. So what about just looking at the last-modified time of your actual executable application file at runtime?

                mzimmersM Offline
                mzimmersM Offline
                mzimmers
                wrote on last edited by
                #7

                @JonB that should work!

                QDateTime QFileInfo::lastModified() const
                

                Thanks.

                JonBJ 1 Reply Last reply
                0
                • mzimmersM mzimmers

                  @JonB that should work!

                  QDateTime QFileInfo::lastModified() const
                  

                  Thanks.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @mzimmers
                  Yes, it's pretty simple if it suffices. I forget which call, but Qt library I think can give you full path to currently running executable for passing to QFileInfo.

                  mzimmersM 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @mzimmers
                    Yes, it's pretty simple if it suffices. I forget which call, but Qt library I think can give you full path to currently running executable for passing to QFileInfo.

                    mzimmersM Offline
                    mzimmersM Offline
                    mzimmers
                    wrote on last edited by mzimmers
                    #9

                    @JonB oh that would be nice...it would save me the trouble of passing argv[0] into the widget, and needing a delegate c'tor and other stuff. I'll look for that, and post it here if/when I find it.

                    EDIT:

                    QString QCoreApplication::applicationFilePath()
                    

                    Let it never be said that Qt does not rock.

                    JonBJ 1 Reply Last reply
                    3
                    • mzimmersM mzimmers

                      @JonB oh that would be nice...it would save me the trouble of passing argv[0] into the widget, and needing a delegate c'tor and other stuff. I'll look for that, and post it here if/when I find it.

                      EDIT:

                      QString QCoreApplication::applicationFilePath()
                      

                      Let it never be said that Qt does not rock.

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #10

                      @mzimmers
                      argv[0] can be changed, does not have to be path. This function tries a bit, be aware of:

                      Warning: On Linux, this function will try to get the path from the /proc file system. If that fails, it assumes that argv[0] contains the absolute file name of the executable. The function also assumes that the current directory has not been changed by the application.

                      May use a native call under Windows, I don't know.

                      1 Reply Last reply
                      0
                      • Chris KawaC Offline
                        Chris KawaC Offline
                        Chris Kawa
                        Lifetime Qt Champion
                        wrote on last edited by Chris Kawa
                        #11

                        I realize that you said you want something low effort, but breaking that "protection" will take whole 2 seconds. A simple touch yourapp will give you 3 more days (or whatever). You might as well show a popup asking to kindly stop using the app after X days and it will be the same level of "security".

                        Sorry to be negative about this but I suggest you either treat this seriously and invest in a real licensing scheme or do nothing. Otherwise it's just silly annoyance and code bloat that achieves nothing.

                        JonBJ 1 Reply Last reply
                        3
                        • Chris KawaC Chris Kawa

                          I realize that you said you want something low effort, but breaking that "protection" will take whole 2 seconds. A simple touch yourapp will give you 3 more days (or whatever). You might as well show a popup asking to kindly stop using the app after X days and it will be the same level of "security".

                          Sorry to be negative about this but I suggest you either treat this seriously and invest in a real licensing scheme or do nothing. Otherwise it's just silly annoyance and code bloat that achieves nothing.

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #12

                          @Chris-Kawa
                          I had no idea the OP had said this was anything about licensing? I thought he was just looking for a quick & dirty method for some unknown purpose.

                          1 Reply Last reply
                          0
                          • Chris KawaC Offline
                            Chris KawaC Offline
                            Chris Kawa
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            @JonB Well, he said

                            If this sounds crazy, I can scrap this idea and tell the customer he needs to buy some license management software for us.

                            so I assumed it's suppose to be a DRM type of thing.

                            JonBJ 1 Reply Last reply
                            0
                            • mzimmersM Offline
                              mzimmersM Offline
                              mzimmers
                              wrote on last edited by mzimmers
                              #14

                              Hi Chris - yeah, you're right. That's why I was hoping for a timestamp that might be built into the app (and not visible through the file system). This whole thing is silly, but the exercise might at least be useful to someone reading this later on.

                              EDIT:
                              Your sentiment is still valid, but this might obviate the specific problem you identified:

                              QDateTime QFileInfo::birthTime() const
                              
                              JonBJ 1 Reply Last reply
                              0
                              • Chris KawaC Chris Kawa

                                @JonB Well, he said

                                If this sounds crazy, I can scrap this idea and tell the customer he needs to buy some license management software for us.

                                so I assumed it's suppose to be a DRM type of thing.

                                JonBJ Offline
                                JonBJ Offline
                                JonB
                                wrote on last edited by JonB
                                #15

                                @Chris-Kawa
                                Ohhhh! I stopped reading when @mzimmers wrote

                                If this sounds crazy, ...

                                Now I notice the thread title... :)

                                @J-Hilk indicated that your build system may allow inserting a datetime into C++ code being compiled, or similar. That would be better than file time, but nothing like @Chris-Kawa 's proper solution.

                                mzimmersM 1 Reply Last reply
                                0
                                • JonBJ JonB

                                  @Chris-Kawa
                                  Ohhhh! I stopped reading when @mzimmers wrote

                                  If this sounds crazy, ...

                                  Now I notice the thread title... :)

                                  @J-Hilk indicated that your build system may allow inserting a datetime into C++ code being compiled, or similar. That would be better than file time, but nothing like @Chris-Kawa 's proper solution.

                                  mzimmersM Offline
                                  mzimmersM Offline
                                  mzimmers
                                  wrote on last edited by
                                  #16

                                  @JonB said in this program will self-destruct in 5 seconds...:

                                  @Chris-Kawa
                                  Ohhhh! I stopped reading when @mzimmers wrote

                                  If this sounds crazy, ...

                                  Probably should have stopped reading when you saw my name!

                                  1 Reply Last reply
                                  0
                                  • Chris KawaC Offline
                                    Chris KawaC Offline
                                    Chris Kawa
                                    Lifetime Qt Champion
                                    wrote on last edited by Chris Kawa
                                    #17

                                    @mzimmers You can heave a timestamp no problem. There are __DATE__ and __TIME__ macros in C++ that will expand to current date/time at compilation moment, but it's useless for this purpose unless you plan to compile a separate executable for each customer right before he starts to use it.

                                    Just go the whole mile and invest in a licensing app/lib that does encryption, passwords, trials and all the shabang. No need to reinvent the wheel. It won't be that round anyway ;)

                                    1 Reply Last reply
                                    5
                                    • mzimmersM Offline
                                      mzimmersM Offline
                                      mzimmers
                                      wrote on last edited by
                                      #18

                                      So, as long as we're on the subject...can anyone recommend a lightweight license manager?

                                      JonBJ kshegunovK 2 Replies Last reply
                                      0
                                      • mzimmersM mzimmers

                                        Hi Chris - yeah, you're right. That's why I was hoping for a timestamp that might be built into the app (and not visible through the file system). This whole thing is silly, but the exercise might at least be useful to someone reading this later on.

                                        EDIT:
                                        Your sentiment is still valid, but this might obviate the specific problem you identified:

                                        QDateTime QFileInfo::birthTime() const
                                        
                                        JonBJ Offline
                                        JonBJ Offline
                                        JonB
                                        wrote on last edited by
                                        #19

                                        @mzimmers
                                        A file's "birth" (creation) time can be altered just as its last modified time can. Any attribute of the file will not be robust. The compiled-in way is better.

                                        1 Reply Last reply
                                        0
                                        • mzimmersM mzimmers

                                          So, as long as we're on the subject...can anyone recommend a lightweight license manager?

                                          JonBJ Offline
                                          JonBJ Offline
                                          JonB
                                          wrote on last edited by
                                          #20

                                          @mzimmers
                                          Just one thing: do you have 100 potential sites/users or 1?

                                          And the second one thing: is your application in a server environment?

                                          mzimmersM 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved