|
-
Feb 13th, 2009, 06:43 PM
#1
Thread Starter
Lively Member
Why exe closes for no reason?
Okay, I have this project, and for some reason if I build the exe, it works fine for me, and it works fine for some people, but for some people, it will open fine, but hitting this button or hitting this menu menu to open another window, it just closes... There is no error messages, it just closes?
The only extra ocx file I'M using is the richtxt32.ocx and then a few user controls.
-
Feb 13th, 2009, 06:46 PM
#2
Re: Why exe closes for no reason?
How are you distrbuting the program? Are you just sending them the exe and/or a few files? If so you need to instead create a set of installion files via the P&D Wizard, Inno, or similar and send the output to them.
-
Feb 13th, 2009, 06:51 PM
#3
Thread Starter
Lively Member
Re: Why exe closes for no reason?
Well, I know the person has the runtime files, and everything that they need, it's just it works for some people, and for some people it doesn't. I really don't know how to explain it.
-
Feb 13th, 2009, 06:51 PM
#4
Re: Why exe closes for no reason?
Also if you dont have any error handling in your app then it may not generate an error message.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 13th, 2009, 06:53 PM
#5
Re: Why exe closes for no reason?
Try what I said for one person and see what happens.
-
Feb 13th, 2009, 07:33 PM
#6
Re: Why exe closes for no reason?
I had a problem like that once and it had to do with the order a form load was loading items and running subs. Why it only happened once in a while i still do not know. The hardest part is getting a user to inform you what they were doing when it happened. Luckily my customer was a little computer savy and i ended up giving him a exe with error line numbers in every sub on the form causing the problem. I would at least give the users with a problem a exe with line numbers that write to a log file. I spent a lot of time on this problem and now have went so far as to write error code that automatically emails me the subs name with the error description and line number thru a online jmail and writes to a log file. Thing is now i never get any errors. If you could get a user to tell you what they were doing at least you would have a place to start.
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 14th, 2009, 12:49 AM
#7
Thread Starter
Lively Member
Re: Why exe closes for no reason?
Well, it happens when a user just clicks a button. And all that button is doing is calling one single sub routine...
I don't see any problems with it.
-
Feb 14th, 2009, 01:14 AM
#8
Re: Why exe closes for no reason?
 Originally Posted by JoshHilton
