Link to home
Start Free TrialLog in
Avatar of Carlos_Rodrigues
Carlos_Rodrigues

asked on

OCX detect develop environment

How can I detect if my VB OCX is placed in a develop environment ( as VB, C++, Delphi, etc) ?

Thanks in advance,

Carlos Rodrigues
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Check  out this:
App.StartMode

Not sure as value, but should be ok most of the time...
Cheers
If you don't want other programmer using your control into their projects, you should check "Require License Key" box from the project properties.

Cut from the VB-Help file:

Require License Key

Enables licensing for ActiveX Control projects (projects that compile to .ocx files), not to .exe or .dll files. A Visual Basic license file (*.vbl) will be created when you build the project. The *.vbl must be registered on the user?s machine for the components to be used in the design environment. The SetUp Wizard will build a setup program that properly registers the information in the *.vbl file on the end user's machine when that setup program is run.
Avatar of viklele
viklele

Here is a small function that tells you if your application is executing from within VB IDE. I had written this a while ago for one of my projects.

I have put code of VB6 IDE, you can easily add appropriate class names for other IDEs.

<CODE>
<PRE>
'----------------------------------------------------------
' IsDesignMode :
'
' Returns true if program is in VB design mode.
'
' Returns false if the program is being executed either
' through the VB IDE or otherwise (compiled execution)
'
' Use this for stopping subclassing duing design mode
' Subclassing during design mode has a potential of causing
' crashes.
'----------------------------------------------------------
Public Function IsDesignMode(hParent As Long) As Boolean
Dim lRet As Long, hTopWindow As Long
Dim bRet As Boolean
Dim sClassName As String

   While (hParent <> 0)
      hTopWindow = hParent
      hParent = GetParent(hParent)
   Wend
   
   sClassName = Space(255)
   lRet = GetClassName(hTopWindow, sClassName, Len(sClassName) - 1)
   sClassName = Left(sClassName, lRet)
   
   Select Case sClassName
      '-- for supporting other IDEs, add class name here --
      Case "wndclass_desked_gsk" 'VB6 IDE
         bRet = True

      Case Else
         bRet = False
   End Select
     
   IsDesignMode = bRet
End Function
</PRE>
</CODE>

Hope this helps.
ASKER CERTIFIED SOLUTION
Avatar of KDivad
KDivad

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm with KDivad on this one!
Thanks! <grin>
KDidav, thanks.

Much better solution than mine. I will update my code library too.

You're welcome.
I got the idea when I heard somewhere that Debug statements aren't included in the final exe. I started wondering if I could somehow use that to determine EXE/IDE status...

Now I wonder if Carlos is coming back.
Give the points to KDivad

If Ambient.UserMode = true then err.raise 999, "Cannot use my control without purchasing it!"
Umm... That would prevent a compiled exe from using it! You want False.

<< True indicates ... an exe ...>>

I'd suggest using a license for that anyway...
Flase then...  I think they needed an example.  And yes a license is better, but that wasn't the question.
Grade Me  :)
It'd be nice... Just grade someone!!!!!
What I meant by "Me" was the Question...  Here let me be more specific!

GIVE KDIVAD AN A GRADE!!!  PLEASE!!!

:)
LOL! I won't argue with that!

It's Q's like this that landed me in an arguement with the moderators over cleaning up abandoned questions...
It appears that Carlos has forgotten about this Q :(
Rejecting proposed answer.

FOrce accepting KDivad's comment.


costello
Community Support Moderator @ Experts-Exchange