?? serverdt.frm
字號(hào):
' this case, we don't need the network protocol or
' Authentication level.
'
' Ouput:
' [strNetworkAddress] - the network address either passed
' in or obtained from the user
' [strNetworkProtocol] - the network protocol either passed
' in or obtained from the user
'-----------------------------------------------------------
'
Public Sub GetServerDetails( _
ByVal strRegFile As String, _
strNetworkAddress As String, _
strNetworkProtocol As String, _
fDCOM As Boolean _
)
Dim i As Integer
Dim strServerName As String
'See if anything is missing
m_fNetworkAddressSpecified = (strNetworkAddress <> "")
m_fNetworkProtocolSpecified = (strNetworkProtocol <> "")
m_fDCOM = fDCOM
If m_fNetworkAddressSpecified And (m_fNetworkProtocolSpecified Or m_fDCOM) Then
'Both the network address and protocol sequence have already
'been specified in SETUP.LST. There is no need to ask the
'user for more information.
'However, we do need to check that the protocol sequence specified
'in SETUP.LST is actually installed and available on this machine
'(Remote Automation only).
'
If Not m_fDCOM Then
CheckSpecifiedProtocolSequence strNetworkProtocol, strGetServerName(strRegFile)
End If
Exit Sub
End If
strServerName = strGetServerName(strRegFile)
Load Me
lblServerName.Caption = strServerName
If Not gfNoUserInput Then
'
' Show the form and extract necessary information from the user
'
Show vbModal
Else
'
' Since this is silent, simply accept the first one on
' the list.
'
' Note that we know there is at least 1 protocol in the
' list or else the program would have aborted in
' the Form_Load code when it called FillInProtocols().
'
cboNetworkProtocol.ListIndex = 0
End If
If m_fNetworkProtocolSpecified And Not m_fDCOM Then
'The network protocol sequence had already been specified
'in SETUP.LST. We need to check that the protocol sequence specified
'in SETUP.LST is actually installed and available on this machine
'(32-bit only).
CheckSpecifiedProtocolSequence strNetworkProtocol, strGetServerName(strRegFile)
End If
If Not m_fNetworkAddressSpecified Then
strNetworkAddress = txtNetworkAddress
End If
If Not m_fNetworkProtocolSpecified And Not m_fDCOM Then
strNetworkProtocol = gProtocol(cboNetworkProtocol.ListIndex + 1).strName
End If
Unload Me
End Sub
'-----------------------------------------------------------
' SUB: FillInProtocols
'
' Fills in the protocol combo with the available protocols from
' setup.lst
'-----------------------------------------------------------
Private Sub FillInProtocols()
Dim i As Integer
Dim fSuccessReading As Boolean
cboNetworkProtocol.Clear
fSuccessReading = ReadProtocols(gstrSetupInfoFile, gstrINI_SETUP)
If Not fSuccessReading Or gcProtocols <= 0 Then
MsgError ResolveResString(resNOPROTOCOLSINSETUPLST), vbExclamation Or vbOKOnly, gstrTitle
ExitSetup frmRemoteServerDetails, gintRET_FATAL
End If
For i = 1 To gcProtocols
If fIsProtocolSeqSupported(gProtocol(i).strName, gProtocol(i).strFriendlyName) Then
cboNetworkProtocol.AddItem gProtocol(i).strFriendlyName
End If
Next i
If cboNetworkProtocol.ListCount > 0 Then
'We were successful in finding at least one protocol available on this machine
Exit Sub
End If
'None of the protocols specified in SETUP.LST are available on this machine. We need
'to let the user know what's wrong, including which protocol(s) were expected.
MsgError ResolveResString(resNOPROTOCOLSSUPPORTED1), vbExclamation Or vbOKOnly, gstrTitle
'
' Don't log the rest if this is SMS. Ok for silent mode since
' silent can take more than 255 characters.
'
If Not gfSMS Then
Dim strMsg As String
strMsg = ResolveResString(resNOPROTOCOLSSUPPORTED2) & vbLf
For i = 1 To gcProtocols
strMsg = strMsg & vbLf & Chr$(9) & gProtocol(i).strFriendlyName
Next i
MsgError strMsg, vbExclamation Or vbOKOnly, gstrTitle
End If
ExitSetup frmRemoteServerDetails, gintRET_FATAL
End Sub
'-----------------------------------------------------------
' SUB: strGetServerName
'
' Given a remote server registration file, retrieves the
' friendly name of the server
'-----------------------------------------------------------
Private Function strGetServerName(ByVal strRegFilename As String) As String
Const strKey = "AppDescription="
Dim strLine As String
Dim iFile As Integer
On Error GoTo DoErr
'This will have to do if we can't find the friendly name
strGetServerName = GetFileName(strRegFilename)
iFile = FreeFile
Open strRegFilename For Input Access Read Lock Read Write As #iFile
While Not EOF(iFile)
Line Input #iFile, strLine
If Left$(strLine, Len(strKey)) = strKey Then
'We've found the line with the friendly server name
Dim strName As String
strName = Mid$(strLine, Len(strKey) + 1)
If strName <> "" Then
strGetServerName = strName
End If
Close iFile
Exit Function
End If
Wend
Close iFile
Exit Function
DoErr:
strGetServerName = ""
End Function
Private Sub txtNetworkAddress_Change()
cmdOK.Enabled = fValid()
End Sub
'Returns True iff the inputs are valid
Private Function fValid() As Boolean
fValid = True
'
' If this is dcom, we don't care about the network protocol.
'
If m_fDCOM = False Then
If Not m_fNetworkProtocolSpecified And (cboNetworkProtocol.ListIndex < 0) Then
fValid = False
End If
End If
If Not m_fNetworkAddressSpecified And (txtNetworkAddress = "") Then
fValid = False
End If
End Function
Private Sub CheckSpecifiedProtocolSequence(ByVal strNetworkProtocol As String, ByVal strFriendlyServerName As String)
'Attempt to find the friendly name of this protocol from the list in SETUP.LST
Dim fSuccessReading As Boolean
Dim strFriendlyName As String
Dim i As Integer
strFriendlyName = strNetworkProtocol 'This will have to do if we can't find anything better
fSuccessReading = ReadProtocols(gstrSetupInfoFile, gstrINI_SETUP)
If fSuccessReading And gcProtocols > 0 Then
For i = 1 To gcProtocols
If gProtocol(i).strName = strNetworkProtocol Then
strFriendlyName = gProtocol(i).strFriendlyName
Exit For
End If
Next i
End If
'Now check to see if this protocol is available
If fIsProtocolSeqSupported(strNetworkProtocol, strFriendlyName) Then
'OK
Exit Sub
Else
'Nope, not supported. Give an informational message about what to do, then continue with setup.
Retry:
If gfNoUserInput Or MsgError( _
ResolveResString(resSELECTEDPROTONOTSUPPORTED, "|1", strFriendlyServerName, "|2", strFriendlyName), _
vbInformation Or vbOKCancel, _
gstrTitle) _
= vbCancel Then
'
' The user chose cancel. Give them a chance to exit (if this isn't a silent or sms install;
' otherwise any call to ExitSetup is deemed fatal.
'
ExitSetup frmRemoteServerDetails, gintRET_EXIT
GoTo Retry
Else
'The user chose OK. Continue with setup.
Exit Sub
End If
End If
End Sub
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -