CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 43 of 43
  1. #31
    Join Date
    Apr 1999
    Posts
    27,449

    Re: How Can I Close exe files with C++ code ?

    Quote Originally Posted by Jeff++ View Post
    maybe so, but trying things out bring up problems and errors. Then I learn why there's a problem or error. Then when I do come across that situation in a tutorial...
    There is one big flaw in all of this -- how do you know what to do or learn next? You must get material from somewhere, or else you never progress.

    For example, how do you know about std::string, std::vector, algorithms, streams, etc. unless you read about them and see how to use them?

    Second, when you say "tutorial", where exactly are you getting this tutorial? Many, if not most websites and so-called tutorials are notorious for giving incorrect and outdated information on the C++ language. This is why books are the defacto way to learn C++ properly -- they are peer-reviewed, unlike websites and other on-line tutorials.

    Regards,

    Paul McKenzie

  2. #32
    Join Date
    Feb 2009
    Posts
    80

    Re: How Can I Close exe files with C++ code ?

    um well I have read about all of that, I just like to try things and not JUST read about it. otherwise it's boring. Also, like I said... if I go ahead and try something and it doesn't work... I learn a lot from finding out why it doesn't work. I'm just having fun with this and it's not like I want to make this a carreer or anything. I've been getting most of my info from here

    http://www.cprogramming.com/tutorial.html#c++tutorial

  3. #33
    Join Date
    Apr 1999
    Posts
    27,449

    Re: How Can I Close exe files with C++ code ?

    Quote Originally Posted by Jeff++ View Post
    um well I have read about all of that, I just like to try things and not JUST read about it. otherwise it's boring. Also, like I said... if I go ahead and try something and it doesn't work... I learn a lot from finding out why it doesn't work.
    The problem with all of this is that you're asking questions here, where most of the people here have programmed as a profession or at the very least, on a very advanced "amateur" level.

    What I'm driving at is this -- it is difficult if not impossible to answer questions from someone who uses a "throw anything on the wall and see what sticks" or ad-hoc approaches to programming in C++. The reason is that it is expected that you have the prerequisite knowledge of the topics required to understand our answers and responses to you. Otherwise it gets frustrating to you and the people trying to help you. You can't "reverse engineer" yourself into an answer that requires you to read up on topics long before you actually use them.

    Every good C++ book has examples that you type in and understand how they work. You can't just dive into complex GUI programming without knowledge of the language. That's already been demonstrated by the many questions you see in the Visual C++ forum from people who use the GUI wizards, and then ask the most basic of C++ questions that are answered in chapters 1 or 2 of any C++ book.

    If you embarked on learning C++ on your own without intervention from anyone, then you can learn whatever way you want. However, when you are asking others to help you while going down this unorthodoxed approach of attempting to learn C++, then that is where it gets problematic.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; February 22nd, 2009 at 07:22 PM.

  4. #34
    Join Date
    Feb 2009
    Posts
    80

    Re: How Can I Close exe files with C++ code ?

    no offence Paul, but I have been told I learn things backwards all my life. You're not the first. I hold some pretty serious patents because of my backwards out of the box thinking, including a the first floatless carburetor design for a company called Briggs and Stratton. Go look in your garage... you might already have one. I have no intensions of becoming a professional programmer. I am just into this for fun. I am having fun, making my own games already after just a few weeks. If you think that is wrong, or bad technique somehow.... I'm sorry but I disagree. I haven't had any problems yet doing what I want to do, and any snags I've run into because I don't understand something... I read about it. If I can't find an answer, I ask someone who knows. I don't see the problem with this approach, but if it bothers you that much, please feel free to not answer any of my questions because they seem silly to you.

  5. #35
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: How Can I Close exe files with C++ code ?

    Quote Originally Posted by Jeff++ View Post
    , please feel free to not answer any of my questions because they seem silly to you.
    I think his point is not that the questions are silly, but that you won't necessarily understand the answers, because your knowledge of C++ is gained in a haphazard fashion. If you'd learnt some of the basics first then you may not have needed to ask the question in the first place.
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  6. #36
    Join Date
    Feb 2009
    Posts
    80

    Re: How Can I Close exe files with C++ code ?

    it may seem rediculas or impossible to you, but I just don't learn the " normal " way. I've been told that all my life, and I've been told not to do it that way, or that I can't do it that way...... just like my small engine repair teacher in high school said... " you need to learn this first... and that will never work " and when I asked why won't it work ? his answer was similar to yours. " You need to understand more of the principals behind it fist " but now I make about $200,000 per year off my invention that " couldn't work ". Not to mention a few smaller patents. Learning the traditional way has never made sense to me. Why do things the same way everyone else does. How could one expect to come up with something new if following the same path as everyone else ?
    I am a person with an inventors mind. I'm sorry if my way of thinking seems totally backwards, unorthodox, or just plain wrong to you. I learn things by cramming through basics, right into the " expert level " stuff.... and fill in the blanks later. For me I can learn things 50 to 100 times faster this way. I would agree with the fact it's not for everyone.
    Here's an example.
    I did DAYS of reading... and couldn't find a real solid answer on how to open an executable file from my C++ code. I asked in this forum and several others for some help or tips. I got LOTS.
    All were different ways to do it. They all seems really long and extravagant to me... just to open the silly little windows calculator. When I asked people that know, why such long code ? isn't there a one line code that will open the calculator for me ? I was told by many experts... NO. I was told It can't be done, I was told it involves more knowledge than I have, I was told if I knew more... I'd understand why it won't work. Then I was shown a short code that would do it, but then wouldn't allow the program to continue without the calculator being closed first....
    and then you John showed me this fabulous little code
    Code:
    ::ShellExecute(NULL,
                       "open",
                       "Calc.exe",
                       "",
                       "",
                       SW_SHOWNORMAL);
    and it worked just dandy ! ( thanks again by the way ). So there.... all that talk of " it can't be done that way " " If you want the program to continue... you NEED to do it the long way " and " you need to understand C++ better before writing a game that will do that "
    all went out the window in one short little line of code.
    Once you handed me this great little code... I did the reasearch to understand shell commands and whats going on under the hood in the code. And THAT's how I choose what to read up on next. Not what I should be reading in any particular order. If that seems messed up or wrong to any of you folks out there.... I'm sorry. It's just the way I invent things and learn. Again... Not for everyone. And I most certainly do appreciate all the help I've been getting in this forum.
    cheers.

  7. #37
    Join Date
    Apr 1999
    Posts
    27,449

    Re: How Can I Close exe files with C++ code ?

    Quote Originally Posted by Jeff++ View Post
    I did DAYS of reading... and couldn't find a real solid answer on how to open an executable file from my C++ code. I asked in this forum and several others for some help or tips. I got LOTS.
    You've steered right into what myself and others are talking about.
    and then you John showed me this fabulous little code
    Code:
    ::ShellExecute(NULL,
                       "open",
                       "Calc.exe",
                       "",
                       "",
                       SW_SHOWNORMAL);
    This code is not standard C++ code. It is Windows API code. This code will not work on another OS. If you are working in Windows, you should have posted your question in the Windows API forum. Maybe that's why you couldn't find answers in C++ books. C++ isn't specific to the Windows API or any other OS specific functions and functionality.

    Regards,

    Paul McKenzie

  8. #38
    Join Date
    Feb 2009
    Posts
    80

    Re: How Can I Close exe files with C++ code ?

    yes , I know that all now. After having fun with my game, which only ever needed to run on windows. Why would I try to open WINDOWS CALCULATOR if it wasn't running on a windows platform ???
    Using it lead me to the research to understand it. Otherwise I wouldn't have even known it existed. It may not be C++ but It worked, and that's all I cared about. I never really cared if it would run on anyone elses computer. Not sure why it bothers you so much Paul. I'm just having fun, and I haven't run into any " snags " as you put it. I'm sure I'll be making better code that " makes sense to you " in a year or so, with all the do's and don'ts weeded out.

    and how on God's green earth would I post my question in the windows API section, when up until a few days ago I had no idea what the heck that was ?
    or the fact that I didn't know there was a windows API section in this forum until right now ?
    or the fact that my game started out with C and then I used a windows function ?

    don't worry so much Paul. You don't need to answer any questions of mine if you don't want to.
    Last edited by Jeff++; February 23rd, 2009 at 09:11 PM.

  9. #39
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: How Can I Close exe files with C++ code ?

    Quote Originally Posted by Jeff++ View Post
    yes , I know that all now. After having fun with my game, which only ever needed to run on windows. Why would I try to open WINDOWS CALCULATOR if it wasn't running on a windows platform ???
    Using it lead me to the research to understand it. Otherwise I wouldn't have even known it existed. It may not be C++ but It worked, and that's all I cared about. I never really cared if it would run on anyone elses computer. Not sure why it bothers you so much Paul. I'm just having fun, and I haven't run into any " snags " as you put it. I'm sure I'll be making better code that " makes sense to you " in a year or so, with all the do's and don'ts weeded out.
    Because this forum is for generic C++ questions. There are several forums for Windows specific problems.

    You'd do well to listen to those who have been where you are now. Arrogance won't serve you well.

  10. #40
    Join Date
    Apr 1999
    Posts
    27,449

    Re: How Can I Close exe files with C++ code ?

    Quote Originally Posted by Jeff++ View Post
    yes , I know that all now.
    You could have explained that in your last post, but it was left to the reader that you didn't understand that there is a difference between the C++ language and the Windows API
    After having fun with my game, which only ever needed to run on windows. Why would I try to open WINDOWS CALCULATOR if it wasn't running on a windows platform ???
    Don't ask me -- you posted the question in this forum that is not for Windows API programming. A "Windows Calculator" could mean anything here -- you could have tried to start it using Wine under Linux. This forum is for non-Windows API, general C++, and other OSes such as Linux/Unix/Macintosh. There is a Windows API forum already set up for questions concerning Windows.
    It may not be C++ but It worked, and that's all I cared about. I never really cared if it would run on anyone elses computer.
    That is not the point. Post your questions in the appropriate forum, that is all that is being asked of you.
    Not sure why it bothers you so much Paul.
    Persons should follow posting guidelines and etiquette. Otherwise what's the use of forums?

    Regards,

    Paul McKenzie

  11. #41
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: How Can I Close exe files with C++ code ?

    I was told by many experts... NO. I was told It can't be done,
    Yes, I've had that before. We once had great trouble with a synchronous detector (a sort of rectifier with oscillator) that kept going out of sync. I suggested a precision rectifier instead (diodes with an op-amp). "No, that won't work anywhere near as well when there's noise in the signal" they said. So I build one, injected noise and put in a switch between the two and asked them to identify which was which in a blind test. We used the precision rectifier.

    I'm sure the 'dive in and work it out as you go along' technique has its advantages (shortcuts to novel solutions) as well as its disadvantages (blind alleys & inelegant solutions), but I think the majority of people here will tell you that it's a terrible way to learn a complex programming language. Long term contributors to CodeGuru have seen it time and again where people have attempted to code for something where it is obvious they have not grasped the fundametals and have made a complete 'pigs-ear' of their code. Memory leaks, undefined behaviour etc abound.

    The problem with learning a programming language is that,without the fundamentals, bad coding practices are nearly always learnt first and, once this is discovered, the coder has to do a complete relearning exercise.

    And the code they produce in the interim causes their colleagues to want to hang them up by their thumbs until they repent.
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  12. #42
    Join Date
    Jun 2009
    Posts
    2

    Re: How Can I Close multiple exe files with C++ code ?

    Hi,

    for closing single exe we can use following code.
    HWND hWnd = ::FindWindow(NULL,"procman");
    ::SendMessage(hWnd,WM_CLOSE,0,0);

    i have multiple exe files running on the window.how to close all windows.

  13. #43
    Join Date
    Jun 2009
    Posts
    2

    Re: How Can I Close exe files with C++ code ?

    Hi,

    for closing single exe we can use following code.
    HWND hWnd = ::FindWindow(NULL,"procman");
    ::SendMessage(hWnd,WM_CLOSE,0,0);

    i have multiple exe files running on the window.how to close all windows.

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured