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. SetComputerName not taking effect. No Error in Debug either.

SetComputerName not taking effect. No Error in Debug either.

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebuggingtutorialquestionlearning
9 Posts 3 Posters 0 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.
  • R Offline
    R Offline
    rbwest86
    wrote on last edited by
    #1

    Hello everyone, I am posting this here because I am not receiving an error to my compiling. The program executes just fine, just not applying the new computer name. Please tell me what you see wrong. I am new and been reading on MSDN's website on how to used this Function correctly. If you have an answer to my question, please explain your answer. It will help me and any other beginner programmer. Here is the code: <code>#include <iostream> #include <windows.h> #include <stdio.h> using namespace std; // Set Local Computer Name BOOL WINAPI SetComputerName( LPCTSTR lpnewcomputername ); int main() { return 0; }

    L S 2 Replies Last reply
    0
    • R rbwest86

      Hello everyone, I am posting this here because I am not receiving an error to my compiling. The program executes just fine, just not applying the new computer name. Please tell me what you see wrong. I am new and been reading on MSDN's website on how to used this Function correctly. If you have an answer to my question, please explain your answer. It will help me and any other beginner programmer. Here is the code: <code>#include <iostream> #include <windows.h> #include <stdio.h> using namespace std; // Set Local Computer Name BOOL WINAPI SetComputerName( LPCTSTR lpnewcomputername ); int main() { return 0; }

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      The computer will do everything you ask it to do; it starts at the first line of your main() function and continues until either a return, an exit() or a fatal error is encountered. You should be able to figure it out from there. :(

      Luc Pattyn [Forum Guidelines] [My Articles]


      Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


      R 1 Reply Last reply
      0
      • L Luc Pattyn

        The computer will do everything you ask it to do; it starts at the first line of your main() function and continues until either a return, an exit() or a fatal error is encountered. You should be able to figure it out from there. :(

        Luc Pattyn [Forum Guidelines] [My Articles]


        Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


        R Offline
        R Offline
        rbwest86
        wrote on last edited by
        #3

        I thought that if I placed the SetComputerName function in int main() That it would be considerd a nested function? And I thought Nested functions are not allowed in int main()? I am confused on this. I feel very stupid for this as well.

        L 1 Reply Last reply
        0
        • R rbwest86

          I thought that if I placed the SetComputerName function in int main() That it would be considerd a nested function? And I thought Nested functions are not allowed in int main()? I am confused on this. I feel very stupid for this as well.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, I can conclude that you are a beginner and this is your first attempt at any programming language. Hence my advice: go to the book store, look at some books, buy the one book that looks most interesting, and study it; in one or two weeks it will teach you all the basics in a systematic way; and you will learn much more than you can discover by yourself, by experimenting and asking random questions. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


          R 1 Reply Last reply
          0
          • L Luc Pattyn

            Hi, I can conclude that you are a beginner and this is your first attempt at any programming language. Hence my advice: go to the book store, look at some books, buy the one book that looks most interesting, and study it; in one or two weeks it will teach you all the basics in a systematic way; and you will learn much more than you can discover by yourself, by experimenting and asking random questions. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


            R Offline
            R Offline
            rbwest86
            wrote on last edited by
            #5

            Thank you for the advice. I will do so when I get back from Iraq. : \ Now I ran back to my room to try and re-compile this and I changed it to the following: I still do not recieve any errors. Yet after I reboot the computer name is still the same. I am doing my best to understand. #include <iostream> #include <windows.h> #include <stdio.h> using namespace std; int main() { BOOL WINAPI SetComputerName( LPCTSTR lpnewcomputername); }

            L 1 Reply Last reply
            0
            • R rbwest86

              Thank you for the advice. I will do so when I get back from Iraq. : \ Now I ran back to my room to try and re-compile this and I changed it to the following: I still do not recieve any errors. Yet after I reboot the computer name is still the same. I am doing my best to understand. #include <iostream> #include <windows.h> #include <stdio.h> using namespace std; int main() { BOOL WINAPI SetComputerName( LPCTSTR lpnewcomputername); }

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Hi, I do not plan on writing a C tutorial, however there are three things to functions: 1. you can declare them, i.e. explain how they look, what their parameters and result are. That is what int square(int val); does. Declaring a function is not always necessary. 2. you can define them, i.e. provide an implementation, that is code that actually does the job. example: int square(int val) { return val*val; } Note the brackets. Defining a function is necessary, unless you have a library (i.e. a collection of function definitions somewhere). 3. you can call them, i.e. cause them to be executed. example: c = square(123); If you need more, for starters look for a tutorial on the web. A simple google will find many, such as this one[^] :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


              R 1 Reply Last reply
              0
              • L Luc Pattyn

                Hi, I do not plan on writing a C tutorial, however there are three things to functions: 1. you can declare them, i.e. explain how they look, what their parameters and result are. That is what int square(int val); does. Declaring a function is not always necessary. 2. you can define them, i.e. provide an implementation, that is code that actually does the job. example: int square(int val) { return val*val; } Note the brackets. Defining a function is necessary, unless you have a library (i.e. a collection of function definitions somewhere). 3. you can call them, i.e. cause them to be executed. example: c = square(123); If you need more, for starters look for a tutorial on the web. A simple google will find many, such as this one[^] :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


                R Offline
                R Offline
                rbwest86
                wrote on last edited by
                #7

                thank you very much for your help. I am reading the tutorial now ^^

                L 1 Reply Last reply
                0
                • R rbwest86

                  thank you very much for your help. I am reading the tutorial now ^^

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  You're welcome. And good luck with it. :)

                  Luc Pattyn [Forum Guidelines] [My Articles]


                  Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


                  1 Reply Last reply
                  0
                  • R rbwest86

                    Hello everyone, I am posting this here because I am not receiving an error to my compiling. The program executes just fine, just not applying the new computer name. Please tell me what you see wrong. I am new and been reading on MSDN's website on how to used this Function correctly. If you have an answer to my question, please explain your answer. It will help me and any other beginner programmer. Here is the code: <code>#include <iostream> #include <windows.h> #include <stdio.h> using namespace std; // Set Local Computer Name BOOL WINAPI SetComputerName( LPCTSTR lpnewcomputername ); int main() { return 0; }

                    S Offline
                    S Offline
                    Stuart Dootson
                    wrote on last edited by
                    #9

                    The docs[^] say this:

                    the name change takes effect the next time the user restarts the computer.

                    Have you restarted the machine?

                    Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                    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