Home All Groups Group Topic Archive Search About

Terminate a called DLL from within the DLL

Author
6 Jul 2005 12:58 AM
Larry
In VB 6, I am calling an in house written DLL,
when in the DLL I detect a serious problem, I want to
terminate the execution of the DLL.

I have tried to unload the form in the DLL, it has only -
one form, but it doesn't do any good, the code (in the DLL) keeps
getting executed.

Thanks for any help you can give me,

Laurence Nuttall
Programmer Analyst III
UCLA - Division of Continuing Education

Author
6 Jul 2005 1:43 AM
Ralph
Show quote Hide quote
"Larry" <bl***@Blifff.com> wrote in message
news:%236528WcgFHA.3316@TK2MSFTNGP14.phx.gbl...
> In VB 6, I am calling an in house written DLL,
> when in the DLL I detect a serious problem, I want to
> terminate the execution of the DLL.
>
> I have tried to unload the form in the DLL, it has only -
> one form, but it doesn't do any good, the code (in the DLL) keeps
> getting executed.
>
> Thanks for any help you can give me,
>
> Laurence Nuttall
> Programmer Analyst III
> UCLA - Division of Continuing Education
>

One could do some guessing, but it would be better if you supplied a bit
more detail.

What is this DLL? Regular DLL? (Probably not as it has a 'Form' in it.)
ActiveX DLL - right? Compiled/created with what?
What do you mean by "terminate the execution"? Kill it while it is running?
Moving it from memory when not needed? ... ?
What's executing? Some code called by a process in the form? Something
called from elsewhere?

In the meantime, best guess, you have left a reference to something behind.
Author
6 Jul 2005 3:55 PM
Larry
It is an active X DLL created using VB 6, Written
in house here.

I want to stop the execution of the application,
the VB 6 application that called the DLL.

The application is executing, and then when the
application calls the DLL, code in the DLL is then executing.

'------

Ralph wrote:
Show quoteHide quote
> "Larry" <bl***@Blifff.com> wrote in message
> news:%236528WcgFHA.3316@TK2MSFTNGP14.phx.gbl...
>
>>In VB 6, I am calling an in house written DLL,
>>when in the DLL I detect a serious problem, I want to
>>terminate the execution of the DLL.
>>
>>I have tried to unload the form in the DLL, it has only -
>>one form, but it doesn't do any good, the code (in the DLL) keeps
>>getting executed.
>>
>>Thanks for any help you can give me,
>>
>>Laurence Nuttall
>>Programmer Analyst III
>>UCLA - Division of Continuing Education
>>
>
>
> One could do some guessing, but it would be better if you supplied a bit
> more detail.
>
> What is this DLL? Regular DLL? (Probably not as it has a 'Form' in it.)
> ActiveX DLL - right? Compiled/created with what?
> What do you mean by "terminate the execution"? Kill it while it is running?
> Moving it from memory when not needed? ... ?
> What's executing? Some code called by a process in the form? Something
> called from elsewhere?
>
> In the meantime, best guess, you have left a reference to something behind.
>
>
Author
6 Jul 2005 3:41 AM
Michael C
"Larry" <bl***@Blifff.com> wrote in message
news:%236528WcgFHA.3316@TK2MSFTNGP14.phx.gbl...
> In VB 6, I am calling an in house written DLL,
> when in the DLL I detect a serious problem, I want to
> terminate the execution of the DLL.
>
> I have tried to unload the form in the DLL, it has only -
> one form, but it doesn't do any good, the code (in the DLL) keeps getting
> executed.
>
> Thanks for any help you can give me,

If (SeriousCondition) then exit sub?


Show quoteHide quote
>
> Laurence Nuttall
> Programmer Analyst III
> UCLA - Division of Continuing Education
>
>
>
>
>
Author
6 Jul 2005 3:58 PM
Larry
Exit Sub only exits the currently running procedure
in the DLL. I want to stop the DLL from executing
and the vb 6 application that called it.

I can make the executing Thread exit the DLL
but then it just goes back to the calling VB app
and continues.

Michael C wrote:
Show quoteHide quote
> "Larry" <bl***@Blifff.com> wrote in message
> news:%236528WcgFHA.3316@TK2MSFTNGP14.phx.gbl...
>
>>In VB 6, I am calling an in house written DLL,
>>when in the DLL I detect a serious problem, I want to
>>terminate the execution of the DLL.
>>
>>I have tried to unload the form in the DLL, it has only -
>>one form, but it doesn't do any good, the code (in the DLL) keeps getting
>>executed.
>>
>>Thanks for any help you can give me,
>
>
> If (SeriousCondition) then exit sub?
>
>
>
>>Laurence Nuttall
>>Programmer Analyst III
>>UCLA - Division of Continuing Education
>>
>>
>>
>>
>>
>
>
>
Author
6 Jul 2005 4:22 PM
Ken Halter
"Larry" <bl***@Blifff.com> wrote in message
news:eyPg0NkgFHA.3940@tk2msftngp13.phx.gbl...
> Exit Sub only exits the currently running procedure
> in the DLL. I want to stop the DLL from executing
> and the vb 6 application that called it.
>
> I can make the executing Thread exit the DLL
> but then it just goes back to the calling VB app
> and continues.

About the best you can do... and still be "compliant", is to raise an error.
Similar to trying to use a control that's not licensed. All it does is raise
an Error 429 in its Initialize event. That causes the component to never
"come to life". The calling app can trap the error and take action.

ActiveX Component Standards and Guidelines
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconolecomponentstandardsguidelines.asp

ActiveX Component Shutdown
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconolecomponentshutdown.asp

Visual Basic Component Shutdown Rules
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconvisualbasiccomponentshutdownrules.asp

Trying to force a DLL to shut itself down can get tricky. Especially if the
calling app's not yours. To, basically, rip it out of ram, would leave
references behind in the calling app and it would probably take the task
manager's End Task button to shut the caller down. imo, the best way would
be to define an error code that the caller can watch for. If it gets the
error, release the reference to the DLL and it should "die" on its own.

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Please keep all discussions in the groups..