What are some possible reasons a VB6 created executable will not run on a machine that does not have VB6 installed?
Said program only has these references: Visual Basic For Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
OLE Automation
As Baka has said, there is probably a support file missing on the target machine. If you run the Package & Deployment Wizard, it will tell you what is needed. The ones you have listed are usually present on most modern machines. One that I have found missing in the past is the Common Dialog Control.
The VB6 runtime is included on newer Windows versions, but that could be an issue on older ones.
If those are the only references (do you have any references in the code that wouldn't appear in the references menu? e.g. APIs, CreateObject, etc), I don't think the problem is a missing dependency. What's the exact error?
Many APIs used.
Perhaps a CreateObject (I will have to check later as I am here on my phone)
2 Forms are supposed to be displayed at startup.
1st form displays as it should,
a MsgBox correctly appears stating "Windows 10",
then app "quitely" shuts down without reporting error, or without displaying 2nd form.
If the first form is displayed, and it displays a MsgBox, then it obviously runs, which contradicts your original post.
What you apparently meant to ask is, what could be the reasons that a VB6 program begins to run on a machine without VB6 installed, and then unexpectedly terminates on its own? And, of course, there are an abundance of potential reasons, very few of which involve VB6 being or not being installed on said machine, and the vast majority of which involve what your code is doing when the program terminates. If you don't know what line of code is running when the program terminates, then you'll have to do something along the lines of adding some sort of debugging code to your program that generates a log file as it runs, writes information about what code is being executed, and see where that log file ends, and that should indicate where in your program the termination is happening.
I am currently doing exactly that; implementing a log file to try and find exactly where the program crashes.
I created risk thread, to find out if there were other reasons that might cause this (on machines without VB)
Then you should have probably been much more clear and detailed in your original post as far as what the exact behavior is, and what you are already doing to try to track down the problem. Hope you get it sorted.
The first 7 files all list on VB6 Support Statement as supported and shipping with Windows.
The next 3 files I assume all ship with Windows.
The last 1 file Project1.exe is my executable.
So am I correct in assuming Project1.exe (on it's own) should run on any Windows machine,
regardless if Visual Basic 6.0 is installed or not?
It should run on any quasi-modern Windows OS, some crazy old OS's like Windows NT 4.0 or Windows 98 didn't include the VB6 required dll files out of the box.
That being said, if you still suspect that the root cause of the issue is tied to one or more files missing, you could use something like Process Monitor, have it capture all events while your program is running, stop capturing events once the problem takes place, and then make use of filtering to only show events stemming from your .exe file, where the result is not Success, and examine any events shown for what look like attempts to access a .dll/.ocx/etc file that couldn't be found.
So I made a minimal project to reproduce the CRASH bug on non-VB machines.
I created and used a RuntimeLog.txt file to help narrow down where/why crashing on non-VB machines.
I determined the cause of crash and it was simply a MsgBox call in my CreateMenuBarForm1 sub.
So all is good ... almost.
If I run the project on a VB-installed machine,
2 MsgBox's first appear, a Splash Screen will display for 5 seconds, another MsgBox displays, and finally Form3 displays atop a Maximized Form1
If I run the exe version of this project on a non-VB machine,
the MsgBox's and Splash Screen appear behind any open Window (should be on top),
and the Splash Screen window appears the correct size, but the bitmap that is displayed, is cut off.
Is someone able to see what the problem might be in the attached project?
I spent the weekend trying to determine the problem, and cannot.
The code is only 14 KB
To speed up applications, MS long ago modified VB to postpone form display until after the form load process was complete. A MsgBox halts program execution until the user responds to the MsgBox. As such MsgBoxs should be avoided in any form load routine, as the timimg will be different between running in the IDE and running an executable.
So, still haven't solved my problem but I've learned 2 things.
1.
If I add the bitmap to Form0 (the Splash Screen) at design time, the bitmap is not "cropped" and displays properly,
but it is not sized the same size as Form0
The bitmap is 431 x 331 pixels, and in Form0's Load Event I do: Me.Width = Screen.TwipsPerPixelX * 431 'must match bmp EXACTLY or white artifact shows
Me.Height = Screen.TwipsPerPixelY * 331 'must match bmp EXACTLY or white artifact shows
2.
If I don't set my app as being DPI Aware via
bAware = SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE)
all is good with my Splash Screen and bitmap, except that Form0 size is 646 x 496 pixels which is 50% larger than the 431 x 331 pixels I set it to.
3.
The "cropped" bitmap issue only happens on a non-VB laptop with a 1920x1080 res screen and a recommended Scale setting of 150%
I tested on non-VB laptop with a 1920x1080 res screen and a recommended Scale setting of 125% and bitmap splash screen is OK
Could this perhaps be a clue as to what the problem is?