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
Printable View
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
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 ?
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.
Why don't you just pass a reference to the form object instead of the application title???
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...
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)
If I run GetModuleFileName within the dll, it returns the name of the dll, not the application that invoked the dll.
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 ?
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.