Solved

mdb running in two different Versions of Access

Posted on 2011-03-08
7
451 Views
Last Modified: 2012-08-13
I need to determine which operating system is running to determine which file-path to use to determine an executable.  Since Win7 file location differs from the WinXp version what is the best way to code for this situation.

My current code has a Private Const that holds the file path for the executable.  How and where do I place code that will determine if the filepath for the Win7 exists and if not look for the alternate for XP version.

Thanks,

karen
Win 7 version:

Private Const mc_VIDATAX_VB_APP As String = _
   "C:\Program Files (x86)\Boeing\FTCS Apps\ViDataX\ViDataX.exe"  'ViDataX Application

Win XP version:

Private Const mc_VIDATAX_VB_APP As String = _
    "C:\Program Files\Boeing\FTCS Apps\ViDataX\ViDataX.exe"

Open in new window

0
Comment
Question by:Karen Schaefer
7 Comments
 
LVL 4

Expert Comment

by:CHutchins
ID: 35073494
Those are the same path for all intensive purposes.. it it is an install that is your issue I would edit the installation to put it in program files rather than x86 would be far easier...

your only difference is 32 bit vs 64 bit file structure.  
0
 

Author Comment

by:Karen Schaefer
ID: 35073537
Yes, I need code that will determine if the X86 directory/file exists and if so chose the first const and if not choose the 2nd Const - which will need to be renamed.

I was thinking something like.

if Find Directory A = true then
 use Const1
else
const2
end if
0
 
LVL 6

Expert Comment

by:Gugro
ID: 35073558
You may use the following code to determine the folder location:

Public Enum SpecialFolderIDs
  sfidDESKTOP = &H0                  ' Desktop
  sfidNTERNET = &H1                  ' Internet Explorer (icon on desktop)
  sfidPROGRAMS = &H2                 ' Start Menu\Programs
  sfidCONTROLS = &H3                 ' My Computer\Control Panel
  sfidPRINTERS = &H4                 ' My Computer\Printers
  sfidPERSONAL = &H5                 ' My Documents
  sfidFAVORITES = &H6                ' \Favorites
  sfidSTARTUP = &H7                  ' StartMenu\Programs\Startup
  sfidRECENT = &H8                   ' \Recent
  sfidSENDTO = &H9                   ' \SendTo
  sfidBITBUCKET = &HA                ' \Recycle Bin
  sfidSTARTMENU = &HB                ' \StartMenu
  sfidDESKTOPDIRECTORY = &H10        ' name>\Desktop
  sfidDRIVERS = &H11                 ' My Computer
  sfidNETWORK = &H12                 ' Network Neighborhood
  sfidNETHOOD = &H13                 ' \nethood
  sfidFONTS = &H14                   ' windows\fonts
  sfidTEMPLATES = &H15
  sfidCOMMON_STARTMENU = &H16        ' All Users\StartMenu
  sfidCOMMON_PROGRAMS = &H17         ' AllUsers\Programs
  sfidCOMMON_STARTUP = &H18          ' AllUsers\Startup
  sfidCOMMON_DESKTOPDIRECTORY = &H19 ' AllUsers\Desktop
  sfidAPPDATA = &H1A                 ' name>\Application Data
  sfidPRINTHOOD = &H1B               ' name>\PrintHood
  sfidLOCAL_APPDATA = &H1C           ' name>\Local Settings\Applicaiton Data (non roaming)
  sfidALTSTARTUP = &H1D              ' non localizedstartup
  sfidCOMMON_ALTSTARTUP = &H1E       ' non localizedCommon startup
  sfidCOMMON_FAVORITES = &H1F
  sfidINTERNET_CACHE = &H20
  sfidCOOKIES = &H21
  sfidHISTORY = &H22
  sfidCOMMON_APPDATA = &H23          ' AllUsers\Application Data
  sfidWINDOWS = &H24                 ' GetWindowsDirectory()
  sfidSYSTEM = &H25                  ' GetSystemDirectory()
  sfidPROGRAM_FILES = &H26           ' C:\Program Files
  sfidMYPICTURES = &H27              ' C:\Program Files\My Pictures
  sfidPROFILE = &H28                 ' USERPROFILE
  sfidSYSTEMX86 = &H29               ' x86 system directory on RISC
  sfidPROGRAM_FILESX86 = &H2A        ' x86 C:\Program Files on RISC
  sfidPROGRAM_FILES_COMMON = &H2B    ' C:\Program Files\Common
  sfidPROGRAM_FILES_COMMONX86 = &H2C ' x86 Program Files\Common on RISC
  sfidCOMMON_TEMPLATES = &H2D        ' All Users\Templates
  sfidCOMMON_DOCUMENTS = &H2E        ' All Users\Documents
  sfidCOMMON_ADMINTOOLS = &H2F       ' All Users\Start Menu\Programs\Administrative Tools
  sfidADMINTOOLS = &H30              ' \Start Menu\Programs\Administrative Tools
  sfidProgramFiles = &H10000
  sfidCommonFiles = &H10001
