Autor Tema: OCX Detect IDE  (Leído 2931 veces)

0 Usuarios y 1 Visitante están viendo este tema.

green.pitch

  • Bytes
  • *
  • Mensajes: 23
  • Reputación: +0/-0
    • Ver Perfil
OCX Detect IDE
« en: Mayo 07, 2012, 04:00:16 am »
Hello,
I am developing an ActiveX control in which I want to detect if the OCX is running under IDE or Running inside a Compiled Application.

I have tried "App.LogMode" in my OCX but that's not working.

Here is the ActiveX Code:

Código: [Seleccionar]
Private Sub UserControl_Initialize()
If (App.LogMode = 0) Then
    MsgBox "IDE Detected"
Else
    MsgBox "IDE not Detected"
End If
End Sub

But after Compiling it, and using as a Reference in the another project IDE. It is returning "IDE not Detected".

PS: Without compiling (Working fine If Adding it as a User Control)

Please tell me How may I detect IDE by OCX?

Thanks before,
Regards,

Bazooka

  • Terabyte
  • *****
  • Mensajes: 951
  • Reputación: +31/-20
  • El pibe Bazooka
    • Ver Perfil
    • Desof sistemas
Re:OCX Detect IDE
« Respuesta #1 en: Mayo 07, 2012, 08:44:51 am »
Hola supongo que por que al compilarlo ya no se esta ejecutando en el ID el ocx, tal vez deberias utilizarlo al control sin compilar como un proyecto (ctl)
Todos somos muy ignorantes. Lo que ocurre es que no todos ignoramos las mismas cosas.

green.pitch

  • Bytes
  • *
  • Mensajes: 23
  • Reputación: +0/-0
    • Ver Perfil
Re:OCX Detect IDE
« Respuesta #2 en: Mayo 07, 2012, 09:03:49 am »
Hola supongo que por que al compilarlo ya no se esta ejecutando en el ID el ocx, tal vez deberias utilizarlo al control sin compilar como un proyecto (ctl)

Hello Bazooka,
Thank you for reply,
I am adding a licensing system in my OCX, I want to share my OCX with my few friends and I want them to Put serial number to Activate my OCX to use that in the IDE. That's why I need to detect IDE by compiled OCX.

Regards,

cobein

  • Moderador Global
  • Gigabyte
  • *****
  • Mensajes: 348
  • Reputación: +63/-0
  • Más Argentino que el morcipan
    • Ver Perfil
Re:OCX Detect IDE
« Respuesta #3 en: Mayo 07, 2012, 10:38:20 am »
You can use, for instance GetCommandLine API (use the API not Command$) or any other function to retrieve information about the process, that way you can check if you are running under the IDE or not.

Example:
Código: [Seleccionar]
Private Declare Function GetCommandLine Lib "kernel32" Alias "GetCommandLineA" () As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)

Private Function IsInIDE() As Boolean
    MsgBox GetCommLine
    If Not InStr(1, UCase(GetCommLine), "VB6.EXE") = 0 Then
        IsInIDE = True
    End If
End Function

Private Function GetCommLine() As String
    Dim RetStr As Long, SLen As Long
    Dim Buffer As String
    'Get a pointer to a string, which contains the command line
    RetStr = GetCommandLine
    'Get the length of that string
    SLen = lstrlen(RetStr)
    If SLen > 0 Then
        'Create a buffer
        GetCommLine = Space$(SLen)
        'Copy to the buffer
        CopyMemory ByVal GetCommLine, ByVal RetStr, SLen
    End If
End Function

Private Sub UserControl_Initialize()
    MsgBox IsInIDE
End Sub

green.pitch

  • Bytes
  • *
  • Mensajes: 23
  • Reputación: +0/-0
    • Ver Perfil
Re:OCX Detect IDE
« Respuesta #4 en: Mayo 07, 2012, 04:58:22 pm »
Thanks cobein brother,
Nice reply. But After few searches visiting few forums found this:

Código: [Seleccionar]
Private Sub UserControl_Initialize()
    If (UserControl.Ambient.UserMode = True) Then
        MsgBox "runtime"
    Else
        MsgBox "Design time"
    End If
End Sub

Hope someone can get help from this.  :)

-Regards,