Solved

Writing User info to ActiveX DLL

Posted on 2000-03-14
5
169 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LINQ return type for nested group query 6 71
DO Loop not working 4 72
VBA color chart bars 12 77
Reading the Contents of a Directory In Access VBA 5 58
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now