パスを構成する文字の種別を判定 <TOP>
PathGetCharType パスを構成する文字の種別を判定
    
    
'================================================================
'= パスを構成する文字の種別を判定
'=    (PathGetCharType.bas)
'================================================================
#include "Windows.bi"
#define GCT_INVALID &H0                                 'パスに使用できない
#define GCT_LFNCHAR &H1                                 '長い形式のファイル名に使用することができる
#define GCT_SEPARATOR &H8                             'パスの区切りの文字である
#define GCT_SHORTCHAR &H2                             '短い形式のファイル名に使用することができる
#define GCT_WILD &H4                                       'ワイルドカード文字である
' パスを構成する文字の種別を判定
Declare Function Api_PathGetCharType& Lib "shlwapi" Alias "PathGetCharTypeA" (ByVal ch As Byte)
Var Shared Text1 As Object
Var Shared Text2 As Object
Var Shared Edit1 As Object
Var Shared Button1 As Object
Text1.Attach GetDlgItem("Text1") : Text1.SetFontSize 14
Text2.Attach GetDlgItem("Text2") : Text2.SetFontSize 14
Edit1.Attach GetDlgItem("Edit1") : Edit1.SetFontSize 14
Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14
'================================================================
'=
'================================================================
Declare Sub Button1_on edecl ()
Sub Button1_on()
    Var MyStr As String
    Var txt As String
    Var Ret As Long
    MyStr = Edit1.GetWindowText
    Select Case Api_PathGetCharType(Asc(MyStr))
        Case GCT_INVALID
            txt = "この文字はパスに使用できません"
        Case GCT_LFNCHAR
            txt = "この文字は長い形式のファイル名に使用することができます"
        Case GCT_SHORTCHAR
            txt = "この文字は短い形式のファイル名に使用することができます"
        Case GCT_WILD
            txt = "この文字はワイルドカード文字です"
        Case GCT_SEPARATOR
            txt = "この文字はパスの区切りの文字です"
    End Select
    
    Text2.SetWindowText "【" & MyStr & "】:" & txt
End Sub
'================================================================
'=
'================================================================
Declare Sub Edit1_SetFocus edecl ()
Sub Edit1_SetFocus()
    Text2.SetWindowText ""
End Sub
'================================================================
'=
'================================================================
While 1
    WaitEvent
Wend
Stop
End