Solved

Writing User info to ActiveX DLL

Posted on 2000-03-14
5
173 Views
Last Modified: 2010-05-02
Is it possible to write user info to a compiled ActiveX DLL (registration etc)?

Also, how do you detect if a dll is running in the IDE or Normal Windows?
0
Comment
Question by:millenisys
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:vindevogel
ID: 2616746
You can detect if your DLL or EXE is running from the shell or not with this piece of code


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

Public Function RunningFromShell(Handle As Long) As Boolean
Dim vModule As String
Dim vDummy As Long
Dim vRight As String

    vModule = String(256, 0)
   
    vDummy = GetModuleFileName(Handle, vModule, Len(vModule))
    vModule = Left$(vModule, InStr(vModule, Chr$(0)) - 1)
   
    vRight = UCase(Right(vModule, 7))
   
    RunningFromShell = (vRight = "VB5.EXE" Or vRight = "VB6.EXE")
End Function


The function receives a handle, which is the APP.HInstance

I coded it in a DLL myself, that's why I used the parameter. You can just type it directly in your code too.


I don't think you can write user info in a compiled dll.
0
 

Accepted Solution

by:
d_hottes earned 100 total points
ID: 2616979
You can determine, if you are in the IDE, by this simple but tricky code.

Public Function IsIDE() as Boolean
  Dim intRet as Integer
 
  On Error Resume Next

  Debug.Print 0 / 1
  If Err = 0 Then
    IsIDE = True
  Else
    IsIDE = False
  End If
End Function

This Code Snippet works very tricky. Normally 0 / 1 would raise an erro (Division through 0). But Debug Statements are not compiled into the Exe. So the third Line of code would not be proceed and would not raise an error.

Hope that will help you. And show you, that sometimes the solution is not very hard.

Greetings ;-)
0
 
LVL 4

Expert Comment

by:vindevogel
ID: 2618914
d_hottes : 0/1 gives you 0
but, the debug.print trick is interesting.
0
 

Expert Comment

by:d_hottes
ID: 2619032
Oh Sorry I mean 1/0 ;-)
0
 

Author Comment

by:millenisys
ID: 2619413
Simple, but brilliant. Thank you.
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

680 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