Visual Basic Foro
Programación => Visual Basic 6 => Mensaje iniciado por: green.pitch 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:
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,
-
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)
-
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,
-
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:
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
-
Thanks cobein brother,
Nice reply. But After few searches visiting few forums found this:
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,