Well, it happens when a user just clicks a button. And all that button is doing is calling one single sub routine...
I don't see any problems with it.
There are other buttons that run subs with no problem ? Post the sub maybe there is something you are missing
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 14th, 2009, 01:41 AM
#9
Thread Starter
Lively Member
Re: Why exe closes for no reason?
There are other buttons and they work fine, but this sub calls about 5 others... then adds the item they find to the list on the main form.
The button calls ScanRooms()
Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function SendMessageSTRING Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Public Function ScanRooms()
'Find Existing rooms first
Dim tmplist As String
For a = 0 To MainForm.channellist.ListCount - 1
If MainForm.channellist.ItemSelected(a) = True Then
tmplist = tmplist & MainForm.channellist.ItemText(a)
End If
Next a
'Clear the list
MainForm.channellist.Clear
DoEvents
'Scan WinMX
Call ScanWinMXWindow
Call ScanMetisWindow
Call ScanRoboWindow
Call ScanOukaWindow
Call ScanRabbitWindow
'Call ScanWinMXPeerWindow
'Apply Previous Selections
Dim tmpsplit() As String
tmpsplit = Split(tmplist, vbCrLf)
For a = 0 To UBound(tmpsplit)
For B = 0 To MainForm.channellist.ListCount - 1
If MainForm.channellist.ItemText(B) = tmpsplit(a) Then
MainForm.channellist.ItemSelected(B) = True
End If
Next B
Next a
End Function
Sub ScanWinMXWindow()
Dim Top As Long
Top = FindWindowEx(0, 0, vbNullString, vbNullString)
While (Top <> 0)
Dim Title As String
Title = Space(100)
Ret = GetWindowText(Top, Title, 100)
Title = Left(Title, Ret)
If (Ret > 0 And InStr(Title, "WinMX v3.")) Then
Dim Inner As Long
Inner = FindWindowEx(Top, 0, vbNullString, vbNullString)
While (Inner <> 0)
Title = Space(100)
Ret = GetWindowText(Inner, Title, 100)
If (Ret > 0 And InStr(Title, "on WinMX Peer Network")) Then
Title = Left(Title, Ret)
MainForm.channellist.AddItem Left(Title, Len(Title) - 22)
End If
Inner = FindWindowEx(Top, Inner, vbNullString, vbNullString)
Wend
End If
Top = FindWindowEx(0, Top, vbNullString, vbNullString)
Wend
End Sub
Sub ScanMetisWindow()
Dim Top As Long
Dim Ret As Long
Dim Title As String
Top = FindWindowEx(0, 0, vbNullString, vbNullString)
While (Top <> 0)
Title = Space(300)
Ret = GetWindowText(Top, Title, 300)
If InStr(Title, "Metis") Then
Dim Inner As Long
Inner = FindWindowEx(Top, 0, vbNullString, vbNullString)
While (Inner <> 0)
Title = Space(100)
Ret = GetClassName(Inner, Title, 100)
If InStr(Title, "MDIClient") Then
Dim Inner2 As Long
Inner2 = FindWindowEx(Inner, 0, vbNullString, vbNullString)
While (Inner2 <> 0)
Title = Space(100)
Ret = GetWindowText(Inner2, Title, 100)
If InStr(Title, "(") Then
Dim ChannelName As String
ChannelName = Split(Title, " (")(0)
'MsgBox ChannelName 'CHANNEL NAME HERE
MainForm.channellist.AddItem (ChannelName)
End If
Inner2 = FindWindowEx(Inner, Inner2, vbNullString, vbNullString)
Wend
End If
Inner = FindWindowEx(Top, Inner, vbNullString, vbNullString)
Wend
End If
Top = FindWindowEx(0, Top, vbNullString, vbNullString)
Wend
End Sub
Sub ScanRoboWindow()
Dim Top As Long
Dim Ret As Long
Dim Title As String
Top = FindWindowEx(0, 0, vbNullString, vbNullString)
While (Top <> 0)
Title = Space(300)
Ret = GetWindowText(Top, Title, 300)
If InStr(Title, "Robo") Then
Dim Inner As Long
Inner = FindWindowEx(Top, 0, vbNullString, vbNullString)
While (Inner <> 0)
Title = Space(100)
Ret = GetClassName(Inner, Title, 100)
If InStr(Title, "MDIClient") Then
Dim Inner2 As Long
Inner2 = FindWindowEx(Inner, 0, vbNullString, vbNullString)
While (Inner2 <> 0)
Title = Space(100)
Ret = GetWindowText(Inner2, Title, 100)
If InStr(Title, "(") Then
Dim ChannelName As String
ChannelName = Split(Title, " (")(0)
'MsgBox ChannelName 'CHANNEL NAME HERE
MainForm.channellist.AddItem (ChannelName)
End If
Inner2 = FindWindowEx(Inner, Inner2, vbNullString, vbNullString)
Wend
End If
Inner = FindWindowEx(Top, Inner, vbNullString, vbNullString)
Wend
End If
Top = FindWindowEx(0, Top, vbNullString, vbNullString)
Wend
End Sub
Sub ScanOukaWindow()
Dim Top As Long
Top = FindWindowEx(0, 0, vbNullString, vbNullString)
While (Top <> 0)
Dim Title As String
Title = Space(100)
Ret = GetWindowText(Top, Title, 100)
Title = Left(Title, Ret)
' If (Ret > 0 And InStr(title, "WinMX v3.")) Then
If (Ret > 0 And InStr(Title, "Ouka Chat Client")) Then
Dim Inner As Long
Inner = FindWindowEx(Top, 0, vbNullString, vbNullString)
While (Inner <> 0)
Title = Space(100)
Ret = GetClassName(Inner, Title, 100)
If InStr(Title, "MDIClient") Then
Dim InnerChat As Long
InnerChat = FindWindowEx(Inner, 0, vbNullString, vbNullString)
While (InnerChat <> 0)
Title = Space(100)
Ret = GetClassName(InnerChat, Title, 100)
If InStr(Title, "MDICHAT") Then
Dim ChannelName As String * 100
Ret = GetWindowText(InnerChat, ChannelName, 100)
MainForm.channellist.AddItem (ChannelName)
End If
InnerChat = FindWindowEx(Inner, InnerChat, vbNullString, vbNullString)
Wend
End If
Inner = FindWindowEx(Top, Inner, vbNullString, vbNullString)
Wend
'MsgBox Top
End If
Top = FindWindowEx(0, Top, vbNullString, vbNullString)
Wend
End Sub
Sub ScanRabbitWindow()
Dim Top As Long
Dim Ret As Long
Dim Title As String
Top = FindWindowEx(0, 0, vbNullString, vbNullString)
While (Top <> 0)
Title = Space(100)
Ret = GetWindowText(Top, Title, 100)
If InStr(Title, "Rabbit v1.3") Then
Dim Inner As Long
Inner = FindWindowEx(Top, 0, vbNullString, vbNullString)
While (Inner <> 0)
Title = Space(100)
Ret = GetClassName(Inner, Title, 100)
If InStr(Title, "MDIClient") Then
Dim Inner2 As Long
Inner2 = FindWindowEx(Inner, 0, "WPNCLIENT", vbNullString)
While (Inner2 <> 0)
Title = Space(100)
Ret = GetClassName(Inner2, Title, 100)
'Found Channel Name here
Dim ChannelName As String * 100
Ret = GetWindowText(Inner2, ChannelName, 100)
MainForm.channellist.AddItem (ChannelName)
Inner2 = FindWindowEx(Inner, Inner2, "WPNCLIENT", vbNullString)
Wend
End If
Inner = FindWindowEx(Top, Inner, vbNullString, vbNullString)
Wend
End If
Top = FindWindowEx(0, Top, vbNullString, vbNullString)
Wend
End Sub
Last edited by JoshHilton; Feb 14th, 2009 at 01:50 AM.
-
Feb 14th, 2009, 02:00 AM
#10
Re: Why exe closes for no reason?
 Originally Posted by JoshHilton
