Complicated question with simple answer I hope? I have an executable compiled using vb5. When installed on user's machine, I get an error when first form is displayed. The error is due to MSVBVM50.dll no being present or registered.

In order to prevent this error being raised, can I perform checks to see if dll is installed and registered prior to loading of first form; and if so, how much of the user's operating system can I access prior to loading first form?

Can I read user's information? Can I write to user's system? Perhaps by accessing shell.application or API resources?

I've been told that I could create a module with sub Main() and call it first, then after performing these operations, load the first form. Is that true?

I guess the bigger question is, by virtue of the app being an executable, are there any bare bones functions which I can perform without having the MSVBVM50.dll begin present and registered, if any?

Hope I have explained this well, tired of restoring OS to boot status.

Any advice would be greatly appreciated.

Hey, billmaster!

I had a few months ago the same problem you're facing...
And solve it creating a Sub Main() (like you said), and using simple functions like DIR$ and FILECOPY to install the needed archives on the client machine.

The more difficulty thing is to determine where the Windows is installed: here in company, we have computers running Windows 98 (yes, until now), Windows NT, Windows 2000, Windows XP and a bit running Windows 7. How to determine when the target folder is WINDOWS\SYSTEM, WINDOWS\SYSTEM32, WINNT\SYSTEM or WINNT\SYSTEM32 (this in the best cases, suposing the user doesn't changed the default folder instalation.

I found the answer reading the Enviroment variables (that ones acessed via MY COMPUTER > PROPERTIES.

'COPIA A DLL SLIDECOLOR PARA O SYSTEM32
  For nCont = 1 To 30
    'FIND WINDOWS INSTALLATION FOLDER
    If InStr(1, Environ$(nCont), "windir=", vbTextCompare) Then
      'VERIFY IF FILE ALREADY EXISTS
      If Dir$(Replace(Right(Environ$(nCont), Len(Environ$(nCont)) - 7), ";", "") & "\SYSTEM32\OBJBSC.OCX") = "" Then
        'IF FILE DOESN'T EXIST, COPY IT FROM THE SOURCE DIRECTORY TO THE CLIENT MACHINE
        FileCopy sSysVar_AICF_Exe & "\OCX\ObjBSC.ocx", Replace(Right(Environ$(nCont), Len(Environ$(nCont)) - 7), ";", "") & "\SYSTEM32\OBJBSC.OCX"
        'REGISTER THE FILE SO THE APPLICATION CAN "FIND" IT
        Shell "REGSVR32.EXE " & Replace(Right(Environ$(nCont), Len(Environ$(nCont)) - 7), ";", "") & "\SYSTEM32\OBJBSC.OCX /s", vbHide
        Exit For
      End If
    End If
  Next

Note in some cases the application generates an error first time is opened, but the error is cleared for the second and the other times you open your app.
Again, here in my office that was a case that is not solved; in a particular computer (three of them to be exact), the code simply don't work and the file is not copied to the client machine. No one finds the answer to WHAT its happen and WHY (three different machines, one with Vista and two with XP, administrative privileges for the user logged...) In all others computers, the code works well.


Regards,
Sidnei

Hi Sidnei:

Thank you for responding. I have not yet tried your example code, but will tomorrow and will let you know how it goes.

I did notice in your example that you used many command functions, such as: DIR, FOR NEXT, INSTR, FILECOPY, etc.

Does this mean that I can use these functions even without the
msvbvm50.dll being installed and registered as long as I perform these actions prior to loading first form, i.e. in sub Main().

I appologize for asking the same question twice, but I was unaware that this is possible. And if it is, why do so many programmers say to purchase installation software? If the above is true, I can build my own installation executables. That would make life much easier.

BTW, I have 3 machines running different OS. Two which are 32 bit, XP and Vista, and one which is 64 bit Windows 7. I will try your example on each and see if I can find the problem.

Thank you again.

Regards,

Mike

Actually, any intrinsic function to VB will require the runtime, however, the use of the API will not as I presently understand it. But your problems can be solved by simply using the PDW or some other installer...

Good Luck

Hi Sidnei,

To thank you for your assistance, I attempted to find the problem you were having. So, I ran your example code using the Environ$ function on my HP Pavillion Notebook PC running XP and noticed the following:

In your FOR..NEXT Loop the counter was set from 1 to 30, but I was unable to locate "windir=" until I set the counter higher an found it at #37. Maybe this is different for each OS. I am not sure.

Dim nCont As Integer
Dim xPos As Integer
  For nCont = 1 To 37 '**** Changed upper limit
      Debug.Print nCont & "|" & Environ$(nCont)
      xPos = InStr(1, Environ$(nCont), "=")
      Debug.Print vbTab & nCont & "|" & Replace(Right(Environ$(nCont), Len(Environ$(nCont)) - xPos), ";", "")
  Next nCont

And got the results below from the PC mentioned above....

Please note #16 which would have to be split based on the semi-colon(;) delimiter. Also see: #6, #25, #29, #30, #31, and #32, as I believe these may be of value to you.


1|ALLUSERSPROFILE=C:\ProgramData
C:\ProgramData
4|CommonProgramFiles=C:\Program Files\Common Files
C:\Program Files\Common Files
6|ComSpec=C:\Windows\system32\cmd.exe
C:\Windows\system32\cmd.exe
9|HOMEDRIVE=C:
C:
13|NUMBER_OF_PROCESSORS=2
2
15|OS=Windows_NT
Windows_NT
16|Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\CyberLink\Power2Go;C:\Program Files\QuickTime\QTSystem\
C:\Windows\system32C:\WindowsC:\Windows\System32\WbemC:\Program Files\CyberLink\Power2GoC:\Program Files\QuickTime\QTSystem\
17|PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
.COM.EXE.BAT.CMD.VBS.VBE.JS.JSE.WSF.WSH.MSC
18|PCBRAND=Pavilion
Pavilion
19|Platform=MCD
MCD
24|ProgramData=C:\ProgramData
C:\ProgramData
25|ProgramFiles=C:\Program Files
C:\Program Files
26|PUBLIC=C:\Users\Public
C:\Users\Public
28|SESSIONNAME=Console
Console
29|SystemDrive=C:
C:
30|SystemRoot=C:\Windows
C:\Windows
31|TEMP=C:\Users\TIMESA~1\AppData\Local\Temp
C:\Users\TIMESA~1\AppData\Local\Temp
32|TMP=C:\Users\TIMESA~1\AppData\Local\Temp
C:\Users\TIMESA~1\AppData\Local\Temp
37|windir=C:\Windows
C:\Windows


I hope you find this helpful and Happy Easter,

Mike (billmaster)

Hi,

A little confused. You said that I could not use intrinsic functions without msvbvm50.dll being present and registered, but that I could access the user's system via API in sub Main() where I must use an "if ... then" statement to check results prior to loading first form. Is not "if ... then" an intrinsic function? Maybe I'm not calling it the right name.

If so, is there a list of basic functions that are available in any EXE created using VB 5.0 even when said dll is missing?

Any help clearing my mind would be appreciated.

Regards

If...Then, Select Case, ElseIF are condition statements found in any language and thus are not intrinsic to vb as they are code branches based upon conditions found withing the code that, no matter what language is used to derive these branches, when compiled they should all be the same, or nearly the same. While on the other hand, Dir, Instr, Mid, Trim, Left, Right, UCase, LCase, GetSetting, SaveSetting, and so on are intrinsic to VB and are interpreted by the VB runtimes. And finally, the API, as I understand it, circumvents the vb runtimes and communicate with the dll in question directly.


Good Luck

Hi Billmaster,
I repeat vb5prgrmr's quote

But your problems can be solved by simply using the PDW or some other installer...

. You can use other installers which will register any components no matter they are already there in the system. Some examples of free installer makers are 'Create install free', 'Create Install Light', 'Windows installer' etc. you can download using Google, yahoo etc.

Thankx

Thank you vb5prgrmr,

Knew if I explained myself better, a better answer would come forth. Funny how that works. Should have stated earlier that my intent was to create my own installation apps. After much research, the means to append a required DLL to the installer EXE was found; thus, all that remained was writing the file out to the user's system and registering it prior to the user being informed of its being missing. It would appear, based on your explanation, that this will now be possible.

The interest in creating my own installation utility was brought about by the attitudes many users have about older technology. Although an application may perform flawlessly, there is still the opinion among some professionals that if app was not written in "C" it must not be that great. So, to avoid that misconception, I did not want the user to know that the msvbvm50.dll was required.

I will research further to find a listing of all "bare-bones" condition statements available across language platforms as to not get confused between them and intrinsic functions again.

Thank you so much for the clarification.

Regards

Not a problem. Just so you know, there is a setup project where vb is installed that allows you to customize the PDW. If you decide to alter this code, be warned that you should make at least two backups, one for alteration, and one for being able to reset as where it is located is the source for the PDW. Also, you could upgrade to the Windows Installer 1.1. See the top pinned thread in this forum for where to download it.


Good Luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.