Solved

Writing User info to ActiveX DLL

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protecting vb6 & .Net code Obfuscation 18 210
Help me. 3 77
RUNRMTCMD from AS/400 13 126
VBA: copy range dynamically based on config sheet v2 3 60
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

737 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