There are other buttons and they work fine, but this sub calls about 5 others... then adds the item they find to the list on the main form.
The button calls ScanRooms()
Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function SendMessageSTRING Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Public Function ScanRooms()
'Find Existing rooms first
Dim tmplist As String
For a = 0 To MainForm.channellist.ListCount - 1
If MainForm.channellist.ItemSelected(a) = True Then
tmplist = tmplist & MainForm.channellist.ItemText(a)
End If
Next a
'Clear the list
MainForm.channellist.Clear
DoEvents
'Scan WinMX
Call ScanWinMXWindow
Call ScanMetisWindow
Call ScanRoboWindow
Call ScanOukaWindow
Call ScanRabbitWindow
'Call ScanWinMXPeerWindow
'Apply Previous Selections
Dim tmpsplit() As String
tmpsplit = Split(tmplist, vbCrLf)
For a = 0 To UBound(tmpsplit)
For B = 0 To MainForm.channellist.ListCount - 1
If MainForm.channellist.ItemText(B) = tmpsplit(a) Then
MainForm.channellist.ItemSelected(B) = True
End If
Next B
Next a
End Function
Sub ScanWinMXWindow()
Dim Top As Long
Top = FindWindowEx(0, 0, vbNullString, vbNullString)
While (Top <> 0)
Dim Title As String
Title = Space(100)
Ret = GetWindowText(Top, Title, 100)
Title = Left(Title, Ret)
If (Ret > 0 And InStr(Title, "WinMX v3.")) Then
Dim Inner As Long
Inner = FindWindowEx(Top, 0, vbNullString, vbNullString)
While (Inner <> 0)
Title = Space(100)
Ret = GetWindowText(Inner, Title, 100)
If (Ret > 0 And InStr(Title, "on WinMX Peer Network")) Then
Title = Left(Title, Ret)
MainForm.channellist.AddItem Left(Title, Len(Title) - 22)
End If
Inner = FindWindowEx(Top, Inner, vbNullString, vbNullString)
Wend
End If
Top = FindWindowEx(0, Top, vbNullString, vbNullString)
Wend
End Sub
Sub ScanMetisWindow()
Dim Top As Long
Dim Ret As Long
Dim Title As String
Top = FindWindowEx(0, 0, vbNullString, vbNullString)
While (Top <> 0)
Title = Space(300)
Ret = GetWindowText(Top, Title, 300)
If InStr(Title, "Metis") Then
Dim Inner As Long
Inner = FindWindowEx(Top, 0, vbNullString, vbNullString)
While (Inner <> 0)
Title = Space(100)
Ret = GetClassName(Inner, Title, 100)
If InStr(Title, "MDIClient") Then
Dim Inner2 As Long
Inner2 = FindWindowEx(Inner, 0, vbNullString, vbNullString)
While (Inner2 <> 0)
Title = Space(100)
Ret = GetWindowText(Inner2, Title, 100)
If InStr(Title, "(") Then
Dim ChannelName As String
ChannelName = Split(Title, " (")(0)
'MsgBox ChannelName 'CHANNEL NAME HERE
MainForm.channellist.AddItem (ChannelName)
End If
Inner2 = FindWindowEx(Inner, Inner2, vbNullString, vbNullString)
Wend
End If
Inner = FindWindowEx(Top, Inner, vbNullString, vbNullString)
Wend
End If
Top = FindWindowEx(0, Top, vbNullString, vbNullString)
Wend
End Sub
Sub ScanRoboWindow()
Dim Top As Long
Dim Ret As Long
Dim Title As String
Top = FindWindowEx(0, 0, vbNullString, vbNullString)
While (Top <> 0)
Title = Space(300)
Ret = GetWindowText(Top, Title, 300)
If InStr(Title, "Robo") Then
Dim Inner As Long
Inner = FindWindowEx(Top, 0, vbNullString, vbNullString)
While (Inner <> 0)
Title = Space(100)
Ret = GetClassName(Inner, Title, 100)
If InStr(Title, "MDIClient") Then
Dim Inner2 As Long
Inner2 = FindWindowEx(Inner, 0, vbNullString, vbNullString)
While (Inner2 <> 0)
Title = Space(100)
Ret = GetWindowText(Inner2, Title, 100)
If InStr(Title, "(") Then
Dim ChannelName As String
ChannelName = Split(Title, " (")(0)
'MsgBox ChannelName 'CHANNEL NAME HERE
MainForm.channellist.AddItem (ChannelName)
End If
Inner2 = FindWindowEx(Inner, Inner2, vbNullString, vbNullString)
Wend
End If
Inner = FindWindowEx(Top, Inner, vbNullString, vbNullString)
Wend
End If
Top = FindWindowEx(0, Top, vbNullString, vbNullString)
Wend
End Sub
Sub ScanOukaWindow()
Dim Top As Long
Top = FindWindowEx(0, 0, vbNullString, vbNullString)
While (Top <> 0)
Dim Title As String
Title = Space(100)
Ret = GetWindowText(Top, Title, 100)
Title = Left(Title, Ret)
' If (Ret > 0 And InStr(title, "WinMX v3.")) Then
If (Ret > 0 And InStr(Title, "Ouka Chat Client")) Then
Dim Inner As Long
Inner = FindWindowEx(Top, 0, vbNullString, vbNullString)
While (Inner <> 0)
Title = Space(100)
Ret = GetClassName(Inner, Title, 100)
If InStr(Title, "MDIClient") Then
Dim InnerChat As Long
InnerChat = FindWindowEx(Inner, 0, vbNullString, vbNullString)
While (InnerChat <> 0)
Title = Space(100)
Ret = GetClassName(InnerChat, Title, 100)
If InStr(Title, "MDICHAT") Then
Dim ChannelName As String * 100
Ret = GetWindowText(InnerChat, ChannelName, 100)
MainForm.channellist.AddItem (ChannelName)
End If
InnerChat = FindWindowEx(Inner, InnerChat, vbNullString, vbNullString)
Wend
End If
Inner = FindWindowEx(Top, Inner, vbNullString, vbNullString)
Wend
'MsgBox Top
End If
Top = FindWindowEx(0, Top, vbNullString, vbNullString)
Wend
End Sub
Sub ScanRabbitWindow()
Dim Top As Long
Dim Ret As Long
Dim Title As String
Top = FindWindowEx(0, 0, vbNullString, vbNullString)
While (Top <> 0)
Title = Space(100)
Ret = GetWindowText(Top, Title, 100)
If InStr(Title, "Rabbit v1.3") Then
Dim Inner As Long
Inner = FindWindowEx(Top, 0, vbNullString, vbNullString)
While (Inner <> 0)
Title = Space(100)
Ret = GetClassName(Inner, Title, 100)
If InStr(Title, "MDIClient") Then
Dim Inner2 As Long
Inner2 = FindWindowEx(Inner, 0, "WPNCLIENT", vbNullString)
While (Inner2 <> 0)
Title = Space(100)
Ret = GetClassName(Inner2, Title, 100)
'Found Channel Name here
Dim ChannelName As String * 100
Ret = GetWindowText(Inner2, ChannelName, 100)
MainForm.channellist.AddItem (ChannelName)
Inner2 = FindWindowEx(Inner, Inner2, "WPNCLIENT", vbNullString)
Wend
End If
Inner = FindWindowEx(Top, Inner, vbNullString, vbNullString)
Wend
End If
Top = FindWindowEx(0, Top, vbNullString, vbNullString)
Wend
End Sub
I would not call that one single sub routine. You need to write error handlers
on all those subroutines. With no error handlers it could be anywhere
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 15th, 2009, 10:34 PM
#11
Thread Starter
Lively Member
Re: Why exe closes for no reason?
Well, wouldn't any errors just trigger a runtime error/other that you always get...
-
Feb 15th, 2009, 11:21 PM
#12
Re: Why exe closes for no reason?
 Originally Posted by JoshHilton
