CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2010
    Posts
    2

    Need Help with code.

    I'm trying to build a little program, but nothing I do seems to work. So I'm using this as a sort of last resort.

    1) I'd like the program to start minimized to the system tray. [Haven't gotten to this yet. but help with it would be appreciated if you have help to offer.]
    2 I'd like the program to have a continuously looping timer of 1 hour.
    3) And the end of each 1 hour interval I want two things to happen:
    a) a certain process is stopped.
    b) a program is executed.

    I'm a complete coding novice, so all my attempts to piece something together from bits learned off of various tutorials have failed. Here's what I got so far:

    Code:
    Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Timer1.Enabled = True 'Timer set to 10 seconds for testing.
    End Sub
    
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Shell("taskkill -f process.exe") 'Kill a program. The -f option will force it to end.
    Shell("explorer program.exe") 'Start a program.
    
    End Sub
    End Class
    When I start the program up, all it does it sit there. No process stopped, or program started. Is it because I'm on windows 7 or something else? Any help would be appreciated.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Need Help with code.

    Welcome to the Forums!

    I'd recommend using the proper APIs for this purpose, for example :

    Process32First
    Process32Next
    CloseHandle
    OpenProcess
    EnumProcesses
    GetModuleFileNameExA
    EnumProcessModules
    CreateToolhelp32Snapshot
    GetVersionEx
    TerminateProcess

    It is a bit more work, but to do it properly, do it the right way.

  3. #3
    Join Date
    May 2010
    Posts
    2

    Re: Need Help with code.

    Quote Originally Posted by HanneSThEGreaT View Post
    Welcome to the Forums!

    I'd recommend using the proper APIs for this purpose, for example :

    Process32First
    Process32Next
    CloseHandle
    OpenProcess
    EnumProcesses
    GetModuleFileNameExA
    EnumProcessModules
    CreateToolhelp32Snapshot
    GetVersionEx
    TerminateProcess

    It is a bit more work, but to do it properly, do it the right way.
    Being the coding noob that I am, this project is turning out to be more and more unfeasible.

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