Solved

Writing User info to ActiveX DLL

Posted on 2000-03-14
5
168 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
Comment Utility
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
Comment Utility
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
Comment Utility
d_hottes : 0/1 gives you 0
but, the debug.print trick is interesting.
0
 

Expert Comment

by:d_hottes
Comment Utility
Oh Sorry I mean 1/0 ;-)
0
 

Author Comment

by:millenisys
Comment Utility
Simple, but brilliant. Thank you.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

763 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

10 Experts available now in Live!

Get 1:1 Help Now