End Enum

Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long

Public Function GetSpecialFolder(CSIDL As SpecialFolderIDs) As String

  Dim lResult As Long
  Dim IDL As ITEMIDLIST
  Dim sPath As String
 
  lResult = SHGetSpecialFolderLocation(100, CSIDL, IDL)
  If lResult = 0 Then
    sPath = Space$(512)
    lResult = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath)
    GetSpecialFolder = Left$(sPath, InStr(sPath, Chr$(0)) - 1)
  End If
End Function
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 6

Expert Comment

by:Gugro
ID: 35073576
Or :

>> Yes, I need code that will determine if the X86 directory/file exists

Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long
0
 
LVL 17

Expert Comment

by:Barry Cunney
ID: 35073587
Have given sample code with possible solution
Private Sub HandleEXEPath_Click()
Select Case getVersion
    Case "Windows 7"
        ' Path for exe on Windows 7
    Case "Windows XP"
        ' Path for exe on Windows XP
    Case Else
        ' Some other operating system
End Select
End Sub

          
 
            Public Function getVersion() As String
               Dim osinfo As OSVERSIONINFO
               Dim retvalue As Integer
 
               osinfo.dwOSVersionInfoSize = 148
               osinfo.szCSDVersion = Space$(128)
               retvalue = GetVersionExA(osinfo)
 
               With osinfo
               Select Case .dwPlatformId
 
                Case 1
                
                    Select Case .dwMinorVersion
                        Case 0
                            getVersion = "Windows 95"
                        Case 10
                            getVersion = "Windows 98"
                        Case 90
                            getVersion = "Windows Millennium"
                    End Select
    
                Case 2
                    Select Case .dwMajorVersion
                        Case 3
                            getVersion = "Windows NT 3.51"
                        Case 4
                            getVersion = "Windows NT 4.0"
                        Case 5
                            If .dwMinorVersion = 0 Then
                                getVersion = "Windows 2000"
                            Else
                                getVersion = "Windows XP"
                            End If
                        Case 6
                            If .dwMinorVersion = 0 Then
                                getVersion = "Windows Vista"
                            Else
                                getVersion = "Windows 7"
                            End If
                        
                    End Select
    
                Case Else
                   getVersion = "Failed"
            End Select
 
               End With
            End Function



' The following has to be put in a module

Public Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Integer

 Public Type OSVERSIONINFO
               dwOSVersionInfoSize As Long
               dwMajorVersion As Long
               dwMinorVersion As Long
               dwBuildNumber As Long
               dwPlatformId As Long
               szCSDVersion As String * 128
            End Type

Open in new window

0
 

Accepted Solution

by:
Karen Schaefer earned 0 total points
ID: 35073876
thanks for the suggestion, however, found the solution within my own code.  

Thanks for your time.
If ViDataX_File_Exists_W7 = True Then
        FP = "mc_VIDATAX_VB_APP_W7"
    ElseIf ViDataX_File_Exists_XP = True Then
        FP = "mc_VIDATAX_VB_APP_XP"
    Else
        MsgBox "Required ViDataX executable has not been installed on this machine." _
           & vbCrLf & "Contact your application support.", vbOKOnly, "ViDataX"
        Exit Function
    End If

Private Function ViDataX_File_Exists_XP() As Boolean
  On Error Resume Next
  
  Dim sFileName As String  'Full file name
  
  '-- Check that the ViDataX executable exists.
  sFileName = Dir(mc_VIDATAX_VB_APP_XP)
  If Err.Number = 0 And Len(sFileName) > 0 Then ViDataX_File_Exists_XP = True  'File exists

End Function

Open in new window

0
 

Author Closing Comment

by:Karen Schaefer
ID: 35120698
thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

840 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