IFPCExplicitLinkTranslationMappings::Add method

Applies to: desktop apps only

The Add method creates a new FPCExplicitLinkTranslationMapping object in the collection and returns a reference to it.


  [in]   BSTR OriginalUrl,
  [in]   BSTR TranslatedUrl,
  [out]  IFPCExplicitLinkTranslationMapping **ppNewMapping
FPCExplicitLinkTranslationMappings.Add( _
  ByVal OriginalUrl As String, _
  ByVal TranslatedUrl As String, _
  ByRef ppNewMapping As IFPCExplicitLinkTranslationMapping _
) As FPCExplicitLinkTranslationMapping


  • OriginalUrl [in]

    C++ Required. BSTR that specifies the original URL in the new mapping.
    VB Required. String that specifies the original URL in the new mapping.
  • TranslatedUrl [in]

    C++ Required. BSTR that specifies the translated URL in the new mapping.
    VB Required. String that specifies the translated URL in the new mapping.
  • ppNewMapping [out]
    Address of an interface pointer that on return points to the new IFPCExplicitLinkTranslationMapping interface created.

Return value


This method can return one of the following:

  • S_OK, indicating that the operation succeeded.
  • An error code, indicating that the operation failed. In this case, the [out] parameter returned is a null object.


This method returns a reference to an FPCExplicitLinkTranslationMapping object if successful. Otherwise, an error is raised that can be intercepted by using an error handler.


The URLs specified in the OriginalUrl and TranslatedUrl parameters must specify HTTP or HTTPS as the protocol.


This VBScript script adds user-defined (explicit) global link translation mappings for the local array from a user-specified file. Note that the text file must contain a list of mappings consisting of two strings separated by a tab character with each mapping on a separate line.

Option Explicit
'Define the constants needed
Const Error_FileNotFound = &H80070002
Const Error_FileAlreadyExits = &H800700B7
Const Error_NoProtocol = &HC00403E0
Const ForReading = 1
Sub Main(args)
    If(args.Count <> 1) Then
    End If
    AddGlobalMappings args(0)
End Sub
Sub AddGlobalMappings(fileName)
    ' Create the root object.
    Dim root  ' The FPCLib.FPC root object
    Set root = CreateObject("FPC.Root")
    'Declare the other objects needed.
    Dim isaArray    ' An FPCArray object
    Dim mappings    ' An FPCExplicitLinkTranslationMappings collection
    Dim fso         ' A FileSystem object
    Dim fileStream  ' A TextStream object
    Dim textRead    ' A String
    Dim original    ' A String
    Dim translated  ' A String
    DIm i           ' An Integer
    Dim pos         ' An Integer
    ' Get references to the array object and the collection of user-defined
    ' global mappings.
    Set isaArray = root.GetContainingArray()
    Set mappings = isaArray.ArrayPolicy.WebProxy.ExplicitLinkTranslationMappings
    Set fso = CreateObject("Scripting.FileSystemObject")
    On Error Resume Next
    Set fileStream = fso.OpenTextFile(fileName, ForReading)
    If Err.Number <> 0 Then
        WScript.Echo "The file specified could not be found."
    End If
    On Error GoTo 0
    ' Clear the existing user-defined global mappings for the array
    ' and then add the explicit global mappings from the file.
    WScript.Echo "Removing the existing user-defined global mappings..." 
    i = mappings.Count
    Do While i > 0
        mappings.Remove i
        i = i - 1   
    WScript.Echo "Adding user-defined global mappings "  _ 
                 & "from the file " & fileName & "..."
    Do While fileStream.AtEndOfStream <> True
        textRead = fileStream.ReadLine
        If textRead <> "" Then
            pos = InStr(1, textRead, vbTab, vbTextCompare)
            If (pos <> 0) Then
                original = Left(textRead, pos - 1)
                translated = Right(textRead, Len(textRead) - pos)
                On Error Resume Next
                mappings.Add original, translated
                If Err.Number = Error_FileAlreadyExits Then
                    WScript.Echo "A duplicate mapping for " & original _
                                 & " was ignored."
                ElseIf Err.Number = Error_NoProtocol Then
                    WScript.Echo "A mapping without a valid protocol was ignored."
                End If
                On Error GoTo 0
            End If
        End If
    isaArray.Save True
    WScript.Echo "Done!"
End Sub 
Sub Usage()
    WScript.Echo "Usage:" & VbCrLf _
        & "  CScript " & WScript.ScriptName & " FileName" & VbCrLf _
        & "" & VbCrLf _
        & "  FileName  - Text file containing a list of mappings" 
End Sub


Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 (64-bit only)


Forefront Threat Management Gateway (TMG) 2010





See also




Build date: 7/12/2010