Results 1 to 10 of 10
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    Vancouver, BC, Br. Columbia, Canada
    Posts
    96
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detect whether program already running

    Hi Access programmers:
    Is there a way to detect at startup whether my Access program is already running and, if so, display a message and shut down. Gotta' feeling this is an API function with window handles (hwnd) and horrible stuff like that.
    Thanks,
    Gwenda

  2. #2
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect whether program already running

    The attatched dll should be of assistance. Declare a function as below and call some sort of startup routine when you start Access.



    'This dll should be in the system directory so that it can always be found
    Declare Function TestAndActivate Lib "AndySoft_AccessStart.dll" (ByVal hwnd As Long) As Long


    public function Startup()
    If TestAndActivate(Application.hWndAccessApp) = 0 Then
    Application.Quit
    Else
    .....
    Attached Files Attached Files

  3. #3
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect whether program already running

    Hi Gwenda
    Your horrible feeling is absolutely spot on!
    Follow this link to Dev Ashish's excellent site
    <A target="_blank" HREF=http://www.mvps.org/access/api/api0041.htm>http://www.mvps.org/access/api/api0041.htm</A>
    (if you are after testing for Access running)
    (There is another page for testing for any application running)
    The use of it is quite well explained for an API call!
    HTH
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  4. #4
    Star Lounger
    Join Date
    Feb 2001
    Location
    Vancouver, BC, Br. Columbia, Canada
    Posts
    96
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect whether program already running

    Andy,
    Can't thank you enough. Will be testing it out shortly.
    If you ever come to beautiful Vancouver, I owe you lunch.
    Gwenda <img src=/S/joy.gif border=0 alt=joy width=23 height=23>

  5. #5
    Star Lounger
    Join Date
    Feb 2001
    Location
    Vancouver, BC, Br. Columbia, Canada
    Posts
    96
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect whether program already running

    Hi Steve,
    Would that be the Scottish flag you're flying??? Did you see the post from Andy? I'm going to try his DLL, but thanks for the steer to the Dev Ashish's site. As I said to Andy, if you're even in beautiful Vancouver, I'll buy you lunch.
    Gwenda

  6. #6
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect whether program already running

    English actually! (St George and all that)
    I did see Andy's post about the DLL. I haven't got involved with DLLs yet. I think you need to have them installed/registered with the associated problems re distribution/permissions. I like to keep my dbs 'in one piece' where possible.
    I stand to be corrected/educated though!
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  7. #7
    Star Lounger
    Join Date
    Feb 2001
    Location
    Vancouver, BC, Br. Columbia, Canada
    Posts
    96
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect whether program already running

    Ahhh... English! Now I understand why your signature is a tankard of beer.

    I haven't tried Andy's DLL yet for exactly that reason ... I'm not sure how to install/register and distribute it. I'll ask Andy.
    G

  8. #8
    Star Lounger
    Join Date
    Feb 2001
    Location
    Vancouver, BC, Br. Columbia, Canada
    Posts
    96
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect whether program already running

    Hi Andy,
    I'm chicken ... afraid of calling your DLL in my Access program. Don't I have to register your DLL first?
    Gwenda

  9. #9
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect whether program already running

    Hi Gwenda,
    Some dll's are registered so that information is stored in the registry to allow them to run. (Maybe other reasons as well). If a dll needds registering you should only get an error when you try to use it and it has not yet been registered. This little dll just needs to be in a directory that the op system looks in for searching for dll's / exe's. Typically the windows/system directory is used for this. Then just declare the function in code and call it somewhere in your startup procedure. If you experience any problems let me know.

    A comment to everyone else. I know Microsoft do not recommend putting dll's in the Windows or System directories. Putting the dll in another directory may require having to register it (or at least more coding somewhere).

  10. #10
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect whether program already running

    Hi Gwenda,
    Please throw away the first dll I posted. I had stripped too much out of the functional version I based it on. You require the one attatched here. Also I didn't make it clear in the origninal post that the declare should be in a module, not in a form.

    Thanks for the offer of lunch, I'll have to pass on it. I doubt I will ever visit Canada.
    Attached Files Attached Files

Posting Permissions

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