IsURL メソッド(ActiveX)

指定された URL を確認します。

サポートされているプラットフォーム: Windows のみ

構文と要素

VBA:

RetVal = object.IsURL(URL)
object

タイプ: Utility

このメソッドが適用されるオブジェクト。

LocalFile

アクセス: 入力のみ

タイプ: 文字列

確認する URL。

戻り値(RetVal)

タイプ: ブール型

注意

「有効」な URL の定義はアプリケーションに依存します。というのは、特定のサードパーティ製アプリケーションにはインターネット プロトコルのすべてをサポートしていないものもあるからです。たとえば、ユーザを Web サイトに接続するよう促すアプリケーションには、FTP サイトへの接続は必要ないでしょう。このようなアプリケーションでは、「http://」以外で始まる URL が入力されると False の値が返されます。

AutoCAD ではこのメソッドの既定の機能は FTP、HTTP、HTTPS、および FILE プロトコルをサポートしています。

VBA:

Sub Example_IsRemoteFile()
    ' This example will prompt the user for a URL to download and will verify that
    ' a proper URL was entered.  After downloading, the example will attempt to load
    ' the downloaded URL as a drawing.
    '
    ' * Note: Remember to delete the downloaded file from your disk drive when finished.
    
    Dim Utility As AcadUtility
    Dim URL As String, DestFile As String, FileURL As String
    
    Set Utility = ThisDrawing.Utility   ' Connect to Utility object
    
GETURL:
    ' Prompt user for a URL to download.  This should be a URL to an AutoCAD drawing file.
    URL = Utility.GetString(False, vbLf & "Enter the complete URL of the file you wish to download: ")
    
    URL = Trim(URL)                     ' Get rid of blank spaces
    
    If URL = "" Then Exit Sub           ' Did user cancel

    ' Determine if user entered a valid URL; if not, prompt again
    If Not (Utility.IsURL(URL)) Then
        MsgBox "The URL you entered is not valid.  Make sure the syntax is a valid URL."
        GoTo GETURL
    End If
        
    ' Download URL
    Utility.GetRemoteFile URL, DestFile, True
    
    ' Display downloaded file information
    MsgBox URL & " was downloaded to: " & DestFile
   
    ' Use IsRemoteFile to determine if this file was downloaded from a URL.
    ' If it was, display the URL it was downloaded from
    '
    ' * Note: Although the results that IsRemoteFile will return are already known
    ' since the file was just downloaded it is important to know how this
    ' method can be used.
    If Utility.IsRemoteFile(DestFile, FileURL) Then
        MsgBox "The file: " & DestFile & " is a downloaded file and was downloaded from: " & FileURL
    Else
        MsgBox "The file: " & DestFile & " is not a downloaded file."
    End If

End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_IsRemoteFile()
    ;; This example will prompt the user for a URL to download and will verify that
    ;; a proper URL was entered.  After downloading, the example will provide information
    ;; about the downloaded drawing.
    ;;
    ;; * Note: Remember to delete the downloaded file from your disk drive when finished.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    (setq Utility (vla-get-Utility doc))   ;; Connect to Utility object
    
    ;; Prompt user for a URL to download.  This should be a URL to an AutoCAD drawing file.
    (setq URL (vla-GetString Utility :vlax-false "Enter the complete URL of the file you wish to download: "))
  
    (if (/= URL "")
        (progn
	           (if (= (vla-IsURL Utility URL) :vlax-false)
	               (alert "The URL you entered is not valid.  Make sure the syntax is a valid URL.")
	               (progn
	                   ;; Download URL
	                   (vla-GetRemoteFile Utility URL 'DestFile :vlax-true)
		    
	                   ;; Display downloaded file information
	                   (alert (strcat URL " was downloaded to: " DestFile "\n"))

	                   ;; Use IsRemoteFile to determine if this file was downloaded from a URL.
	                   ;; If it was, display the URL it was downloaded from
	                   ;;
	                   ;; * Note: Although the results that IsRemoteFile will return are already known
	                   ;; since the file was just downloaded it is important to know how this
	                   ;; method can be used.
	                   (if (= (vla-IsRemoteFile Utility DestFile URL) :vlax-true)
	                       (alert (strcat "The file: " DestFile " is a downloaded file and was downloaded from: " URL))
	                       (alert (strcat "The file: " DestFile " is not a downloaded file."))
	                   )
	               )
	           )
	       )
    )
)