CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: startup problem

  1. #1
    Join Date
    Sep 2009
    Posts
    5

    startup problem

    hi all
    i am having a problem with starting up a c++ program on startup.
    my program runs in the background and it is working 100%.
    but when i use the registry to autostart, the program will show a blank msdos and will not work.
    the thing that is confusing me is when i put a shortcut for the program in the startup folder, it works fine when i restart. but when i
    use the registry to autostart, the program won't work. it just gives that blank msdos!!

    my main looks like this:
    int main()
    {

    HWND hWnd = GetConsoleWindow();
    ShowWindow( hWnd, SW_HIDE ); // used to hide window.

    StartFunc(); // this function never stops. it has an infinite while loop (while(true))

    return 0;
    }

    so my question is, how can i hide the application after restarting the pc and using the registy to autostart?

  2. #2
    Join Date
    Apr 2008
    Posts
    725

    Re: startup problem

    hmm, blank msdos sounds like infintie loop is working...

  3. #3
    Join Date
    Sep 2009
    Posts
    5

    Re: startup problem

    yes i know...
    i want the infinite loop to work , but in the background...
    i don't want the window to appear after restart. it only appears when i use the registry to autostart, but when i create a shortcut in the statup folder, everything works fine (no window appears, and the program works gr8).
    that is the problem i am facing...
    any solutions??

  4. #4
    Join Date
    Oct 2005
    Location
    England
    Posts
    803

    Re: startup problem

    What IDE are you using? Often there is an option to run the program with no console window without having to hide it with code.
    Rich

    Visual Studio 2010 Professional | Windows 7 (x64)
    Ubuntu

  5. #5
    Join Date
    Sep 2009
    Posts
    5

    Re: startup problem

    i am using devc++
    can i run the program with no console window in devc++?

  6. #6
    Join Date
    Oct 2005
    Location
    England
    Posts
    803

    Re: startup problem

    Quote Originally Posted by scatman View Post
    i am using devc++ can i run the program with no console window in devc++?
    Navigate according to the following instructions:

    1. Tools -> Compiler Options
    2. "Settings" tab
    3. On the left hand side tree view select "Linker".
    4. Finally set "Do not create console window" to Yes using the drop down box.


    Hopefully that will work.
    Rich

    Visual Studio 2010 Professional | Windows 7 (x64)
    Ubuntu

  7. #7
    Join Date
    Sep 2009
    Posts
    5

    Re: startup problem

    Sweat
    although it didn't solve my problem..... but i learned something very useful. thank you.
    now i can hide the application, but it is not working as it is supposed to.
    i can see it in the task manager, but it is not working.
    i solved the problem by creating a function that creates a bat file automatically. the bat file starts the application, and i included the bat file in the registry startup.
    so when i restart the pc, the bat file is called at startup, which starts the program.

    but i am still confused because everything works fine when i use the startup folder to startup my program. i still can't figure why its not working when i use the registry to startup.
    i thought both ways (the registry and the startup folder) both starts the application in the same way...

    if you have any other solutions or explanations please feel free to post.

  8. #8
    Join Date
    Oct 2005
    Location
    England
    Posts
    803

    Re: startup problem

    It it much harder to hide things from task manager. This project of yours sounds slightly fishy, for what reason would you want to hide an application to that extent?

    If you have a good reason to do this then consider making your application in to a windows service if it is going to be running in the background.
    Rich

    Visual Studio 2010 Professional | Windows 7 (x64)
    Ubuntu

  9. #9
    Join Date
    Sep 2009
    Posts
    5

    Re: startup problem

    My application is a keylogger and its for educational purposes.
    after i finish it, i will upload the code on some page and explain it.

    the program self copies it self to a folder, and adds the folder's location to registry startup. after the user restarts his pc, the program starts logging his keystrokes to a txt file. when the txt file becomes bigger than 500 kb, the program sends the txt file to an email and clears the data from the txt file.

    as i said, its for educational purposes only. it is working fine now, but there are some problems that i couldn't figure out the answer to. i fined some ways to go around the problems (and solve them).... but i can't understand why they didn't work in the 1st place.
    for example the registry startup and the startup folder.
    why will the program works well when i use the startup folder, but not when i use the registry to startup.

    the whole point of doing the program is educational. the program is working now, but i still want explanations...

    what is a windows service? i only know abt windows application and console application programming in c++.

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