Force Application.Exit from a DLL?

Fazzyer

Member
Joined
Jul 29, 2005
Messages
16
Programming Experience
5-10
Hi all,

I'm writing a little serial-check DLL for my programs at the moment.
I don't want the program to check if the DLL has found a correct serial; instead, if the serial is incorrect, the DLL should exit (kill) the main-program.

I've tried importing System.Windows.Forms in the DLL and using the Application.Exit-method, but this doesn't work; the main-program ist still executed. :(

A little code for better understanding:
VB.NET:
' Program
Private Sub Form1_Load(...)
    Dim Serial As New DLLSerialCheck.CSerialCheck  
    Serial.CheckSerial()   
    MsgBox("If the serial is wrong, this MsgBox shouldn't be visible, but it is!")
End Sub
 
 
' DLL
Public Sub CheckSerial()
    (...)
    If Not ValidSerial Then System.Windows.Forms.Application.Exit()
    (...)
End Sub

Has anyone an idea or tip how to solve my little problem? Thanx for any help!

- Fazzyer
 
VB.NET:
' DLL
Public Sub CheckSerial()
    (...)
    If Not ValidSerial Then Process.GetCurrentProcess.Kill()
    (...)
End Sub
 
Back
Top