1*cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2*cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3*cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="API" script:language="StarBasic">Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" _ 4*cdf0e10cSrcweir (ByVal hKey As Long, _ 5*cdf0e10cSrcweir ByVal lpSubKey As String, _ 6*cdf0e10cSrcweir ByVal ulOptions As Long, _ 7*cdf0e10cSrcweir ByVal samDesired As Long, _ 8*cdf0e10cSrcweir phkResult As Long) As Long 9*cdf0e10cSrcweir 10*cdf0e10cSrcweirDeclare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" _ 11*cdf0e10cSrcweir (ByVal hKey As Long, _ 12*cdf0e10cSrcweir ByVal lpValueName As String, _ 13*cdf0e10cSrcweir ByVal lpReserved As Long, _ 14*cdf0e10cSrcweir lpType As Long, _ 15*cdf0e10cSrcweir lpData As String, _ 16*cdf0e10cSrcweir lpcbData As Long) As Long 17*cdf0e10cSrcweir 18*cdf0e10cSrcweirDeclare Function RegQueryValueExLong Lib "advapi32.dll" Alias "RegQueryValueExA" _ 19*cdf0e10cSrcweir (ByVal hKey As Long, _ 20*cdf0e10cSrcweir ByVal lpValueName As String, _ 21*cdf0e10cSrcweir ByVal lpReserved As Long, _ 22*cdf0e10cSrcweir lpType As Long, _ 23*cdf0e10cSrcweir lpData As Long, _ 24*cdf0e10cSrcweir lpcbData As Long) As Long 25*cdf0e10cSrcweir 26*cdf0e10cSrcweirDeclare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" _ 27*cdf0e10cSrcweir (ByVal hKey As Long, _ 28*cdf0e10cSrcweir ByVal lpValueName As String, _ 29*cdf0e10cSrcweir ByVal lpReserved As Long, _ 30*cdf0e10cSrcweir lpType As Long, _ 31*cdf0e10cSrcweir ByVal lpData As Long, _ 32*cdf0e10cSrcweir lpcbData As Long) As Long 33*cdf0e10cSrcweir 34*cdf0e10cSrcweirDeclare Function RegCloseKeyA Lib "advapi32.dll" Alias "RegCloseKey" _ 35*cdf0e10cSrcweir (ByVal hKey As Long) As Long 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir 38*cdf0e10cSrcweirPublic Const HKEY_CLASSES_ROOT = &H80000000 39*cdf0e10cSrcweirPublic Const HKEY_CURRENT_USER = &H80000001 40*cdf0e10cSrcweirPublic Const HKEY_LOCAL_MACHINE = &H80000002 41*cdf0e10cSrcweirPublic Const HKEY_USERS = &H80000003 42*cdf0e10cSrcweirPublic Const KEY_ALL_ACCESS = &H3F 43*cdf0e10cSrcweirPublic Const REG_OPTION_NON_VOLATILE = 0 44*cdf0e10cSrcweirPublic Const REG_SZ As Long = 1 45*cdf0e10cSrcweirPublic Const REG_DWORD As Long = 4 46*cdf0e10cSrcweirPublic Const ERROR_NONE = 0 47*cdf0e10cSrcweirPublic Const ERROR_BADDB = 1 48*cdf0e10cSrcweirPublic Const ERROR_BADKEY = 2 49*cdf0e10cSrcweirPublic Const ERROR_CANTOPEN = 3 50*cdf0e10cSrcweirPublic Const ERROR_CANTREAD = 4 51*cdf0e10cSrcweirPublic Const ERROR_CANTWRITE = 5 52*cdf0e10cSrcweirPublic Const ERROR_OUTOFMEMORY = 6 53*cdf0e10cSrcweirPublic Const ERROR_INVALID_PARAMETER = 7 54*cdf0e10cSrcweirPublic Const ERROR_ACCESS_DENIED = 8 55*cdf0e10cSrcweirPublic Const ERROR_INVALID_PARAMETERS = 87 56*cdf0e10cSrcweirPublic Const ERROR_NO_MORE_ITEMS = 259 57*cdf0e10cSrcweir'Public Const KEY_READ = &H20019 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir 60*cdf0e10cSrcweirFunction OpenRegKey(lBaseKey As Long, sKeyName As String) As Variant 61*cdf0e10cSrcweirDim LocKeyValue 62*cdf0e10cSrcweirDim hKey as Long 63*cdf0e10cSrcweirDim lRetValue as Long 64*cdf0e10cSrcweir lRetValue = RegOpenKeyEx(lBaseKey, sKeyName, 0, KEY_ALL_ACCESS, hKey) 65*cdf0e10cSrcweir' lRetValue = QueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Outlook Express\5.0\Default Settings", "Revocation Checking") 66*cdf0e10cSrcweir If hKey <> 0 Then 67*cdf0e10cSrcweir RegCloseKeyA (hKey) 68*cdf0e10cSrcweir End If 69*cdf0e10cSrcweir OpenRegKey() = lRetValue 70*cdf0e10cSrcweirEnd Function 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir 73*cdf0e10cSrcweirFunction GetDefaultPath(CurOffice as Integer) As String 74*cdf0e10cSrcweirDim sPath as String 75*cdf0e10cSrcweirDim Index as Integer 76*cdf0e10cSrcweir Select Case Wizardmode 77*cdf0e10cSrcweir Case SBMICROSOFTMODE 78*cdf0e10cSrcweir Index = Applications(CurOffice,SBAPPLKEY) 79*cdf0e10cSrcweir If GetGUIType = 1 Then ' Windows 80*cdf0e10cSrcweir sPath = QueryValue(HKEY_LOCAL_MACHINE, sKeyName(Index), sValueName(Index)) 81*cdf0e10cSrcweir Else 82*cdf0e10cSrcweir sPath = "" 83*cdf0e10cSrcweir End If 84*cdf0e10cSrcweir If sPath = "" Then 85*cdf0e10cSrcweir sPath = SOWorkPath 86*cdf0e10cSrcweir End If 87*cdf0e10cSrcweir GetDefaultPath = sPath 88*cdf0e10cSrcweir Case SBXMLMODE 89*cdf0e10cSrcweir GetDefaultPath = SOWorkPath 90*cdf0e10cSrcweir End Select 91*cdf0e10cSrcweirEnd Function 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir 94*cdf0e10cSrcweirFunction GetTemplateDefaultPath(Index as Integer) As String 95*cdf0e10cSrcweirDim sLocTemplatePath as String 96*cdf0e10cSrcweirDim sLocProgrampath as String 97*cdf0e10cSrcweirDim Progstring as String 98*cdf0e10cSrcweirDim PathList()as String 99*cdf0e10cSrcweirDim Maxindex as Integer 100*cdf0e10cSrcweirDim OldsLocTemplatePath 101*cdf0e10cSrcweirDim sTemplateKeyName as String 102*cdf0e10cSrcweirDim sTemplateValueName as String 103*cdf0e10cSrcweir On Local Error Goto NOVAlIDSYSTEMPATH 104*cdf0e10cSrcweir Select Case WizardMode 105*cdf0e10cSrcweir Case SBMICROSOFTMODE 106*cdf0e10cSrcweir If GetGUIType = 1 Then ' Windows 107*cdf0e10cSrcweir ' Template directory of Office 97 108*cdf0e10cSrcweir sTemplateKeyName = "Software\Microsoft\Office\8.0\Common\FileNew\LocalTemplates" 109*cdf0e10cSrcweir sTemplateValueName = "" 110*cdf0e10cSrcweir sLocTemplatePath = QueryValue(HKEY_LOCAL_MACHINE, sTemplateKeyName, sTemplateValueName) 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir If sLocTemplatePath = "" Then 113*cdf0e10cSrcweir ' Retrieve the template directory of Office 2000 114*cdf0e10cSrcweir ' Unfortunately there is no existing note about the template directory in 115*cdf0e10cSrcweir ' the whole registry. 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir ' Programdirectory of Office 2000 118*cdf0e10cSrcweir sTemplateKeyName = "Software\Microsoft\Office\9.0\Common\InstallRoot" 119*cdf0e10cSrcweir sTemplateValueName = "Path" 120*cdf0e10cSrcweir sLocProgrampath = QueryValue(HKEY_LOCAL_MACHINE, sTemplateKeyName, sTemplateValueName) 121*cdf0e10cSrcweir If sLocProgrampath <> "" Then 122*cdf0e10cSrcweir If Right(sLocProgrampath, 1) <> "\" Then 123*cdf0e10cSrcweir sLocProgrampath = sLocProgrampath & "\" 124*cdf0e10cSrcweir End If 125*cdf0e10cSrcweir PathList() = ArrayoutofString(sLocProgrampath,"\",Maxindex) 126*cdf0e10cSrcweir Progstring = "\" & PathList(Maxindex-1) & "\" 127*cdf0e10cSrcweir OldsLocTemplatePath = DeleteStr(sLocProgramPath,Progstring) 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir sLocTemplatePath = OldsLocTemplatePath & "\" & "Templates" 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir ' Does this subdirectory "templates" exist at all 132*cdf0e10cSrcweir If oUcb.Exists(sLocTemplatePath) Then 133*cdf0e10cSrcweir ' If Not the main directory of the office is the base 134*cdf0e10cSrcweir sLocTemplatePath = OldsLocTemplatePath 135*cdf0e10cSrcweir End If 136*cdf0e10cSrcweir Else 137*cdf0e10cSrcweir sLocTemplatePath = SOWorkPath 138*cdf0e10cSrcweir End If 139*cdf0e10cSrcweir End If 140*cdf0e10cSrcweir GetTemplateDefaultPath = ConvertToUrl(sLocTemplatePath) 141*cdf0e10cSrcweir Else 142*cdf0e10cSrcweir GetTemplateDefaultPath = SOWorkPath 143*cdf0e10cSrcweir End If 144*cdf0e10cSrcweir Case SBXMLMODE 145*cdf0e10cSrcweir If Index = 3 Then 146*cdf0e10cSrcweir ' Helper Application with no templates 147*cdf0e10cSrcweir GetTemplateDefaultPath = SOWorkPath 148*cdf0e10cSrcweir Else 149*cdf0e10cSrcweir GetTemplateDefaultPath = SOTemplatePath 150*cdf0e10cSrcweir End If 151*cdf0e10cSrcweir End Select 152*cdf0e10cSrcweirNOVALIDSYSTEMPATH: 153*cdf0e10cSrcweir If Err <> 0 Then 154*cdf0e10cSrcweir GetTemplateDefaultPath() = SOWorkPath 155*cdf0e10cSrcweir Resume ONITGOES 156*cdf0e10cSrcweir ONITGOES: 157*cdf0e10cSrcweir End If 158*cdf0e10cSrcweirEnd Function 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir 161*cdf0e10cSrcweirFunction QueryValueEx(ByVal lhKey, ByVal szValueName As String, vValue As String) As Long 162*cdf0e10cSrcweirDim cch As Long 163*cdf0e10cSrcweirDim lrc As Long 164*cdf0e10cSrcweirDim lType As Long 165*cdf0e10cSrcweirDim lValue As Long 166*cdf0e10cSrcweirDim sValue As String 167*cdf0e10cSrcweirDim Empty 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir On Error GoTo QueryValueExError 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir lrc = RegQueryValueExNULL(lhKey, szValueName, 0&, lType, 0&, cch) 172*cdf0e10cSrcweir If lrc <> ERROR_NONE Then Error 5 173*cdf0e10cSrcweir Select Case lType 174*cdf0e10cSrcweir Case REG_SZ: 175*cdf0e10cSrcweir sValue = String(cch, 0) 176*cdf0e10cSrcweir lrc = RegQueryValueExString(lhKey, szValueName, 0&, lType, sValue, cch) 177*cdf0e10cSrcweir If lrc = ERROR_NONE Then 178*cdf0e10cSrcweir vValue = Left$(sValue, cch) 179*cdf0e10cSrcweir Else 180*cdf0e10cSrcweir vValue = Empty 181*cdf0e10cSrcweir End If 182*cdf0e10cSrcweir Case REG_DWORD: 183*cdf0e10cSrcweir lrc = RegQueryValueExLong(lhKey, szValueName, 0&, lType, lValue, cch) 184*cdf0e10cSrcweir If lrc = ERROR_NONE Then 185*cdf0e10cSrcweir vValue = lValue 186*cdf0e10cSrcweir End If 187*cdf0e10cSrcweir Case Else 188*cdf0e10cSrcweir lrc = -1 189*cdf0e10cSrcweir End Select 190*cdf0e10cSrcweirQueryValueExExit: 191*cdf0e10cSrcweir QueryValueEx = lrc 192*cdf0e10cSrcweir Exit Function 193*cdf0e10cSrcweirQueryValueExError: 194*cdf0e10cSrcweir Resume QueryValueExExit 195*cdf0e10cSrcweirEnd Function 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir 198*cdf0e10cSrcweirFunction QueryValue(BaseKey As Long, sKeyName As String, sValueName As String) As Variant 199*cdf0e10cSrcweirDim lRetVal As Long ' Returnvalue API-Call 200*cdf0e10cSrcweirDim hKey As Long ' Onen key handle 201*cdf0e10cSrcweirDim vValue As String ' Key value 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir lRetVal = RegOpenKeyEx(BaseKey, sKeyName, 0, KEY_ALL_ACCESS, hKey) 204*cdf0e10cSrcweir lRetVal = QueryValueEx(hKey, sValueName, vValue) 205*cdf0e10cSrcweir RegCloseKeyA (hKey) 206*cdf0e10cSrcweir QueryValue = vValue 207*cdf0e10cSrcweirEnd Function 208*cdf0e10cSrcweir</script:module>