Results 1 to 6 of 6

Thread: VB help!!

  1. #1
    Member
    Join Date
    Nov 2001
    Posts
    37

    Question VB help!!

    hi all,

    i m trying to write a vb code(program)..
    it is like if someone is already running the program then he will not be able to launch it again unless he terminate the program first.. for example like Windows Media Player

    anyone knows pls reply.. thanks alot..

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    472
    You have to to use the win32api to do that. Here's how:
    1. Call EnumProcesses() to receive an array of all the running process IDs.
    2. Call OpenProcess() to get a handle to the process.
    3. Call EnumProcessModules() to get an array of process property identifiers (I guess)
    4. Call GetModuelFileNameEx() with the first HMODULE from the list in nr 3. That will return a complete path to an executable.

    The rest i bet you can figure out yourself. BTW, I haven't tried this, I'm just referring to a post on Google groups (http://groups.google.com/groups?hl=e....cz%26rnum%3D1)

    Edit:
    Suddenly noticed this was posted in the wrong forum. Please choose another forum next time, such as Genereal Chit Chat or Programming Scurity
    ---
    proactive

  3. #3
    Just a Virtualized Geek MrLinus's Avatar
    Join Date
    Sep 2001
    Location
    Redondo Beach, CA
    Posts
    7,323
    **Moved from Tutorials to General Chit Chat**
    Goodbye, Mittens (1992-2008). My pillow will be cold without your purring beside my head
    Extra! Extra! Get your FREE copy of Insight Newsletter||MsMittens' HomePage

  4. #4
    Senior Member
    Join Date
    Aug 2001
    Posts
    100
    hmm, don't know wether this is what you want
    you can test whether a form of your application is already loaded

    'begin code listing
    private sub form_load()
    msgbox "form2 is loaded" & testform(form2)
    end sub

    function testform(formname as form)
    dim tempform as form

    for each tempform in forms
    if tempform is formname then
    testform = true
    exit function
    end if
    next
    testform = false
    end function

    'end code listing
    \"Knowledge is the Real Power\"

  5. #5
    Member
    Join Date
    Nov 2001
    Posts
    37
    i haven't tried it yet.. but i will try later.. anyway, thanks alot guys...
    O btw, i did look for the General Chit Chat forum but perpahs i overlook it.. sorry...

  6. #6
    yes have a message box come up if he tries to open more than one, if you know a little about vb a msg_box code isn't that hard to make

Posting Permissions

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