Hi,
ich hab das Problem auch gerade gehabt und eine Lösung gefunden. Hier die fertige Funktion:
'Declarations:
'For CreateEmptyReplica
Type TIMEDATE
Innards(1) As Long
End Type
Type DBREPLICAINFO
ID As TIMEDATE
Flags As Integer
CutoffInterval As Integer
Cutoff As TIMEDATE
End Type
Declare Function W32NSFDbReplicaInfoGet Lib "nnotes" Alias "NSFDbReplicaInfoGet" ( Byval hDb As Long, ReplicationInfo As DBREPLICAINFO ) As Integer
Declare Function W32NSFDbReplicaInfoSet Lib "nnotes" Alias "NSFDbReplicaInfoSet" ( Byval hDb As Long, ReplicationInfo As DBREPLICAINFO ) As Integer
Declare Function W32NSFDbOpen Lib "nnotes" Alias "NSFDbOpen" ( Byval PathName As Lmbcs String, rethDb As Long ) As Integer
Declare Function W32NSFDbClose Lib "nnotes" Alias "NSFDbClose" ( Byval hDb As Long ) As Integer
Declare Function W32OSLoadString Lib "nnotes" Alias "OSLoadString" ( Byval hModule As Long, Byval StringCode As Integer, Byval retBuffer As Lmbcs String, Byval BufferLength As Integer ) As Integer
Const NULLHANDLE = 0&
Const NOERROR = 0
Const PKG_NSF = &H200
Const ERR_NOT_NSF = PKG_NSF + 1
Const ERR_NSF_VERSION = PKG_NSF + 25
Const REPLFLG_HIDDEN_DESIGN = &H00 ' &H20 Hide , &H00 Unhide.
Sub CreateEmptyReplica( strSrSrv As String, strSrNa As String, strDeSrv As String, strDeNa As String)
Dim dbSr As New NotesDatabase(strSrSrv,strSrNa)
Dim dbDes As NotesDatabase
Dim hDbSr As Long
Dim hDbDe As Long
Dim dbRepInfo As DBREPLICAINFO
Dim iStatus As Integer
Dim sErrMsg As String
Dim sBuffer As String
Dim strTmp As String
'Create empty copy of DB
Call dbSr.CreateCopy(strDeSrv,strDeNa)
'Copy Replica info to make it a replica
sBuffer = String$(256, 0)
'Open Source DB
If strSrSrv="" Then
strTmp=strSrNa
Else
strTmp=strSrSrv+"!!"+strSrNa
End If
iStatus = W32NSFDbOpen(strTmp, hDbSr) 'Source Server and database name
If iStatus <> NOERROR Then
Select Case iStatus
Case ERR_NOT_NSF
sErrMsg = "No NSF File"
Case ERR_NSF_VERSION
sErrMsg = "Version NSF Invalide"
Case Else
sErrMsg = GetCAPIErrorMsg(iStatus)
End Select
Msgbox sErrMsg, 48, "Error in API C"
Exit Sub
End If
'Open Destination DB
If strDeSrv="" Then
strTmp=strDeNa
Else
strTmp=strDeSrv+"!!"+strDeNa
End If
iStatus = W32NSFDbOpen(strTmp, hDbDe) 'Destination Server and database name
If iStatus <> NOERROR Then
Select Case iStatus
Case ERR_NOT_NSF
sErrMsg = "No NSF File"
Case ERR_NSF_VERSION
sErrMsg = "Version NSF Invalide"
Case Else
sErrMsg = GetCAPIErrorMsg(iStatus)
End Select
Msgbox sErrMsg, 48, "Error in API C"
Exit Sub
End If
'Read Source Replica Info
iStatus = W32NSFDbReplicaInfoGet(hDbSr, dbRepInfo)
If iStatus <> NOERROR Then
Msgbox GetCAPIErrorMsg(iStatus), 48, "Error in API C"
Exit Sub
End If
'Write Dest. Replica Info
iStatus = W32NSFDbReplicaInfoSet(hDbDe, dbRepInfo)
If iStatus <> NOERROR Then
Msgbox GetCAPIErrorMsg(iStatus), 48, "Error in API C"
Exit Sub
End If
'Close Source
iStatus = W32NSFDbClose(hDbSr)
If iStatus <> NOERROR Then
Msgbox GetCAPIErrorMsg(iStatus), 48, "Error in API C"
End If
'Close Dest.
iStatus = W32NSFDbClose(hDbDe)
If iStatus <> NOERROR Then
Msgbox GetCAPIErrorMsg(iStatus), 48, "Error in API C"
End If
End Sub
Achtung: Wenn man nicht direkt in der ACL mit Name eingetragen ist, ist der Zugriff auf die Replik erst nach dem ersten replicieren möglich!
Gurß Hape