Results 1 to 2 of 2

Thread: Which process is using my DLL?

  1. #1

    Thread Starter
    Addicted Member danielkw's Avatar
    Join Date
    Mar 2000
    Location
    Sweden
    Posts
    134

    Question Which process is using my DLL?

    Hi everyone!

    I have a question regarding ActiveX dll:s created in VB. Here is my prototype situation:
    I create a public class called Class1 in my DLL project. I compile my DLL.
    I start a new project and and a reference to my DLL. In frmMain_Load I write:
    Dim x as MyDLL.Class1
    set x = new Class1

    The last line will initiate Class_Initialize in Class1. I want this procedure to be able to find out exactly which process is creating an instance of this class, i.e. I want the DLL to be able to know which EXE (in this case) initiated it.

    ActiveX dlls are in-process servers which probably means that the dll will be able to find out which process it is running in (i.e. the EXE process calling the dll).

    What I am trying to achieve is simply that the DLL will check to see if the calling application has permission to use the dll or not.

    Hope you all understand my situation here and thanks in advance!
    Everyone knows my profile

  2. #2
    Member
    Join Date
    Nov 2002
    Posts
    54

    Re: Which process is using my DLL?

    Hi, try this to get a file name of process owner:

    VB Code:
    1. Private Declare Function GetModuleFileName _
    2.  Lib "kernel32" Alias "GetModuleFileNameA" ( _
    3.  ByVal hModule As Long, _
    4.  ByVal lpFileName As String, _
    5.  ByVal nSize As Long) As Long
    6.  
    7. Private Function GetOwnerFileName() As String
    8.     Dim sFile As String
    9.     Dim nLen As Long
    10.     Const MAX_PATH = 260 As Long
    11.  
    12.     sFile = Space$(MAX_PATH)
    13.     nLen = GetModuleFileName(0, sFile, MAX_PATH)
    14.     GetOwnerFileName = Left$(sFile, nLen)
    15. End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width