Well, wouldn't any errors just trigger a runtime error/other that you always get...
No.
And even if they did, how are you going to know what error they trigger? You need to write code that traps errors and tells you what they are. I would even go so far as to program in a debug mode. Plus you should set your compile options to include line numbers, etc.
As you are using api calls though i am willing to bet one of them is the culprit. You are reading the handle to a window and it's not finding the window then posting a message to a non existing window or something like that.
Probably the simplest thing you can do for now is to make a small change to your code like this:
Code:
open "debug.txt" for output as #1
call ScanWinMXWindow: print #1, "a"
Call ScanMetisWindow: print #1, "b"
Call ScanRoboWindow: print #1, "c"
Call ScanOukaWindow: print #1, "d"
Call ScanRabbitWindow: print #1, "e"
Call ScanWinMXPeerWindow: print #1,"f"
close #1
this will make a debug file that is telling you which sub is crashing the program. For example if the file says a b c d then you know scanrabbitwindow did not work.
-
Feb 16th, 2009, 02:12 AM
#13
Re: Why exe closes for no reason?
should open and close the output file as append file, for each time you print, if the program crashes the file will not be closed correctly
proper error handling is essential
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 16th, 2009, 07:09 AM
#14
Re: Why exe closes for no reason?
i opened it as output so it would be overwritten upon open. it "should" close the file handles when it crashes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|