Solved

Simple VB Program Missing Files Needed to Run on Other PCs

Posted on 2002-05-18
34
293 Views
Last Modified: 2012-05-04
Hi.

Oh, a month or so ago I finished, or so I thought, a simple Visual Basic 6 program which, when the CD is placed into a CD drive (autorun/autoplay settings set in Windows), this program starts up. Once again, as I am discovering as a VB newbie, it only works on my machine.

This program has one Form and on this Form is the Windows Media Player control. The program starts and it plays Billy Joel's "Lullaby" as the Form has its picture property set to a picture of my brother's and his wife's new son. One can stop playing this and resume playing this (after a few times, it would get tiring). Once the 'Stop' command button is clicked, a message box displays with vbOkOnly and then that is clicked and the Forms unload event is coded as such as to bring up Windows Explorer into the CD drive, whereby my brother can look through a large archive of family photographs, GIFs, JPEGs, MPEGs and so on.

This is not a complex application.

Now, I had the CD all labeled and I brought it to work and tried it on an NT machine, before I give it to brother, I want to make sure it works. Much to my chagrin and dismay, I got the following, cryptic error message:

Automation Error:Unspecified Error.

I tried it on a 2 different PCs with Windows 2000 installed on them.

The same cryptic error message ocurred on them as on the NT machine. And, of course, the application crashes in flames.

Now, I just love error messages like these. Obviously, I need to include a DLL or some run-time file or something in order for this to work on bro's PC (I think he still runs Windows95).

Could anyone please offer some suggestions here?
I am finally going to meet my new 2 1/2 month old nephew during the Memorial Day weekend - next weekend.
I'd like to be able to give this to them. I think it's sort of a cool bit a family memorabilia to give to them, providing it works the way I want it to work.

Jim
0
Comment
Question by:jnowlin
  • 11
  • 8
  • 7
  • +5
34 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 7018529
did you use package and deployment wizard to create a setup package?
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 7018604
YOu cannot simply copy the EXE fro a VB program, and have it run on another PC, which does not already have VB installed.  as bobbit31 suggests, in order to run a program createdwith VB on another PC, the program must be "INSTALLED", which is to say,that allof the support DLLS which are needed by VB in order to run, MUST be copied to the target PC,and registered in the system registry on that target PC.  This is the case even with what you be call a "very simpl" program, because under the covers, VB uses a great deal of rather sophisticated code, in order to allow your "very simple" program to run.  YOu will find the Package and Deployment Wizard in the VB directory on your PC, or youshould be able to access it from with the VB IDE, under the Add Ins menu item on the menu bar.
0
 
LVL 2

Expert Comment

by:woka
ID: 7019124
You could try putting the MSVBVM60.DLL and the media player OCX in the same folder as your .EXE on the CD.  Not sure if it will work, but I've had success using this with a simle VB5 app that had no other dependencies.
0
 
LVL 4

Expert Comment

by:mcoop
ID: 7019204
He already has media player - and probably some other dependencies.  There is a small chance - but very unreliable way of sharing a compiled app.
0
 
LVL 17

Expert Comment

by:inthedark
ID: 7019373
If you have visual studio you should use c++ and use the Project Wizard to create a sample Win32 App. It will run without the need for a dll.

You can then build in the links you need to readme files, a VB setup, created with the Package and Deployment Wizard, etc.

0
 
LVL 18

Expert Comment

by:Crash2100
ID: 7019718
You can use a program like fusion to recompile your program to include the code in the drivers so all you need is the exe.

BitArts Fusion
http://www.bit-arts.com/fusion.html
0
 

Author Comment

by:jnowlin
ID: 7019812
No, I didn't use the P & D Wizard with this. I merely had an idea to do this, not realizing that it cannot be done this way, unless I try Crash2100's suggestion using Fusion. I'm not terribly thrilled with the P&D, as evidenced by another question I've posted.
inthedark's suggestion may be too involved. I *did* have VC++ 6 at one time. I don't know if I still have it. I know I don't have it installed at present.

So, it appears that I need to re-write this app so that a Setup.exe runs once the CD is inserted and then after setup completes, run the app. Unless of course Fusion works.
JN
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 7021027
Just a suggestion:
How about having the required run-time files in your CD project directory, and running from it, instead of running the SETUP and then running the program.

