[blue]Option Compare Database
Option Explicit
Private Const VER_PLATFORM_WIN32_NT = 2
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" _
(ByRef lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Function GetFileNameFromBrowseW Lib "shell32" _
Alias "#63" _
(ByVal hwndOwner As Long, _
ByVal lpstrFile As Long, _
ByVal nMaxFile As Long, _
ByVal lpstrInitialDir As Long, _
ByVal lpstrDefExt As Long, _
ByVal lpstrFilter As Long, _
ByVal lpstrTitle As Long) As Long
Private Declare Function GetFileNameFromBrowseA Lib "shell32" _
Alias "#63" _
(ByVal hwndOwner As Long, _
ByVal lpstrFile As String, _
ByVal nMaxFile As Long, _
ByVal lpstrInitialDir As String, _
ByVal lpstrDefExt As String, _
ByVal lpstrFilter As String, _
ByVal lpstrTitle As String) As Long
Public Function IsWinNT() As Boolean
Dim myOS As OSVERSIONINFO
myOS.dwOSVersionInfoSize = Len(myOS)
GetVersionEx myOS
IsWinNT = (myOS.dwPlatformId = VER_PLATFORM_WIN32_NT)
End Function
Public Function BrowseFiles(frm As Form)
Dim sSave As String, idx As Integer
sSave = Space(255)
[green]'Arguement definitions:
'hwndOwner
'Initialize edit control & return path to file (Buffer)
'Size in characters of above buffer
'Initial Dir
'Default extension
'Filter Strings
'Title (Title Bar)[/green]
If IsWinNT Then
[green]'unicode version of the function[/green]
GetFileNameFromBrowseW _
frm.hwnd, _
StrPtr(sSave), _
255, _
StrPtr(CurrentProject.Path), _
StrPtr("jpg"), _
StrPtr("JPG files (*.jpg)" + Chr$(0) + "*.jpg" + Chr$(0) + _
"All files (*.*)" + Chr$(0) + "*.*" + Chr$(0)), _
StrPtr("Browse JPG Files")
Else
[green]'ANSI version of the function[/green]
GetFileNameFromBrowseA _
frm.hwnd, _
sSave, _
255, _
CurrentProject.Path, _
"jpg", _
"JPG files (*.jpg)" + Chr$(0) + "*.jpg" + Chr$(0) + _
"All files (*.*)" + Chr$(0) + "*.*" + Chr$(0), _
"Browse JPG Files"
End If
idx = InStr(1, sSave, vbNullChar)
If idx Then
sSave = Left(sSave, idx - 1)
idx = InStrRev(sSave, "\")
BrowseFiles = Left(sSave, idx)
Else
BrowseFiles = ""
End If
End Function[/blue]