URLパスを取得しDOSパスに変換 <TOP>
PathCreateFromUrl
URLパスを取得しDOSパスに変換
'================================================================ '= URLパスを取得しDOSパスに変換 '= (PathCreateFromUrl.bas) '================================================================ #include "Windows.bi" ' URLパスを取得しDOSパスに変換 Declare Sub Api_PathCreateFromUrl Lib "shlwapi" Alias "PathCreateFromUrlA" (ByVal pszUrl$, ByVal pszPath$, ByRef pcchPath&, ByVal dwFlags&) Var Shared Edit1 As Object Var Shared Text1 As Object Var Shared Button1 As Object Edit1.Attach GetDlgItem("Edit1") : Edit1.SetFontSize 14 Text1.Attach GetDlgItem("Text1") : Text1.SetFontSize 14 Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14 '================================================================ '= Chr$(0)を取り除く '================================================================ Declare Function TrimNull (item As String) As String Function TrimNull(item As String) As String Var ePos As Integer ePos = Instr(item, Chr$(0)) If ePos Then TrimNull = Left$(item, ePos - 1) Else TrimNull = item End If End Function '================================================================ '= '================================================================ Declare Sub MainForm_Start edecl () Sub MainForm_Start() Edit1.SetWindowText "file:///C:/dir/myfile.ext" End Sub '================================================================ '= '================================================================ Declare Sub Button1_on edecl () Sub Button1_on() Var Buff As String Var sSave As String Buff = String$(100, 0) sSave = Edit1.GetWindowText Api_PathCreateFromUrl sSave, Buff, Len(Buff), 0 Text1.SetWindowText TrimNull(Buff) End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End