Im not sure though, if you'd have to register any components to run the app.

Cheers
0
 

Author Comment

by:jnowlin
ID: 7021428
I'm not sure valli_an. I could give it a try - if I could remember how many run-time files are needed. Yesterday, I tried 'Crash2100's BitArts Fusion. It's a nice program, a good idea. It didn't work. My guess is that the full, paid for version would work. I caved in and made a Setup program. It worked, but, I rarely get what I think is a good idea. I had HIGH HOPES I could do it the way I was trying to do it. After, all, hearing 2 .WAV files back to back would get tiresome in a short period of time. Who would want that installed on their PC, even if it's a (well-liked) family member?
;)

I get time off this week from my job so I'll give yours/'woka's way a try. I need some more CD-RW discs first.

Jim
PS
If there's anyone here who knows anything about P&Ding a Sybase Adaptive Server AnyWhere database using VB DataEnvironment Designer, there's another annoying problem I've been having with that and I'm off to increase the amount of points. It's either that or it's a PowerBuilder posting I must do.
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7021575
if you want, i can post code that will automatically register any required dlls/ocxs that the computer may need. This would run on the first run of the program.
0
 

Author Comment

by:jnowlin
ID: 7022447
Well bobbit31,

it may worth a look. As I said, this is a family thing. It's something that would be viewed a few times. It is not something that I need to work on hundreds of PCs, just one or two.
JNowlin
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 250 total points
ID: 7022503
put this in a module:

Public Declare Function GetProcAddress _
   Lib "kernel32" _
   (ByVal hModule As Long, _
    ByVal lpProcName As String) _
   As Long

Public Declare Function LoadLibrary _
    Lib "kernel32" Alias "LoadLibraryA" _
    (ByVal lpLibFileName As String) As Long

Public Declare Function CreateThread Lib "kernel32" _
(lpThreadAttributes As Long, ByVal dwStackSize As Long, _
lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, _
lpThreadId As Long) As Long

Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public Declare Function GetExitCodeThread Lib "kernel32" (ByVal hThread As Long, lpExitCode As Long) As Long
Public Declare Sub ExitThread Lib "kernel32" (ByVal dwExitCode As Long)
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long

Sub Main()

    Screen.MousePointer = vbHourglass
   
    '' copy dependencies to system folder (these are just examples)
    copyToSystem("MSVBVM60.DLL")
    copyToSystem("MCI32.OCX")

    '' register the dlls/ocxs that need registering
    VBRegSvr32 ("C:\windows\system\msvbvm60.dll")
    VBRegSvr32 ("C:\windows\system\mci32.ocx")
   
    Screen.MousePointer = vbDefault

    Form1.Show '' show your form
end sub

