Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to get "native window" ?

how to get "native window" ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
18 Posts 5 Posters 108 Views 1 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.
  • L Lost User

    Voluntarily removed- violates "Posting guidelines "

    J Offline
    J Offline
    jschell
    wrote on last edited by
    #8

    Salvatore Terress wrote:

    Apparently there are at least two ways to accomplish that.

    All languages, C++ or anything else, for an external app has the following communication paths. - Start Up - Command line parameters. - Running. Exit code. Which is an int value and nothing else. - Running. Stdio: stderr, stdin, stdout. Using the above I have implemented the following in the past - One computer connecting to multiple hardware devices. - Error output collected. - Logging collected. - Commands controlling each device. - Binary data sent to and from each device. An application might provide another API. But that has nothing to do with running it from the first application. And for most standard 'OS Command line' commands it will not apply. As a specific example you can start and stop IIS using command line commands. But you are definitely not going to be accessing web sites from it using exactly the same commands (if at all using a OS command.) Using a command line app and controlling it requires that one understand exactly what the app does. And that has nothing to do with the controller code from the calling app. Using a OS shell is going to make the above MUCH harder. That is because the shell must then redirect all output from any commands it runs back along the stdio path (in and out.) Getting the shell to do that has nothing to do with the calling application. One will need to figure that out by looking for command line parameter to the shell itself. Although I suspect that that it is possible to do this, at the very least I know it is difficult.

    L 1 Reply Last reply
    0
    • J jschell

      Salvatore Terress wrote:

      Apparently there are at least two ways to accomplish that.

      All languages, C++ or anything else, for an external app has the following communication paths. - Start Up - Command line parameters. - Running. Exit code. Which is an int value and nothing else. - Running. Stdio: stderr, stdin, stdout. Using the above I have implemented the following in the past - One computer connecting to multiple hardware devices. - Error output collected. - Logging collected. - Commands controlling each device. - Binary data sent to and from each device. An application might provide another API. But that has nothing to do with running it from the first application. And for most standard 'OS Command line' commands it will not apply. As a specific example you can start and stop IIS using command line commands. But you are definitely not going to be accessing web sites from it using exactly the same commands (if at all using a OS command.) Using a command line app and controlling it requires that one understand exactly what the app does. And that has nothing to do with the controller code from the calling app. Using a OS shell is going to make the above MUCH harder. That is because the shell must then redirect all output from any commands it runs back along the stdio path (in and out.) Getting the shell to do that has nothing to do with the calling application. One will need to figure that out by looking for command line parameter to the shell itself. Although I suspect that that it is possible to do this, at the very least I know it is difficult.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #9

      Thanks for all the replies. I have been thru this before and had to fix some other part of the project. Again , RTFM is little misreading...but that is not my concern. I may have said this before when my command is "hcitool dev" I get expected response (stdio)- non issue. To be able to do "hcitool info (address)" I need to have "sudo" access... Such access has NOTHING to do with Linux security. and that is when I need interactive repose and that is when SAME "shell" does not work. I'll to modify "sudo" configuration, but not sure if "hcitool info" will work.

      L D 2 Replies Last reply
      0
      • L Lost User

        Thanks for all the replies. I have been thru this before and had to fix some other part of the project. Again , RTFM is little misreading...but that is not my concern. I may have said this before when my command is "hcitool dev" I get expected response (stdio)- non issue. To be able to do "hcitool info (address)" I need to have "sudo" access... Such access has NOTHING to do with Linux security. and that is when I need interactive repose and that is when SAME "shell" does not work. I'll to modify "sudo" configuration, but not sure if "hcitool info" will work.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #10

        Salvatore Terress wrote:

        I need to have "sudo" access... Such access has NOTHING to do with Linux security.

        Yes, it has everything to do with Linux security, as clearly explained in the man page: https://linux.die.net/man/8/sudo[^]. And although I have not tried this myself, I strongly suspect that you cannot use it in the way you are trying to do. If you want elevated/admin permissions then you most likely need to call sudo before you start the original application. And this question has nothing to do with C/C++; please use the correct forums for your questions.

        1 Reply Last reply
        0
        • L Lost User

          Thanks for all the replies. I have been thru this before and had to fix some other part of the project. Again , RTFM is little misreading...but that is not my concern. I may have said this before when my command is "hcitool dev" I get expected response (stdio)- non issue. To be able to do "hcitool info (address)" I need to have "sudo" access... Such access has NOTHING to do with Linux security. and that is when I need interactive repose and that is when SAME "shell" does not work. I'll to modify "sudo" configuration, but not sure if "hcitool info" will work.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #11

          In today's O/S security systems, there is usually a wall between normal user processes and admin-level processes. You cannot access the streams of an admin process from a normal user process. Think about it for just 5 seconds and you'll see why this is a security risk and is now not allowed.

          Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak

          L 1 Reply Last reply
          0
          • D Dave Kreskowiak

            In today's O/S security systems, there is usually a wall between normal user processes and admin-level processes. You cannot access the streams of an admin process from a normal user process. Think about it for just 5 seconds and you'll see why this is a security risk and is now not allowed.

            Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #12

            Thank your very much for all these "security comments" they are very helpful in resolving the issue. Appreciate that very much.

            L 1 Reply Last reply
            0
            • L Lost User

              Thank your very much for all these "security comments" they are very helpful in resolving the issue. Appreciate that very much.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #13

              ADDENDUM This is a request for C/C++ code... This is specific application I am asking for assistance with actual code. I am still asking for assistance in actual C/C++ code to implement system ("sudo hcitool cc --role=c 98:D3:31:F8:29:33"); hcitool cc command require root / sudo , period. hence I need to enter password WITHOUT running "terminal" which "sudo -S" option should provide. I DO NOT KNOW HOW TO ENTER PASSWORD in code USING stdin... I need help with that - I need actual C/C++ code it won't work if I run "sudo su" prior to executing my application after connection is established the code no longer needs to run as "su", it is of non issue . I am trying a solve different task, plain (Linux ) command, and having difficulty implementing the "sudo" bypass. In an essence, I should be able to "enter" password using a sudo command options -S and -ps It is unclear , to me , how to actually code it. I have this code :

              system ("sudo -S su -ps q/n" );

              system ("sudo hcitool cc --role=c 98:D3:31:F8:29:33");

              and this output

              [sudo] password for nov25-1:
              sudo: no password was provided
              sudo: a password is required
              sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
              sudo: a password is required

              K L 2 Replies Last reply
              0
              • L Lost User

                ADDENDUM This is a request for C/C++ code... This is specific application I am asking for assistance with actual code. I am still asking for assistance in actual C/C++ code to implement system ("sudo hcitool cc --role=c 98:D3:31:F8:29:33"); hcitool cc command require root / sudo , period. hence I need to enter password WITHOUT running "terminal" which "sudo -S" option should provide. I DO NOT KNOW HOW TO ENTER PASSWORD in code USING stdin... I need help with that - I need actual C/C++ code it won't work if I run "sudo su" prior to executing my application after connection is established the code no longer needs to run as "su", it is of non issue . I am trying a solve different task, plain (Linux ) command, and having difficulty implementing the "sudo" bypass. In an essence, I should be able to "enter" password using a sudo command options -S and -ps It is unclear , to me , how to actually code it. I have this code :

                system ("sudo -S su -ps q/n" );

                system ("sudo hcitool cc --role=c 98:D3:31:F8:29:33");

                and this output

                [sudo] password for nov25-1:
                sudo: no password was provided
                sudo: a password is required
                sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
                sudo: a password is required

                K Offline
                K Offline
                k5054
                wrote on last edited by
                #14

                I'm sure've been over this before:

                $ id
                uid=1002(k5054) gid=1002(k5054) groups=1002(k5054),27(sudo),100(users)

                create a new group for bluetooth users, call it btusers

                $ sudo groupadd btusers

                add user k5054 to the btusers group

                $ sudo usermod -a -G btusers k5054

                edit /etc/sudoers.d/btusers to allow any user in btusers group

                to run hcitool without a password:

                $ sudo visudo /etc/sudoers.d/btusers
                add line %btusers ALL=(ALL) NOPASSWD:/usr/bin/hcitool

                log out and log back in again ...

                $ sudo ps
                [sudo] password for k5054: (CTL-D)
                sudo: no password was provided
                sudo: a password is required

                We're now part of the btusers group, so we don't need a password for hcitool

                id

                uid=1002(k5054) gid=1002(k5054) groups=1002(k5054),27(sudo),100(users),1003(btusers)

                sudo hcitool without needing a password

                $ sudo hcitool dev
                Devices:

                If you need to be able to run other commands you can append them as a comma separated items to the sudoers file e.g.

                %btusers ALL=(ALL) NOPASSWD:/usr/bin/hcitool,/usr/bin/hcidump

                With knowledge comes great power. Use it wisely. But this should really be int the linux programming forum, or maybe System Admin.

                "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

                L J 2 Replies Last reply
                0
                • L Lost User

                  ADDENDUM This is a request for C/C++ code... This is specific application I am asking for assistance with actual code. I am still asking for assistance in actual C/C++ code to implement system ("sudo hcitool cc --role=c 98:D3:31:F8:29:33"); hcitool cc command require root / sudo , period. hence I need to enter password WITHOUT running "terminal" which "sudo -S" option should provide. I DO NOT KNOW HOW TO ENTER PASSWORD in code USING stdin... I need help with that - I need actual C/C++ code it won't work if I run "sudo su" prior to executing my application after connection is established the code no longer needs to run as "su", it is of non issue . I am trying a solve different task, plain (Linux ) command, and having difficulty implementing the "sudo" bypass. In an essence, I should be able to "enter" password using a sudo command options -S and -ps It is unclear , to me , how to actually code it. I have this code :

                  system ("sudo -S su -ps q/n" );

                  system ("sudo hcitool cc --role=c 98:D3:31:F8:29:33");

                  and this output

                  [sudo] password for nov25-1:
                  sudo: no password was provided
                  sudo: a password is required
                  sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
                  sudo: a password is required

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #15

                  As we lkeep telling you, you cannot call sudo from within the program. Whether you use QProcess or system makes no difference, as neither will do what you want. You must call sudo at the actual terminal before you run your application.

                  1 Reply Last reply
                  0
                  • K k5054

                    I'm sure've been over this before:

                    $ id
                    uid=1002(k5054) gid=1002(k5054) groups=1002(k5054),27(sudo),100(users)

                    create a new group for bluetooth users, call it btusers

                    $ sudo groupadd btusers

                    add user k5054 to the btusers group

                    $ sudo usermod -a -G btusers k5054

                    edit /etc/sudoers.d/btusers to allow any user in btusers group

                    to run hcitool without a password:

                    $ sudo visudo /etc/sudoers.d/btusers
                    add line %btusers ALL=(ALL) NOPASSWD:/usr/bin/hcitool

                    log out and log back in again ...

                    $ sudo ps
                    [sudo] password for k5054: (CTL-D)
                    sudo: no password was provided
                    sudo: a password is required

                    We're now part of the btusers group, so we don't need a password for hcitool

                    id

                    uid=1002(k5054) gid=1002(k5054) groups=1002(k5054),27(sudo),100(users),1003(btusers)

                    sudo hcitool without needing a password

                    $ sudo hcitool dev
                    Devices:

                    If you need to be able to run other commands you can append them as a comma separated items to the sudoers file e.g.

                    %btusers ALL=(ALL) NOPASSWD:/usr/bin/hcitool,/usr/bin/hcidump

                    With knowledge comes great power. Use it wisely. But this should really be int the linux programming forum, or maybe System Admin.

                    "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #16

                    per sudo man I am trying to implement this as C++ command: -S, --stdin Write the prompt to the standard error and read the password from the standard input instead of using the terminal device. system (" sudo -S "); what am I missing ?

                    L 1 Reply Last reply
                    0
                    • K k5054

                      I'm sure've been over this before:

                      $ id
                      uid=1002(k5054) gid=1002(k5054) groups=1002(k5054),27(sudo),100(users)

                      create a new group for bluetooth users, call it btusers

                      $ sudo groupadd btusers

                      add user k5054 to the btusers group

                      $ sudo usermod -a -G btusers k5054

                      edit /etc/sudoers.d/btusers to allow any user in btusers group

                      to run hcitool without a password:

                      $ sudo visudo /etc/sudoers.d/btusers
                      add line %btusers ALL=(ALL) NOPASSWD:/usr/bin/hcitool

                      log out and log back in again ...

                      $ sudo ps
                      [sudo] password for k5054: (CTL-D)
                      sudo: no password was provided
                      sudo: a password is required

                      We're now part of the btusers group, so we don't need a password for hcitool

                      id

                      uid=1002(k5054) gid=1002(k5054) groups=1002(k5054),27(sudo),100(users),1003(btusers)

                      sudo hcitool without needing a password

                      $ sudo hcitool dev
                      Devices:

                      If you need to be able to run other commands you can append them as a comma separated items to the sudoers file e.g.

                      %btusers ALL=(ALL) NOPASSWD:/usr/bin/hcitool,/usr/bin/hcidump

                      With knowledge comes great power. Use it wisely. But this should really be int the linux programming forum, or maybe System Admin.

                      "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

                      J Offline
                      J Offline
                      jschell
                      wrote on last edited by
                      #17

                      k5054 wrote:

                      I'm sure've been over this before:

                      To me it is the same as the question that was posted a while ago. One of my posts in this thread has a link to my post in that previous post.

                      1 Reply Last reply
                      0
                      • L Lost User

                        per sudo man I am trying to implement this as C++ command: -S, --stdin Write the prompt to the standard error and read the password from the standard input instead of using the terminal device. system (" sudo -S "); what am I missing ?

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #18

                        Salvatore Terress wrote:

                        what am I missing ?

                        It makes no difference how you run that command string, it will never work. If that command succeeds then the generated shell that runs the sudo command will be elevated to (possibly root) status. It will then terminate and return to your application which runs at non-elevated level. If you want root access in your application then you have two very simple choices: 1. Do what k5054 advised and set up your account to run at higher level. 2. Call sudo in your shell before launching your application.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups