CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2000
    Location
    Liverpool, England
    Posts
    1

    Runtime/Debug Environment

    Does anyone know a way from code, that I can automatically detect if the application is running under the development environment or is
    being executed "normally"?

    A project I am currently involved with is using system timers to automatically close Database connections if no activity occurs within a certain timescale. This unfortunately has a side effect that the VB environment itself can be completely closed if the "End" buuton is pressed and timers are outstanding. I do not if possible wish to have to control this via INI file or compile parameters if possible.

    The project is converting to VB6 from VB5, and comprises of 1 main exe and 7 DLLs (3 provide common functions, the others are function specific) within the one project group, testing is usually done with all the code as vbps in the development environment, but sometimes the compiled DLLs are linked.


    Thankyou in advance.





  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Runtime/Debug Environment

    There's a really simple way of determining if you are running under the VB IDE :


    public Function IsCompiled() as Boolean
    '
    on error GoTo NotCompiled
    '
    ' Debug.print 1/0 will raise an error at debug time
    ' at compile time, all Debug.print commands are
    ' stripped out from the EXE
    '
    Debug.print 1 / 0
    '
    IsCompiled = true
    '
    NotCompiled:
    '
    End Function




    So a simple :



    If IsCompiled then ' Whatever
    '




    - should do the trick.



    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

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