1cdf0e10cSrcweirAttribute VB_Name = "Utilities" 2*e76eebc6SAndrew Rist'************************************************************************* 3cdf0e10cSrcweir' 4*e76eebc6SAndrew Rist' Licensed to the Apache Software Foundation (ASF) under one 5*e76eebc6SAndrew Rist' or more contributor license agreements. See the NOTICE file 6*e76eebc6SAndrew Rist' distributed with this work for additional information 7*e76eebc6SAndrew Rist' regarding copyright ownership. The ASF licenses this file 8*e76eebc6SAndrew Rist' to you under the Apache License, Version 2.0 (the 9*e76eebc6SAndrew Rist' "License"); you may not use this file except in compliance 10*e76eebc6SAndrew Rist' with the License. You may obtain a copy of the License at 11cdf0e10cSrcweir' 12*e76eebc6SAndrew Rist' http://www.apache.org/licenses/LICENSE-2.0 13cdf0e10cSrcweir' 14*e76eebc6SAndrew Rist' Unless required by applicable law or agreed to in writing, 15*e76eebc6SAndrew Rist' software distributed under the License is distributed on an 16*e76eebc6SAndrew Rist' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17*e76eebc6SAndrew Rist' KIND, either express or implied. See the License for the 18*e76eebc6SAndrew Rist' specific language governing permissions and limitations 19*e76eebc6SAndrew Rist' under the License. 20cdf0e10cSrcweir' 21*e76eebc6SAndrew Rist'************************************************************************* 22cdf0e10cSrcweirOption Explicit 23cdf0e10cSrcweir 24cdf0e10cSrcweirPublic Const LOCALE_ILANGUAGE As Long = &H1 'language id 25cdf0e10cSrcweirPublic Const LOCALE_SLANGUAGE As Long = &H2 'localized name of lang 26cdf0e10cSrcweirPublic Const LOCALE_SENGLANGUAGE As Long = &H1001 'English name of lang 27cdf0e10cSrcweirPublic Const LOCALE_SABBREVLANGNAME As Long = &H3 'abbreviated lang name 28cdf0e10cSrcweirPublic Const LOCALE_SNATIVELANGNAME As Long = &H4 'native name of lang 29cdf0e10cSrcweirPublic Const LOCALE_ICOUNTRY As Long = &H5 'country code 30cdf0e10cSrcweirPublic Const LOCALE_SCOUNTRY As Long = &H6 'localized name of country 31cdf0e10cSrcweirPublic Const LOCALE_SENGCOUNTRY As Long = &H1002 'English name of country 32cdf0e10cSrcweirPublic Const LOCALE_SABBREVCTRYNAME As Long = &H7 'abbreviated country name 33cdf0e10cSrcweirPublic Const LOCALE_SNATIVECTRYNAME As Long = &H8 'native name of country 34cdf0e10cSrcweirPublic Const LOCALE_SINTLSYMBOL As Long = &H15 'intl monetary symbol 35cdf0e10cSrcweirPublic Const LOCALE_IDEFAULTLANGUAGE As Long = &H9 'def language id 36cdf0e10cSrcweirPublic Const LOCALE_IDEFAULTCOUNTRY As Long = &HA 'def country code 37cdf0e10cSrcweirPublic Const LOCALE_IDEFAULTCODEPAGE As Long = &HB 'def oem code page 38cdf0e10cSrcweirPublic Const LOCALE_IDEFAULTANSICODEPAGE As Long = &H1004 'def ansi code page 39cdf0e10cSrcweirPublic Const LOCALE_IDEFAULTMACCODEPAGE As Long = &H1011 'def mac code page 40cdf0e10cSrcweir 41cdf0e10cSrcweirPublic Const LOCALE_IMEASURE As Long = &HD '0 = metric, 1 = US 42cdf0e10cSrcweirPublic Const LOCALE_SSHORTDATE As Long = &H1F 'short date format string 43cdf0e10cSrcweir 44cdf0e10cSrcweir'#if(WINVER >= &H0400) 45cdf0e10cSrcweirPublic Const LOCALE_SISO639LANGNAME As Long = &H59 'ISO abbreviated language name 46cdf0e10cSrcweirPublic Const LOCALE_SISO3166CTRYNAME As Long = &H5A 'ISO abbreviated country name 47cdf0e10cSrcweir'#endif /* WINVER >= as long = &H0400 */ 48cdf0e10cSrcweir 49cdf0e10cSrcweir'#if(WINVER >= &H0500) 50cdf0e10cSrcweirPublic Const LOCALE_SNATIVECURRNAME As Long = &H1008 'native name of currency 51cdf0e10cSrcweirPublic Const LOCALE_IDEFAULTEBCDICCODEPAGE As Long = &H1012 'default ebcdic code page 52cdf0e10cSrcweirPublic Const LOCALE_SSORTNAME As Long = &H1013 'sort name 53cdf0e10cSrcweir'#endif /* WINVER >= &H0500 */ 54cdf0e10cSrcweir 55cdf0e10cSrcweirPublic Const CSTR_LOG_FILE_NAME = "analysis.log" 56cdf0e10cSrcweir 57cdf0e10cSrcweirPublic Declare Function GetThreadLocale Lib "kernel32" () As Long 58cdf0e10cSrcweir 59cdf0e10cSrcweirPublic Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long 60cdf0e10cSrcweirPublic Declare Function GetUserDefaultLCID Lib "kernel32" () As Long 61cdf0e10cSrcweirPublic Declare Function GetUserDefaultLangID Lib "kernel32" () As Long 62cdf0e10cSrcweirPublic Declare Function GetSystemDefaultLangID Lib "kernel32" () As Long 63cdf0e10cSrcweir 64cdf0e10cSrcweirPublic Declare Function GetLocaleInfo Lib "kernel32" _ 65cdf0e10cSrcweir Alias "GetLocaleInfoA" _ 66cdf0e10cSrcweir (ByVal Locale As Long, _ 67cdf0e10cSrcweir ByVal LCType As Long, _ 68cdf0e10cSrcweir ByVal lpLCData As String, _ 69cdf0e10cSrcweir ByVal cchData As Long) As Long 70cdf0e10cSrcweir 71cdf0e10cSrcweirPrivate Const VER_PLATFORM_WIN32s = 0 72cdf0e10cSrcweirPrivate Const VER_PLATFORM_WIN32_WINDOWS = 1 73cdf0e10cSrcweirPrivate Const VER_PLATFORM_WIN32_NT = 2 74cdf0e10cSrcweir 75cdf0e10cSrcweirPrivate Type OSVERSIONINFO 76cdf0e10cSrcweir OSVSize As Long 'size, in bytes, of this data structure 77cdf0e10cSrcweir dwVerMajor As Long 'ie NT 3.51, dwVerMajor = 3; NT 4.0, dwVerMajor = 4. 78cdf0e10cSrcweir dwVerMinor As Long 'ie NT 3.51, dwVerMinor = 51; NT 4.0, dwVerMinor= 0. 79cdf0e10cSrcweir dwBuildNumber As Long 'NT: build number of the OS 80cdf0e10cSrcweir 'Win9x: build number of the OS in low-order word. 81cdf0e10cSrcweir ' High-order word contains major & minor ver nos. 82cdf0e10cSrcweir PlatformID As Long 'Identifies the operating system platform. 83cdf0e10cSrcweir szCSDVersion As String * 128 'NT: string, such as "Service Pack 3" 84cdf0e10cSrcweir 'Win9x: string providing arbitrary additional information 85cdf0e10cSrcweirEnd Type 86cdf0e10cSrcweir 87cdf0e10cSrcweirPublic Type RGB_WINVER 88cdf0e10cSrcweir PlatformID As Long 89cdf0e10cSrcweir VersionName As String 90cdf0e10cSrcweir VersionNo As String 91cdf0e10cSrcweir ServicePack As String 92cdf0e10cSrcweir BuildNo As String 93cdf0e10cSrcweirEnd Type 94cdf0e10cSrcweir 95cdf0e10cSrcweir'defined As Any to support OSVERSIONINFO and OSVERSIONINFOEX 96cdf0e10cSrcweirPrivate Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _ 97cdf0e10cSrcweir (lpVersionInformation As Any) As Long 98cdf0e10cSrcweir 99cdf0e10cSrcweirPrivate Declare Function GetDesktopWindow Lib "user32" () As Long 100cdf0e10cSrcweir 101cdf0e10cSrcweirPrivate Declare Function ShellExecute Lib "shell32" _ 102cdf0e10cSrcweir Alias "ShellExecuteA" _ 103cdf0e10cSrcweir (ByVal hWnd As Long, _ 104cdf0e10cSrcweir ByVal lpOperation As String, _ 105cdf0e10cSrcweir ByVal lpFile As String, _ 106cdf0e10cSrcweir ByVal lpParameters As String, _ 107cdf0e10cSrcweir ByVal lpDirectory As String, _ 108cdf0e10cSrcweir ByVal nShowCmd As Long) As Long 109cdf0e10cSrcweir 110cdf0e10cSrcweirPublic Const SW_SHOWNORMAL As Long = 1 111cdf0e10cSrcweirPublic Const SW_SHOWMAXIMIZED As Long = 3 112cdf0e10cSrcweirPublic Const SW_SHOWDEFAULT As Long = 10 113cdf0e10cSrcweirPublic Const SE_ERR_NOASSOC As Long = 31 114cdf0e10cSrcweir 115cdf0e10cSrcweirPublic Const CNO_OPTIONAL_PARAM = "_NoOptionalParam_" 116cdf0e10cSrcweirPrivate Declare Function WritePrivateProfileString Lib "kernel32" _ 117cdf0e10cSrcweir Alias "WritePrivateProfileStringA" _ 118cdf0e10cSrcweir (ByVal lpSectionName As String, _ 119cdf0e10cSrcweir ByVal lpKeyName As Any, _ 120cdf0e10cSrcweir ByVal lpString As Any, _ 121cdf0e10cSrcweir ByVal lpFileName As String) As Long 122cdf0e10cSrcweir 123cdf0e10cSrcweir 124cdf0e10cSrcweirPublic Const HKEY_LOCAL_MACHINE As Long = &H80000002 125cdf0e10cSrcweirPublic Const HKEY_CLASSES_ROOT = &H80000000 126cdf0e10cSrcweirPrivate Const ERROR_MORE_DATA = 234 127cdf0e10cSrcweirPrivate Const ERROR_SUCCESS As Long = 0 128cdf0e10cSrcweirPrivate Const KEY_QUERY_VALUE As Long = &H1 129cdf0e10cSrcweirPrivate Const KEY_ENUMERATE_SUB_KEYS As Long = &H8 130cdf0e10cSrcweirPrivate Const KEY_NOTIFY As Long = &H10 131cdf0e10cSrcweirPrivate Const STANDARD_RIGHTS_READ As Long = &H20000 132cdf0e10cSrcweirPrivate Const SYNCHRONIZE As Long = &H100000 133cdf0e10cSrcweirPrivate Const KEY_READ As Long = ((STANDARD_RIGHTS_READ Or _ 134cdf0e10cSrcweir KEY_QUERY_VALUE Or _ 135cdf0e10cSrcweir KEY_ENUMERATE_SUB_KEYS Or _ 136cdf0e10cSrcweir KEY_NOTIFY) And _ 137cdf0e10cSrcweir (Not SYNCHRONIZE)) 138cdf0e10cSrcweir 139cdf0e10cSrcweirPrivate Declare Function RegOpenKeyEx Lib "advapi32.dll" _ 140cdf0e10cSrcweir Alias "RegOpenKeyExA" _ 141cdf0e10cSrcweir (ByVal hKey As Long, _ 142cdf0e10cSrcweir ByVal lpSubKey As String, _ 143cdf0e10cSrcweir ByVal ulOptions As Long, _ 144cdf0e10cSrcweir ByVal samDesired As Long, _ 145cdf0e10cSrcweir phkResult As Long) As Long 146cdf0e10cSrcweir 147cdf0e10cSrcweirPrivate Declare Function RegQueryValueEx Lib "advapi32.dll" _ 148cdf0e10cSrcweir Alias "RegQueryValueExA" _ 149cdf0e10cSrcweir (ByVal hKey As Long, _ 150cdf0e10cSrcweir ByVal lpValueName As String, _ 151cdf0e10cSrcweir ByVal lpReserved As Long, _ 152cdf0e10cSrcweir lpType As Long, _ 153cdf0e10cSrcweir lpData As Any, _ 154cdf0e10cSrcweir lpcbData As Long) As Long 155cdf0e10cSrcweir 156cdf0e10cSrcweirPrivate Declare Function RegCloseKey Lib "advapi32.dll" _ 157cdf0e10cSrcweir (ByVal hKey As Long) As Long 158cdf0e10cSrcweir 159cdf0e10cSrcweirPrivate Declare Function lstrlenW Lib "kernel32" _ 160cdf0e10cSrcweir (ByVal lpString As Long) As Long 161cdf0e10cSrcweir 162cdf0e10cSrcweirPrivate Type ShortItemId 163cdf0e10cSrcweir cb As Long 164cdf0e10cSrcweir abID As Byte 165cdf0e10cSrcweirEnd Type 166cdf0e10cSrcweir 167cdf0e10cSrcweirPrivate Type ITEMIDLIST 168cdf0e10cSrcweir mkid As ShortItemId 169cdf0e10cSrcweirEnd Type 170cdf0e10cSrcweir 171cdf0e10cSrcweirPrivate Declare Function SHGetPathFromIDList Lib "shell32.dll" _ 172cdf0e10cSrcweir (ByVal pidl As Long, ByVal pszPath As String) As Long 173cdf0e10cSrcweir 174cdf0e10cSrcweirPrivate Declare Function SHGetSpecialFolderLocation Lib _ 175cdf0e10cSrcweir "shell32.dll" (ByVal hWndOwner As Long, ByVal nFolder _ 176cdf0e10cSrcweir As Long, pidl As ITEMIDLIST) As Long 177cdf0e10cSrcweir 178cdf0e10cSrcweir 179cdf0e10cSrcweirPublic Function IsWin98Plus() As Boolean 180cdf0e10cSrcweir 'returns True if running Windows 2000 or later 181cdf0e10cSrcweir Dim osv As OSVERSIONINFO 182cdf0e10cSrcweir 183cdf0e10cSrcweir osv.OSVSize = Len(osv) 184cdf0e10cSrcweir 185cdf0e10cSrcweir If GetVersionEx(osv) = 1 Then 186cdf0e10cSrcweir 187cdf0e10cSrcweir Select Case osv.PlatformID 'win 32 188cdf0e10cSrcweir Case VER_PLATFORM_WIN32s: 189cdf0e10cSrcweir IsWin98Plus = False 190cdf0e10cSrcweir Exit Function 191cdf0e10cSrcweir Case VER_PLATFORM_WIN32_NT: 'win nt, 2000, xp 192cdf0e10cSrcweir IsWin98Plus = True 193cdf0e10cSrcweir Exit Function 194cdf0e10cSrcweir Case VER_PLATFORM_WIN32_WINDOWS: 195cdf0e10cSrcweir Select Case osv.dwVerMinor 196cdf0e10cSrcweir Case 0: 'win95 197cdf0e10cSrcweir IsWin98Plus = False 198cdf0e10cSrcweir Exit Function 199cdf0e10cSrcweir Case 90: 'Windows ME 200cdf0e10cSrcweir IsWin98Plus = True 201cdf0e10cSrcweir Exit Function 202cdf0e10cSrcweir Case 10: ' Windows 98 203cdf0e10cSrcweir If osv.dwBuildNumber >= 2222 Then 'second edition 204cdf0e10cSrcweir IsWin98Plus = True 205cdf0e10cSrcweir Exit Function 206cdf0e10cSrcweir Else 207cdf0e10cSrcweir IsWin98Plus = False 208cdf0e10cSrcweir Exit Function 209cdf0e10cSrcweir End If 210cdf0e10cSrcweir End Select 211cdf0e10cSrcweir Case Else 212cdf0e10cSrcweir IsWin98Plus = False 213cdf0e10cSrcweir Exit Function 214cdf0e10cSrcweir End Select 215cdf0e10cSrcweir 216cdf0e10cSrcweir End If 217cdf0e10cSrcweir 218cdf0e10cSrcweirEnd Function 219cdf0e10cSrcweir 220cdf0e10cSrcweirPublic Function GetWinVersion(WIN As RGB_WINVER) As String 221cdf0e10cSrcweir 222cdf0e10cSrcweir'returns a structure (RGB_WINVER) 223cdf0e10cSrcweir'filled with OS information 224cdf0e10cSrcweir 225cdf0e10cSrcweir #If Win32 Then 226cdf0e10cSrcweir 227cdf0e10cSrcweir Dim osv As OSVERSIONINFO 228cdf0e10cSrcweir Dim pos As Integer 229cdf0e10cSrcweir Dim sVer As String 230cdf0e10cSrcweir Dim sBuild As String 231cdf0e10cSrcweir 232cdf0e10cSrcweir osv.OSVSize = Len(osv) 233cdf0e10cSrcweir 234cdf0e10cSrcweir If GetVersionEx(osv) = 1 Then 235cdf0e10cSrcweir 236cdf0e10cSrcweir 'PlatformId contains a value representing the OS 237cdf0e10cSrcweir WIN.PlatformID = osv.PlatformID 238cdf0e10cSrcweir 239cdf0e10cSrcweir Select Case osv.PlatformID 240cdf0e10cSrcweir Case VER_PLATFORM_WIN32s: WIN.VersionName = "Win32s" 241cdf0e10cSrcweir Case VER_PLATFORM_WIN32_NT: WIN.VersionName = "Windows NT" 242cdf0e10cSrcweir 243cdf0e10cSrcweir Select Case osv.dwVerMajor 244cdf0e10cSrcweir Case 4: WIN.VersionName = "Windows NT" 245cdf0e10cSrcweir Case 5: 246cdf0e10cSrcweir Select Case osv.dwVerMinor 247cdf0e10cSrcweir Case 0: WIN.VersionName = "Windows 2000" 248cdf0e10cSrcweir Case 1: WIN.VersionName = "Windows XP" 249cdf0e10cSrcweir End Select 250cdf0e10cSrcweir End Select 251cdf0e10cSrcweir 252cdf0e10cSrcweir Case VER_PLATFORM_WIN32_WINDOWS: 253cdf0e10cSrcweir 254cdf0e10cSrcweir 'The dwVerMinor bit tells if its 95 or 98. 255cdf0e10cSrcweir Select Case osv.dwVerMinor 256cdf0e10cSrcweir Case 0: WIN.VersionName = "Windows 95" 257cdf0e10cSrcweir Case 90: WIN.VersionName = "Windows ME" 258cdf0e10cSrcweir Case Else: WIN.VersionName = "Windows 98" 259cdf0e10cSrcweir End Select 260cdf0e10cSrcweir 261cdf0e10cSrcweir End Select 262cdf0e10cSrcweir 263cdf0e10cSrcweir 264cdf0e10cSrcweir 'Get the version number 265cdf0e10cSrcweir WIN.VersionNo = osv.dwVerMajor & "." & osv.dwVerMinor 266cdf0e10cSrcweir 267cdf0e10cSrcweir 'Get the build 268cdf0e10cSrcweir WIN.BuildNo = (osv.dwBuildNumber And &HFFFF&) 269cdf0e10cSrcweir 270cdf0e10cSrcweir 'Any additional info. In Win9x, this can be 271cdf0e10cSrcweir '"any arbitrary string" provided by the 272cdf0e10cSrcweir 'manufacturer. In NT, this is the service pack. 273cdf0e10cSrcweir pos = InStr(osv.szCSDVersion, Chr$(0)) 274cdf0e10cSrcweir If pos Then 275cdf0e10cSrcweir WIN.ServicePack = Left$(osv.szCSDVersion, pos - 1) 276cdf0e10cSrcweir End If 277cdf0e10cSrcweir 278cdf0e10cSrcweir End If 279cdf0e10cSrcweir 280cdf0e10cSrcweir #Else 281cdf0e10cSrcweir 282cdf0e10cSrcweir 'can only return that this does not 283cdf0e10cSrcweir 'support the 32 bit call, so must be Win3x 284cdf0e10cSrcweir WIN.VersionName = "Windows 3.x" 285cdf0e10cSrcweir #End If 286cdf0e10cSrcweir GetWinVersion = WIN.VersionName 287cdf0e10cSrcweir 288cdf0e10cSrcweirEnd Function 289cdf0e10cSrcweir 290cdf0e10cSrcweirPublic Sub RunShellExecute(sTopic As String, _ 291cdf0e10cSrcweir sFile As Variant, _ 292cdf0e10cSrcweir sParams As Variant, _ 293cdf0e10cSrcweir sDirectory As Variant, _ 294cdf0e10cSrcweir nShowCmd As Long) 295cdf0e10cSrcweir 296cdf0e10cSrcweir Dim hWndDesk As Long 297cdf0e10cSrcweir Dim success As Long 298cdf0e10cSrcweir 299cdf0e10cSrcweir 'the desktop will be the 300cdf0e10cSrcweir 'default for error messages 301cdf0e10cSrcweir hWndDesk = GetDesktopWindow() 302cdf0e10cSrcweir 303cdf0e10cSrcweir 'execute the passed operation 304cdf0e10cSrcweir success = ShellExecute(hWndDesk, sTopic, sFile, sParams, sDirectory, nShowCmd) 305cdf0e10cSrcweir 306cdf0e10cSrcweir 'This is optional. Uncomment the three lines 307cdf0e10cSrcweir 'below to have the "Open With.." dialog appear 308cdf0e10cSrcweir 'when the ShellExecute API call fails 309cdf0e10cSrcweir If success = SE_ERR_NOASSOC Then 310cdf0e10cSrcweir Call Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " & sFile, vbNormalFocus) 311cdf0e10cSrcweir End If 312cdf0e10cSrcweir 313cdf0e10cSrcweirEnd Sub 314cdf0e10cSrcweir 315cdf0e10cSrcweirPublic Sub WriteToLog(key As String, value As String, _ 316cdf0e10cSrcweir Optional path As String = CNO_OPTIONAL_PARAM, _ 317cdf0e10cSrcweir Optional section As String = WIZARD_NAME) 318cdf0e10cSrcweir 319cdf0e10cSrcweir Static logFile As String 320cdf0e10cSrcweir 321cdf0e10cSrcweir If logFile = "" Then 322cdf0e10cSrcweir logFile = GetLogFilePath 323cdf0e10cSrcweir End If 324cdf0e10cSrcweir 325cdf0e10cSrcweir If path = "" Then 326cdf0e10cSrcweir Exit Sub 327cdf0e10cSrcweir End If 328cdf0e10cSrcweir 329cdf0e10cSrcweir If path = CNO_OPTIONAL_PARAM Then 330cdf0e10cSrcweir path = logFile 331cdf0e10cSrcweir End If 332cdf0e10cSrcweir Call WritePrivateProfileString(section, key, value, path) 333cdf0e10cSrcweirEnd Sub 334cdf0e10cSrcweir 335cdf0e10cSrcweirPublic Sub WriteDebug(value As String) 336cdf0e10cSrcweir Static ErrCount As Long 337cdf0e10cSrcweir Static logFile As String 338cdf0e10cSrcweir Static debugLevel As Long 339cdf0e10cSrcweir 340cdf0e10cSrcweir If logFile = "" Then 341cdf0e10cSrcweir logFile = GetLogFilePath 342cdf0e10cSrcweir End If 343cdf0e10cSrcweir 344cdf0e10cSrcweir Dim sSection As String 345cdf0e10cSrcweir sSection = WIZARD_NAME & "Debug" 346cdf0e10cSrcweir 347cdf0e10cSrcweir Call WritePrivateProfileString(sSection, "Analysis" & "_debug" & ErrCount, _ 348cdf0e10cSrcweir value, logFile) 349cdf0e10cSrcweir ErrCount = ErrCount + 1 350cdf0e10cSrcweirEnd Sub 351cdf0e10cSrcweir 352cdf0e10cSrcweirPublic Function GetDebug(section As String, key As String) As String 353cdf0e10cSrcweir Static logFile As String 354cdf0e10cSrcweir 355cdf0e10cSrcweir If logFile = "" Then 356cdf0e10cSrcweir logFile = GetLogFilePath 357cdf0e10cSrcweir End If 358cdf0e10cSrcweir 359cdf0e10cSrcweir GetDebug = ProfileGetItem(section, key, "", logFile) 360cdf0e10cSrcweirEnd Function 361cdf0e10cSrcweir 362cdf0e10cSrcweirPublic Function GetUserLocaleInfo(ByVal dwLocaleID As Long, ByVal dwLCType As Long) As String 363cdf0e10cSrcweir 364cdf0e10cSrcweir Dim sReturn As String 365cdf0e10cSrcweir Dim r As Long 366cdf0e10cSrcweir 367cdf0e10cSrcweir 'call the function passing the Locale type 368cdf0e10cSrcweir 'variable to retrieve the required size of 369cdf0e10cSrcweir 'the string buffer needed 370cdf0e10cSrcweir r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn)) 371cdf0e10cSrcweir 372cdf0e10cSrcweir 'if successful.. 373cdf0e10cSrcweir If r Then 374cdf0e10cSrcweir 375cdf0e10cSrcweir 'pad the buffer with spaces 376cdf0e10cSrcweir sReturn = Space$(r) 377cdf0e10cSrcweir 378cdf0e10cSrcweir 'and call again passing the buffer 379cdf0e10cSrcweir r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn)) 380cdf0e10cSrcweir 381cdf0e10cSrcweir 'if successful (r > 0) 382cdf0e10cSrcweir If r Then 383cdf0e10cSrcweir 384cdf0e10cSrcweir 'r holds the size of the string 385cdf0e10cSrcweir 'including the terminating null 386cdf0e10cSrcweir GetUserLocaleInfo = Left$(sReturn, r - 1) 387cdf0e10cSrcweir 388cdf0e10cSrcweir End If 389cdf0e10cSrcweir 390cdf0e10cSrcweir End If 391cdf0e10cSrcweir 392cdf0e10cSrcweirEnd Function 393cdf0e10cSrcweir 394cdf0e10cSrcweirPublic Function GetRegistryInfo(sHive As String, sSubKey As String, sKey As String) As String 395cdf0e10cSrcweir GetRegistryInfo = "" 396cdf0e10cSrcweir Dim hKey As Long 397cdf0e10cSrcweir 398cdf0e10cSrcweir hKey = OpenRegKey(sHive, sSubKey) 399cdf0e10cSrcweir 400cdf0e10cSrcweir If hKey <> 0 Then 401cdf0e10cSrcweir GetRegistryInfo = GetRegValue(hKey, sKey) 402cdf0e10cSrcweir 403cdf0e10cSrcweir 'the opened key must be closed 404cdf0e10cSrcweir Call RegCloseKey(hKey) 405cdf0e10cSrcweir End If 406cdf0e10cSrcweirEnd Function 407cdf0e10cSrcweir 408cdf0e10cSrcweir 409cdf0e10cSrcweirPrivate Function GetRegValue(hSubKey As Long, sKeyName As String) As String 410cdf0e10cSrcweir 411cdf0e10cSrcweir Dim lpValue As String 'value retrieved 412cdf0e10cSrcweir Dim lpcbData As Long 'length of retrieved string 413cdf0e10cSrcweir 414cdf0e10cSrcweir 'if valid 415cdf0e10cSrcweir If hSubKey <> 0 Then 416cdf0e10cSrcweir 417cdf0e10cSrcweir 'Pass an zero-length string to 418cdf0e10cSrcweir 'obtain the required buffer size 419cdf0e10cSrcweir 'required to return the result. 420cdf0e10cSrcweir 'If the key passed exists, the call 421cdf0e10cSrcweir 'will return error 234 (more data) 422cdf0e10cSrcweir 'and lpcbData will indicate the 423cdf0e10cSrcweir 'required buffer size (including 424cdf0e10cSrcweir 'the terminating null). 425cdf0e10cSrcweir lpValue = "" 426cdf0e10cSrcweir lpcbData = 0 427cdf0e10cSrcweir If RegQueryValueEx(hSubKey, _ 428cdf0e10cSrcweir sKeyName, _ 429cdf0e10cSrcweir 0&, _ 430cdf0e10cSrcweir 0&, _ 431cdf0e10cSrcweir ByVal lpValue, _ 432cdf0e10cSrcweir lpcbData) = ERROR_MORE_DATA Then 433cdf0e10cSrcweir 434cdf0e10cSrcweir lpValue = Space$(lpcbData) 435cdf0e10cSrcweir 436cdf0e10cSrcweir 'retrieve the desired value 437cdf0e10cSrcweir If RegQueryValueEx(hSubKey, _ 438cdf0e10cSrcweir sKeyName, _ 439cdf0e10cSrcweir 0&, _ 440cdf0e10cSrcweir 0&, _ 441cdf0e10cSrcweir ByVal lpValue, _ 442cdf0e10cSrcweir lpcbData) = ERROR_SUCCESS Then 443cdf0e10cSrcweir 444cdf0e10cSrcweir GetRegValue = TrimNull(lpValue) 445cdf0e10cSrcweir 446cdf0e10cSrcweir End If 'If RegQueryValueEx (second call) 447cdf0e10cSrcweir End If 'If RegQueryValueEx (first call) 448cdf0e10cSrcweir End If 'If hSubKey 449cdf0e10cSrcweir 450cdf0e10cSrcweirEnd Function 451cdf0e10cSrcweir 452cdf0e10cSrcweirPrivate Function OpenRegKey(ByVal hKey As Long, _ 453cdf0e10cSrcweir ByVal lpSubKey As String) As Long 454cdf0e10cSrcweir Dim hSubKey As Long 455cdf0e10cSrcweir Dim retval As Long 456cdf0e10cSrcweir 457cdf0e10cSrcweir retval = RegOpenKeyEx(hKey, lpSubKey, _ 458cdf0e10cSrcweir 0, KEY_READ, hSubKey) 459cdf0e10cSrcweir 460cdf0e10cSrcweir If retval = ERROR_SUCCESS Then 461cdf0e10cSrcweir OpenRegKey = hSubKey 462cdf0e10cSrcweir End If 463cdf0e10cSrcweirEnd Function 464cdf0e10cSrcweir 465cdf0e10cSrcweir 466cdf0e10cSrcweirPrivate Function TrimNull(startstr As String) As String 467cdf0e10cSrcweir 468cdf0e10cSrcweir TrimNull = Left$(startstr, lstrlenW(StrPtr(startstr))) 469cdf0e10cSrcweir 470cdf0e10cSrcweirEnd Function 471cdf0e10cSrcweir 472cdf0e10cSrcweirFunction GetLogFilePath() As String 473cdf0e10cSrcweir 474cdf0e10cSrcweir Dim fso As New FileSystemObject 475cdf0e10cSrcweir Dim TempPath As String 476cdf0e10cSrcweir 477cdf0e10cSrcweir TempPath = fso.GetSpecialFolder(TemporaryFolder).path 478cdf0e10cSrcweir 479cdf0e10cSrcweir If (TempPath = "") Then 480cdf0e10cSrcweir TempPath = "." 481cdf0e10cSrcweir End If 482cdf0e10cSrcweir 483cdf0e10cSrcweir GetLogFilePath = fso.GetAbsolutePathName(TempPath & "\" & CSTR_LOG_FILE_NAME) 484cdf0e10cSrcweirEnd Function 485cdf0e10cSrcweir 486cdf0e10cSrcweirFunction GetIniFilePath() As String 487cdf0e10cSrcweir 488cdf0e10cSrcweir Dim fso As New FileSystemObject 489cdf0e10cSrcweir Dim AppDataDir As String 490cdf0e10cSrcweir 491cdf0e10cSrcweir AppDataDir = GetAppDataFolder 492cdf0e10cSrcweir If (AppDataDir = "") Then 493cdf0e10cSrcweir AppDataDir = CBASE_RESOURCE_DIR 494cdf0e10cSrcweir Else 495cdf0e10cSrcweir If Not fso.FolderExists(AppDataDir) Then 496cdf0e10cSrcweir fso.CreateFolder (AppDataDir) 497cdf0e10cSrcweir End If 498cdf0e10cSrcweir AppDataDir = AppDataDir & "\Sun" 499cdf0e10cSrcweir If Not fso.FolderExists(AppDataDir) Then 500cdf0e10cSrcweir fso.CreateFolder (AppDataDir) 501cdf0e10cSrcweir End If 502cdf0e10cSrcweir AppDataDir = AppDataDir & "\AnalysisWizard" 503cdf0e10cSrcweir If Not fso.FolderExists(AppDataDir) Then 504cdf0e10cSrcweir fso.CreateFolder (AppDataDir) 505cdf0e10cSrcweir End If 506cdf0e10cSrcweir End If 507cdf0e10cSrcweir 508cdf0e10cSrcweir GetIniFilePath = fso.GetAbsolutePathName(AppDataDir & "\" & CANALYSIS_INI_FILE) 509cdf0e10cSrcweirEnd Function 510cdf0e10cSrcweir 511cdf0e10cSrcweir' This function returns the Application Data Folder Path 512cdf0e10cSrcweirFunction GetAppDataFolder() As String 513cdf0e10cSrcweir Dim idlstr As Long 514cdf0e10cSrcweir Dim sPath As String 515cdf0e10cSrcweir Dim IDL As ITEMIDLIST 516cdf0e10cSrcweir Const NOERROR = 0 517cdf0e10cSrcweir Const MAX_LENGTH = 260 518cdf0e10cSrcweir Const CSIDL_APPDATA = &H1A 519cdf0e10cSrcweir 520cdf0e10cSrcweir On Error GoTo Err_GetFolder 521cdf0e10cSrcweir 522cdf0e10cSrcweir ' Fill the idl structure with the specified folder item. 523cdf0e10cSrcweir idlstr = SHGetSpecialFolderLocation(0, CSIDL_APPDATA, IDL) 524cdf0e10cSrcweir 525cdf0e10cSrcweir If idlstr = NOERROR Then 526cdf0e10cSrcweir ' Get the path from the idl list, and return 527cdf0e10cSrcweir ' the folder with a slash at the end. 528cdf0e10cSrcweir sPath = Space$(MAX_LENGTH) 529cdf0e10cSrcweir idlstr = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath) 530cdf0e10cSrcweir If idlstr Then 531cdf0e10cSrcweir GetAppDataFolder = Left$(sPath, InStr(sPath, Chr$(0)) - 1) 532cdf0e10cSrcweir End If 533cdf0e10cSrcweir End If 534cdf0e10cSrcweir 535cdf0e10cSrcweirExit_GetFolder: 536cdf0e10cSrcweir Exit Function 537cdf0e10cSrcweir 538cdf0e10cSrcweirErr_GetFolder: 539cdf0e10cSrcweir MsgBox "An Error was Encountered" & Chr(13) & Err.Description, _ 540cdf0e10cSrcweir vbCritical Or vbOKOnly 541cdf0e10cSrcweir Resume Exit_GetFolder 542cdf0e10cSrcweir 543cdf0e10cSrcweirEnd Function 544cdf0e10cSrcweir 545cdf0e10cSrcweir 546cdf0e10cSrcweir 547