running a GUI program in the background - Page 5
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 5 of 6 FirstFirst ... 23456 LastLast
Results 61 to 75 of 83

Thread: running a GUI program in the background

  1. #61
    Join Date
    Dec 2012
    Location
    England
    Posts
    1,985

    Re: running a GUI program in the background

    the service installed fine but it won't start
    Why not? What error is being reported? What is your service doing and what is causing the error?
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  2. #62
    Join Date
    Mar 2012
    Posts
    99

    Re: running a GUI program in the background

    when i try start the service from the system control management the message error 2: system cannot find the file specified appears and when i run the batch file in the cmd i get the same message

  3. #63
    Join Date
    Apr 1999
    Posts
    27,418

    Re: running a GUI program in the background

    Quote Originally Posted by beginner91 View Post
    can't debug a service program
    All programs can be debugged, unless the program has anti-debugger features in it.

    Second, even if you couldn't figure out how to debug, you always have OutputDebugString() and programs such as DebugView from sysinternal.com to see output messages.

    Third, let's ask you to see if you understand what everyone is saying:

    What do you think the result of this operation is?
    Code:
    CString path = GetExeFolderName() + TEXT("C:\\testService\\Debug\\testService.exe");
    ?
    What string is going to be created from this?

    Regards,

    Paul McKenzie

  4. #64
    Join Date
    Mar 2012
    Posts
    99

    Re: running a GUI program in the background

    What string is going to be created from this?
    i don't know. i thought that code just told the program where the exe file is

  5. #65
    Join Date
    Dec 2012
    Location
    England
    Posts
    1,985

    Re: running a GUI program in the background

    Quote Originally Posted by beginner91 View Post
    i don't know. i thought that code just told the program where the exe file is
    It would probably be useful if you posted your code so we could see how you are trying to achive and so we could provide better guidance.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  6. #66
    Join Date
    Mar 2012
    Posts
    99

    Re: running a GUI program in the background

    i am using the code igor posted to this thread (post #42). the only line i changed was the path

  7. #67
    Join Date
    Dec 2012
    Location
    England
    Posts
    1,985

    Re: running a GUI program in the background

    Please post the code here that you are actually using.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  8. #68
    Join Date
    Mar 2012
    Posts
    99

    Re: running a GUI program in the background

    ok i attached the code

    code.zip

  9. #69
    Join Date
    Dec 2012
    Location
    England
    Posts
    1,985

    Re: running a GUI program in the background

    the service installed fine but it won't start
    How do you know that the service installed fine? Have you checked it with the services program? What does sc query MyServiceX say from the command line? What is the contents of the file mysvcx.log (not sure which folder it'll be in - do a search for it)?
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  10. #70
    Join Date
    Mar 2012
    Posts
    99

    Re: running a GUI program in the background

    How do you know that the service installed fine?
    i can see its installed because it appears in the Service Management Console list.

    What does sc query MyServiceX say from the command line?
    C:\testService>if -u == goto UNINSTALL

    C:\testService>sc create MyServiceX binPath= "C:\testService\mysvcx.exe"
    [SC] CreateService FAILED 1073:

    The specified service already exists.

    C:\testService>sc start MyServiceX
    [SC] StartService FAILED 2:

    The system cannot find the file specified.

    What is the contents of the file mysvcx.log
    when i try run the service the file is empty but when i run the exe file it says:
    [05/01/13 14:29:07] ++ Start ++
    [05/01/13 14:29:14] -- Stop --

  11. #71
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,877

    Re: running a GUI program in the background

    Quote Originally Posted by beginner91 View Post
    i am using the code igor posted to this thread (post #42). the only line i changed was the path
    No, you're not using my code. What you made of it is a horrible mess, while what you were just supposed to do is to run Visual Studio Command Prompt and run make.bat there to build mysvcx.exe as well as test.exe.
    Best regards,
    Igor

  12. #72
    Join Date
    Mar 2012
    Posts
    99

    Re: running a GUI program in the background

    i don't have experience using batch files so i wasn't sure what to do.
    run Visual Studio Command Prompt and run make.bat
    i got this error:
    test.cpp
    test.cpp(1) : fatal error C1083: Cannot open include file: 'windows.h': No such
    file or directory
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
    Copyright (C) Microsoft Corporation. All rights reserved.

    10.cpp
    10.cpp(2) : fatal error C1083: Cannot open include file: 'windows.h': No such fi
    le or directory

  13. #73
    Join Date
    Dec 2012
    Location
    England
    Posts
    1,985

    Re: running a GUI program in the background

    what does sc qc MyServiceX show? Especially for the BINARY_PATH_NAME?
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  14. #74
    Join Date
    Apr 1999
    Posts
    27,418

    Re: running a GUI program in the background

    Quote Originally Posted by beginner91 View Post
    i don't know. i thought that code just told the program where the exe file is
    So basically you don't have any idea what that line of code does or what type of string will be created?

    I don't know what you believe C++ is, but it isn't a scripting language or HTML. It requires that you know the language, and obviously you need to learn the language.
    Code:
    CString path = GetExeFolderName() + TEXT("C:\\testService\\Debug\\testService.exe");
    What does the "+" in red do? It joins two strings together to create a single string. It joins the string on the left with the string on the right to create a single string.

    What does the "=" in blue do? It assigns the value of the operation on the right hand side of the "=" to the variable on the left hand side of the "=". So "path" will contain the value of the concatenation of the two strings.

    Now, look at the two strings you're joining -- you are taking the value of GetExeFolderName(), and adding to it C:\testService\Debug\testService.exe. So for arguments sake, let's say that GetExeFolderName() returns "C:\MyFolder\MyEXE\". So what is the result of "path" after the concatenation is done?
    Code:
    C:\MyFolder\MyEXE\C:\testService\Debug\testService.exe
    (extra slashes were removed for ease looking at the real value)

    Does that look like a valid directory name to you? Forget about C++, have you ever seen a directory name that looks like that? That name is not even a valid Windows directory name, regardless of what you want to do. If you want to be convinced, go to a command prompt and do a "DIR" on the name that "path" happens to be -- do you get back a listing or does the DIR give you an error?

    That's why you keep getting the error and why you should have checked the result of "path" so that you know what you are using.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; May 1st, 2013 at 10:49 AM.

  15. #75
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,877

    Re: running a GUI program in the background

    Quote Originally Posted by beginner91 View Post
    i don't have experience using batch files so i wasn't sure what to do.

    i got this error:
    test.cpp
    test.cpp(1) : fatal error C1083: Cannot open include file: 'windows.h': No such
    file or directory
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
    Copyright (C) Microsoft Corporation. All rights reserved.

    10.cpp
    10.cpp(2) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
    Considering the error what you opened is not Visual Studio Command Prompt. You should use Search in Start Menu.
    Best regards,
    Igor

Page 5 of 6 FirstFirst ... 23456 LastLast

Tags for this Thread

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center