Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

mdb running in two different Versions of Access

Posted on 2011-03-08
7
Medium Priority
?
456 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
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

963 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