Solved

Writing User info to ActiveX DLL

Posted on 2000-03-14
5
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: 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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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