[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Running inside VB5 or in EXE?

Posted on 1998-06-25
7
Medium Priority
?
320 Views
Last Modified: 2010-05-03
I want to know if my program is running inside the VB5 development environment or in compiled EXE.
I can not use the App.EXEName because it will return the same name if the application name and the EXE name is the same.
Also, I succeeded to detect this in VB4 using API GetModuleFileName and GetWindowWord, but in VB5 they always report that the project is running in EXE. I think this is probably because VB5 compiles and runs the project as a true compiled application which is not the case in VB4 (I think).
I also tried to check the 'Compile to p-code' in the compile options, but got the same results.
Thanks.
0
Comment
Question by:gelco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Author Comment

by:gelco
ID: 1464344
Adjusted points to 200
0
 
LVL 2

Expert Comment

by:marti
ID: 1464345
One possible solution could be to set command line arguments to something specific while working in VB5 development environment.
0
 

Author Comment

by:gelco
ID: 1464346
Thanks marti, but I think this will not solve my problem.
I want some API code or some other way to do the real job.
Thanks again.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
yowkee earned 400 total points
ID: 1464347
gelco,

  Let's try this:

-----
Private Declare Function GetModuleFileName Lib "kernel32" Alias _
        "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As _
        String, ByVal nSize As Long) As Long

Function IsRunUnderVB5() As Boolean
 Dim S As String, Length
 Length = 256
 S = String(Length, 0)
 Call GetModuleFileName(0, S, Length)
 S = Left(S, InStr(S, Chr(0)) - 1)
 IsRunUnderVB5 = UCase(Right(S, 7)) = "VB5.EXE"
End Function
Private Sub Form_Load()
    If IsRunUnderVB5 Then
        MsgBox "Run Under VB5"
    Else
        MsgBox "Run in Exe"
    End If
End Sub
----------

Regards.
0
 

Expert Comment

by:LMSuporte
ID: 1464348
I am making this an answer: These function  doesnt require any API at all. It will return true if you are running in design time, false otherwise. To make sure this will work, go to the menu TOOLS, then OPTIONS, then choose the tab GENERAL and make sure your "Error Trapping" is set to "BREAK IN CLASS MODULE" (under VB5). In all other versions of VB, it will work just fine.
(PS: This might not work properly if you are creating an OCX and a VBP in the same project)

Public Function IsDesign() As Boolean

    On Error GoTo IsDesignIsTrue

    Debug.Print 1 / 0
    IsDesign = False
    Exit Function

IsDesignIsTrue:
    IsDesign = True

End Function

0
 
LVL 9

Expert Comment

by:Dalin
ID: 1464349
yowkee,
congradulations on your making the top 15. Keep up the good work.
regards
Dalin
0
 
LVL 4

Expert Comment

by:yowkee
ID: 1464350
Thanks, Dalin. It seem I start to be lazy after being the 15th :P...... Hope I could come back after good rest. My respect to you as you keep answering question here. It's not easy, really. :)

And gelco, are you there? Come and evaluate mine and LMSuporte's post.

 
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question