CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: dll question

  1. #1
    Join Date
    Jun 2001
    Location
    Michigan
    Posts
    2,222

    dll question

    In a vb 6.0 dll how can I find the App.Title of the calling application (the application that invoked the dll).

    App.Title only gives me the title of the dll. Do I have to pass this is in as a param or is there a better way?

    Thanks

  2. #2
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: dll question

    From inside the DLL code ? what kind of DLL is this ?

    By title, you meant the main form's Caption (text on the title bar), right ?
    Regards,
    Ramkrishna Pawar

  3. #3
    Join Date
    Jun 2001
    Location
    Michigan
    Posts
    2,222

    Re: dll question

    This is what is happening.

    1) We have a stand alone COM exe that runs.

    2) Usually an application invokes the COM to do its work. When the application invokes the COM exe it passes in the application name (App.Title).

    3) The COM exe has a timer that runs to check if the "application name" window still exists using FindWindow(). If it does not exist it shuts itself down to avoid a hung process.

    4) The problem is that if this COM exe is invoked using a dll, the dll passes in the dll application name, the COM timer does not find that window and so shuts down prematurely.

    5) So I need the DLL to be able to pass in the application name of the application that invoked the DLL, not of the DLL itself.

    Thanks for any help.
    Last edited by bluesource; February 19th, 2007 at 12:16 PM.

  4. #4
    Join Date
    Oct 2003
    Location
    Merate-North Italy
    Posts
    230

    Re: dll question

    Why don't you just pass a reference to the form object instead of the application title???
    ++++++++[>++++++++<-]>+.<+++[>++++<-]>+.<++[>-----<-]>.<+++[>++++<-]>++.<+++[>----<-]>-.----.
    God does not play dice with the universe.(A.Einstein)

  5. #5
    Join Date
    Jun 2001
    Location
    Michigan
    Posts
    2,222

    Re: dll question

    The form is a part of the dll and a reference to it is passed into the COM exe, but the COM exe is using FindWindow with the application name to see if it exists.

    Unfortunately modifying the COM exe is not an option, it presents too many compatibilty issues and considered too much work for the nature of this "hot fix".

    To think how much code in our system should be re-written and how much was developed with poor coding standards gives me the chills...

  6. #6
    Join Date
    Mar 2002
    Location
    Izhevsk, Udmurtia, Russia
    Posts
    930

    Re: dll question

    Code:
    Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" _
          (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
    ...
    Dim sFilename As String, i As Long
    sFilename = String(256, " ")
    i = GetModuleFileName(0, sFilename, 256)
    sFilename = Left(sFilename, i)
    With best wishes,
    Vita
    -----------------------
    Russian Software Development Network -- http://www.rsdn.ru

  7. #7
    Join Date
    Jun 2001
    Location
    Michigan
    Posts
    2,222

    Re: dll question

    If I run GetModuleFileName within the dll, it returns the name of the dll, not the application that invoked the dll.

  8. #8
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: dll question

    I think there is some confusion, as far as I know GetModuleFileName gives you name of the Executable used to create process, not the current module name.

    What kind of DLL is this ?

    Another thing is that the Executable name and App.Title is not the same thing, can you explain what you want to achieve by doing all this ?
    Regards,
    Ramkrishna Pawar

  9. #9
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487

    Re: dll question

    why pass the app.title when there is the form's handle/caption?

    if you used the form's handle you would have been using the IsWindow API function inside the COM exe to check if the window exists.
    Last edited by Thread1; February 20th, 2007 at 09:37 PM.
    Busy

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

Featured