Find Notes directory both V4 , R5 and R6 (app dir)

Get the App path for Notes in V4 & R5 & R6

Someone asked me how to get the App path for Notes in V4 & R5 & R6, as in v4 registry queries can't be handled by formulas I had to use Windows API to do so.


'Paste in Declaration of a form button
Type FILETIME
	dwLowDateTime As Long
	dwHighDateTime As Long
End Type

Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (Byval hKey 
As Long, Byval lpSubKey As String, phkResult As Long) As Long
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (Byval
hKey As Long, Byval lpSubKey As String, Byval ulOptions As Long, Byval
samDesired As Long, phkResult As Long) As Long Declare Function RegCloseKey Lib "advapi32.dll" (Byval hKey As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA"
(Byval hKey As Long, Byval lpValueName As String, Byval lpReserved As Long,
lpType As Long, Byval lpData As String, lpcbData As Long) As Long
Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (Byval hKey
As Long, Byval dwIndex As Long, Byval lpname As String, Byval cbName As Long) As Long
Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (Byval
hKey As Long, Byval dwIndex As Long, Byval lpname As String, lpcbName As Long,
Byval lpReserved As Long, Byval lpClass As String,
lpcbClass As Long, lpftLastWriteTime As FILETIME) As Long Declare Function RegSetValueEx& Lib "advapi32.dll" Alias "RegSetValueExA" _
(Byval hKey As Long, Byval lpValueName As String, Byval Reserved As Long, Byval _ dwType As Long, Byval lpData As String, Byval cbData As Long) Declare Function RegCreateKey& Lib "advapi32.dll" Alias "RegCreateKeyA" (Byval _ hKey
As Long, Byval lpSubKey As String, phkResult As Long) '-- Constant Definitions for WIN32API Const HKEY_CLASSES_ROOT = &H80000000 Const HKEY_CURRENT_USER = &H80000001 Const HKEY_LOCAL_MACHINE = &H80000002 Const HKEY_USERS = &H80000003 Const HKEY_PERFORMANCE_DATA = &H80000004 Const SYNCHRONIZE = &H100000 Const STANDARD_RIGHTS_READ = &H20000 Const STANDARD_RIGHTS_WRITE = &H20000 Const STANDARD_RIGHTS_EXECUTE = &H20000 Const STANDARD_RIGHTS_REQUIRED = &HF0000 Const STANDARD_RIGHTS_ALL = &H1F0000 Const KEY_QUERY_VALUE = &H1 Const KEY_SET_VALUE = &H2 Const KEY_CREATE_SUB_KEY = &H4 Const KEY_ENUMERATE_SUB_KEYS = &H8 Const KEY_NOTIFY = &H10 Const KEY_CREATE_LINK = &H20 Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or
KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or
KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))
Const KEY_EXECUTE = (KEY_READ) Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or
KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or
KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE)) Const ERROR_SUCCESS = 0& ' Reg Data Types... Const REG_NONE = 0 ' No value type Const REG_SZ = 1 ' Unicode nul terminated string Const REG_EXPAND_SZ = 2 ' Unicode nul terminated string Const REG_BINARY = 3 ' Free form binary Const REG_DWORD = 4 ' 32-bit number Const REG_DWORD_LITTLE_ENDIAN = 4 ' 32-bit number (same as REG_DWORD) Const REG_DWORD_BIG_ENDIAN = 5 ' 32-bit number Const REG_LINK = 6 ' Symbolic Link (unicode) Const REG_MULTI_SZ = 7 ' Multiple Unicode strings 'Paste in the form button click event 'Test if Notes R5?' Dim res As Variant Dim s As New notessession Dim db As notesdatabase Set db = s.currentdatabase Dim doc As notesdocument Set doc = New notesdocument(db) 'Need a doc for evaluate to work Dim qry As String qry = {@version} res = Evaluate(qry,doc) If Cint(res(0)) > 166 Then 'rnext R6 qry = {@RegQueryValue("HKEY_LOCAL_MACHINE"; "SOFTWARELotusNotes6.0"; "Path");} res = Evaluate(qry,doc) Elseif Cint(res(0)) > 147 Then 'R5 qry = {@RegQueryValue("HKEY_LOCAL_MACHINE"; "SOFTWARELotusNotes5.0"; "Path");} res = Evaluate(qry,doc) Else 'V4 or Less Dim keyhandle As Long KeyName$ = "SOFTWARELotusNotes4.0" res3& = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KeyName$ , 0,
KEY_ALL_ACCESS,keyhandle) If res3& = ERROR_SUCCESS Then Dim Ret_Type As Long Dim lpFileName As String Dim lpReturnedString As String*127 Dim retSize As Long retSize = 126 res4& = RegQueryValueEx( keyhandle, "Path", 0,
Ret_Type,lpReturnedString, retSize ) If res4& = ERROR_SUCCESS Then Res(0) = Left$(lpReturnedString, retSize-1) End If End If Call RegCloseKey(keyhandle) End If 'We have the Notes Path Print res(0) 'End Button Form Code
This was first published in February 2002
This Content Component encountered an error

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close