Private Sub copyToSystem(strPath As String, strFile As String)

    '' if your system folder will vary (ie, win xp or nt or 2000) i'll post code to check
    if dir("C:\windows\system\" & strFile) = "" then '' the file doesn't exist
     FileCopy strPath & strFile, "C:\windows\system\" & strFile
    end if

End Sub

Function VBRegSvr32(ByVal sServerPath As String, _
                                           Optional fRegister = True) As Boolean
Dim hMod As Long            ' module handle
Dim lpfn As Long            ' reg/unreg function address
Dim lpThreadId As Long      ' dummy var that get's filled
Dim hThread As Long         ' thread handle
Dim fSuccess As Boolean     ' if things worked
Dim dwExitCode As Long      ' thread's exit code if it doesn't finish

    Screen.MousePointer = vbHourglass

    ' Load the server into memeory
    hMod = LoadLibrary(sServerPath)
       
    ' Get the specified function's address and our msgbox string.
    If fRegister Then
        lpfn = GetProcAddress(hMod, "DllRegisterServer")
    Else
        lpfn = GetProcAddress(hMod, "DllUnregisterServer")
    End If
     
    ' If we got a function address...
    If lpfn Then
        ' Create an alive thread and execute the function.
        hThread = CreateThread(ByVal 0, 0, ByVal lpfn, ByVal 0, 0, lpThreadId)
         
        ' If we got the thread handle...
        If hThread Then
            ' Wait 10 secs for the thread to finish (the function may take a while...)
            fSuccess = (WaitForSingleObject(hThread, 10000) = WAIT_OBJECT_0)
           
            ' If it didn't finish in 5 seconds...
            If Not fSuccess Then
                ' Something unlikely happened, lose the thread.
                Call GetExitCodeThread(hThread, dwExitCode)
                Call ExitThread(dwExitCode)
            End If
     
        ' Lose the thread handle
        Call CloseHandle(hThread)
        End If   ' hThread
    End If   ' lpfn
     
    ' Free server if we loaded it.
    If hMod Then Call FreeLibrary(hMod)
     
    Screen.MousePointer = vbDefault
     
    If fSuccess Then
        VBRegSvr32 = True
    Else
        MsgBox ("Error: " & sServerPath)
        VBRegSvr32 = False
    End If
   
End Function

under project/properties change the startup object to sub main

0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 7023128
Another option, is to do your presentation in Powerpoint, then choose Pack & Go, include the Powerpoint Viewer along with it, the easier and no hastles way I suppose.

In your CD, make it to run this presentation automatically.

Cheers.
0
 
LVL 17

Expert Comment

by:inthedark
ID: 7023242
valli_an's solution is simple, or create your app using HTML is simple to, put the cd in then up-comes your pics.

Crash2100, this Fusion stuff I have been promising myself that I would buy it. Do you use it? Does it work?

0
 
LVL 18

Expert Comment

by:Crash2100
ID: 7024313
I've used an older version of fusion several times, and it seems to work very well.  It does an amazing job of compressing the exe and all the programs I've made with it were small enough to fit on a single floppy disk.

It's very simple and straight foreward.  Probabbly the hardest thing to do is to figure out what drivers you need to include in your program.
0
 

Author Comment

by:jnowlin
ID: 7029734
"How about having the required run-time files in your CD project directory, and running from it, instead
of running the SETUP and then running the program."

I copied MS VB Virtual Machine, MSVBVM60.DLL, and what looks to be the Media Player DirectX/ActiveX file, MSDXM.OCX into the CD's root folder with the program. I then tried it on my Windows 2000 Server and it started and played.
I won't know if this will work until I try it on my brother's PC.

0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7030154
typically, these files have to be registered using some setup package or regsvr32 (which is basically what my routine above does)... However, there was once a lengthy discussion very similar to this where the user also got it to work by just having the dependencies in the project directory.  I haven't tried it, but theorhetically it SHOULD NOT work.  In that other thread, it seemed to work for him, which baffled many of the experts in that thread.  Please let us know if it works for you.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 18

Expert Comment

by:bobbit31
ID: 7030160
btw: have you tried the code i provided above??? all you have to do is cut and copy it and make your startup object Sub Main and have the dependencies in your project dir.
0
 
LVL 2

Expert Comment

by:woka
ID: 7030678
With regard to having unregistered dependencies files in the same folder as the dependent exe, it does work and is documented.  See MSKB article Q129943.

The only time this will not work is if there are recurring dependencies (of the dll or ocx being referenced) that are not present in the search path or are a different version with an incompatible interface.
0
 
LVL 2

Expert Comment

by:woka
ID: 7030715
With regard to having unregistered dependencies files in the same folder as the dependent exe, it does work and is documented.  See MSKB article Q129943.

The only time this will not work is if there are recurring dependencies (of the dll or ocx being referenced) that are not present in the search path or are a different version with an incompatible interface.
0
 

Author Comment

by:jnowlin
ID: 7032020
If I had only kept my Windows95 and 98 CDs, I could have set up a second PC to see if it would work.
Oh, well. "No use crying over spilt milk."

No bobbit31, I haven't had a chance yet to try the code you've included in an earlier thread. Hopefull, I'll give it a try this weekend.

woka, Q129943?

Jim Nowlin
0
 

Author Comment

by:jnowlin
ID: 7032081
MSKB Q129943 seems to say that *both* registered and unregistered OLE controls will work:

Q129943:
SUMMARY
OLE Controls (.OCX files) are OLE servers, so they must be listed in the registry. Visual Basic applications require an installation process to ensure that the necessary items are properly registered. During the setup process, if an OLE Control is needed and not registered, Visual Basic uses the auto-registration facility to automatically register an OLE Control by searching along the normal DLL search path for a file with the OLE Control name. This is done both in the design environment and for built executables. If the OLE Control is properly registered by other means, it need not be on the DLL search path.

If Visual Basic does not reside on a computer, any Visual Basic application targeted to be run on that computer must be installed through the setup process. It cannot be simply copied.

What is VB's auto-registration facility?
0
 

Author Comment

by:jnowlin
ID: 7034469
bobbit31,

Today, I tried the code you offered earlier.
There were a couple of problems.
CopyToSystem ("MSVBVM60.DLL")
I got the error "Aurgument not Optional"

There appeared to be a constant in:
fSuccess = (WaitForSingleObject(hThread, 10000) = WAIT_OBJECT_0)
the compiler didn't know what WAIT_OBJECT_0 was;

In the line:

VBRegSvr32 ("C:\Windows\System\Msvbvm60.dll")

Would this file exist in different Windows folders depending upon which version of Windows was on the target PC? The above may exist in Windows95, but it would be:
("[Drive]:\Winnt\System32\Msvbvm60.dll") in Windows NT, WIN2K and:
("[Drive]:\Windows\System32\Msvbvm60.dll") in Windows XP, maybe also in Windows98.

The other thing that happened was when I ran this the second time, from within the design, it closed Visual Basic and when I opened VB back up and selected the project I was working on, VB told me that it was already open. Once I shut down Windows 2000 and re-started, I was able to work on it again.
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7034479
it should be
CopyToSystem("<path on your cd to msvbvm60.dll>", "msvbvm60.dll")

the VBRegSvr32("C:\windows\system\msvbvm60.dll")

... i have to restart my computer, it's acting up on me, brb
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7034490
also, put this by the other declares:

Private Const WAIT_OBJECT_0 = 0

> Would this file exist in different Windows folders depending upon which version of Windows was on the
target PC? The above may exist in Windows95, but it would be:
("[Drive]:\Winnt\System32\Msvbvm60.dll") in Windows NT, WIN2K and:
("[Drive]:\Windows\System32\Msvbvm60.dll") in Windows XP, maybe also in Windows98.

in win9x, it would be in c:\windows\system
in winxp, it would be in c:\windows\system32
in nt, c:\winnt\system32 (i think)

put this in your declares section:
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Const MAX_SIZE = 255

and use this new copyToSystem:

Private Sub copyToSystem(strPath As String, strFile As String)

    Dim buff As String
    Dim sysdir as String
    Dim rc As Long
   
    buff = Space$(MAX_SIZE)
    rc = GetSystemDirectory(buff, MAX_SIZE)
    sysdir = Left$(buff, rc)

   if dir(sysdir & "\" & strFile) = "" then '' the file doesn't exist
    FileCopy strPath & strFile, sysdir & "\" & strFile
   end if

End Sub


also, i don't believe msvbvm60.dll has to be registered, so all you have to do is copy it to the system dir...
you don't have to call vbregsvr32 on it.  however, your app may have other dependencies that require registration... so call copytosystem on them and then vbregsvr32.

so your new sub main might look like this:
Sub Main()
   Dim buff as String
   Dim sysdir as String
   Dim rc as long

   Screen.MousePointer = vbHourglass
   buff = Space$(MAX_SIZE)
   rc = GetSystemDirectory(buff, MAX_SIZE)
   sysdir = Left$(buff, rc)
   
   '' copy dependencies to system folder (these are just examples)
   copyToSystem("MSVBVM60.DLL")
   copyToSystem("MCI32.OCX")

   '' register the dlls/ocxs that need registering
   VBRegSvr32 (sysdir & "\mci32.ocx")
   
   Screen.MousePointer = vbDefault

   Form1.Show '' show your form
end sub

that should do it... good luck (btw, the CopyToSystem doesn't overwrite any files if they are already on the computer, so you don't have to worry about messing their computer up)
0
 
LVL 2

Expert Comment

by:woka
ID: 7034850
With regard to auto-registration:

A VB .exe keeps information about it's dependencies including the name of the file containing OLE interfaces it needs to access (eg. MSVBVM60.DLL).

If the dependency hasn't been registered, but the exe finds the file in the search path, the exe will use the DLL (or OCX) even though it hasn't been registered.
0
 
LVL 2

Expert Comment

by:woka
ID: 7034851
PS bobbit31: nice piece of API code.
0
 

Author Comment

by:jnowlin
ID: 7036423
Well,
today (this afternoon) I was at my brother's home. I hadn't seen my niece for a while and had not seen my new nephew in the nearly 3 months he has been in this world, so I did not have enough time to try what I had to this point on his PC (I hope I didn't mess up his machine).

I arrived with 3 CDs, I only had time to try 2 of them.
The first CD had the VB app and the support files, which, heretofor (via Microsoft's Knowledge Base) should have worked to run this application.

It did not run. My brother witnessed the run-time error and said so much as "well, run-time error. I see that and that's it for me". It was the same run-time error as I had witnessed myself on other 'client' machines.

"Automation Error:Unspecified Error."

So, I think, 3 strikes and your out Microsoft.

NEXT....

My 2nd CD had this app (again, with all sorts of GIFs and BMPs and JPGs and MPGs) PLUS it included a Setup.Exe with the .CABinet file and Setup.Lst file. When the CD was placed into the drive, Setup.Exe (being in the Autorun.ini file to be called) started up.
Alas, as the installation was going along smoothly, an error message came up to thwart this install:
"An error occured attempting to register MSDXM.OCX"
[Abort][Retry][Ignore]

Retry did not work, as expected.
The next thing I tried...

did I mention this PC runs Windows95?

was to double-click on a movie file, a MPG (MPEG) file. The error was as follows:

"The MSDXM.OCX file is linked to missing export SHELL32.DLL: ExtractionExW"

??
That was new.

So, it's looking as though it is time to accept a comment as the most appropriate answer, 'cause dealing with an outdated version of MS Windows is wearing me down. I need to go back to work on another VB project that has been going nowhere over the last few weeks.
Besides, the NY Yankees are killing (have killed?) us tonight on national TV!

Man, oh man.

JN
0
 
LVL 2

Expert Comment

by:woka
ID: 7036480
I didn't read everything well enough to make the distinction that you were using the Media Player control.

You might be better off using the ms multimedia control (MCI32.OCX) which has less complex dependencies.

Little compensation for losing a game to the NY Yankees though!
0
 

Author Comment

by:jnowlin
ID: 7037266
Well,

I got a call from my brother this morning.

He can no longer run any MPEGs on his machine and he wants to know how it can be fixed. He downloaded the Windows Media Player from Microsoft and he still gets the error message:

"The MSDXM.OCX file is linked to missing export SHELL32.DLL: ExtractionExW
A device attached to the system is not functioning."

What is SHELL32.DLL and how is MSDXM.OCX dependent upon it?
Any thoughts?
I feel awfull. This is much worse than losing to the Yankees.
0
 
LVL 2

Expert Comment

by:woka
ID: 7037876
By running your setup, I think you've installed an incompatible version of MSDXM.OCX.

If you take a look at:

http://www.microsoft.com/windows/windowsmedia/download/default.asp

Windows Media Player (WMP) seems to be only supported on Win95 up to version 6.4.  If the MSDXM.OCX you installed is from a later version, the WMP install your brother is running (for Win95) is probably not replacing the OCX you've installed.

A "safe" test would be for your brother to rename MSDXM.OCX to something else, then rerun the WMP setup he has for Win95.

PS. Nothing is worse than losing to the NY Yankees!
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7039322
>  I think you've installed an incompatible version of MSDXM.OCX.

just a side note... if you get the code i posted above working, you don't have to worry about this as the above code WILL NOT overwrite any existing files that might be on the user's system. Obviously, if your program requires a later version, then it might not work, but at least you won't screw up their system.

Anyway, good luck getting it to work.
0
 

Author Comment

by:jnowlin
ID: 7039661
OK.
I like "safe" solutions like yours woka, in the short term.
I believe, without looking back at all of these many threads, that bobbit31's code is the way to go.

Damn Yankees, we get to play them on their own turf this weekend!
0
 

Author Comment

by:jnowlin
ID: 7039679
Thanks ever so much bobbit31 and everybody for that matter. I never did get a chance to try this in PowerPoint.

What a wonderful world Mr. Gates has built. If I had only gotten involved with sports, I could be getting paid millions to be an average baseball player, instead of trying to learn all of this.
Oh, well. Hopefully, I won't be disowned by my sister-in-law for awhile.

GO RED SOX!

Jim Nowlin (jnowlin)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now