by yu0627 » 2005年5月30日(月) 21:38
> Function GetFolderPath() As Long
> Dim bi As BROWSEINFO
> Dim pidl As Long
> Dim buf[MAX_PATH] As byte
>
> ZeroMemory(VarPtr(bi),Len(bi))
> bi.hwndOwner=0
> bi.lpszTitle="フォルダを選択してください"
> bi.ulFlags=BIF_RETURNONLYFSDIRS
>
> pidl=SHBrowseForFolder(bi)
>
> If pidl Then
> SHGetPathFromIDList(pidl,buf)
> CoTaskMemFree(pidl)
> GetFolderPath=1
> MessageBox(0,buf,"選択したパス",0)
> Else
> GetFolderPath=0
> End If
> End Function
以上のソースを以下のようにした。
Function GetFolderPath() As Long
Dim bi As BROWSEINFO
Dim pidl As Long
Dim buf[MAX_PATH] As byte
ZeroMemory(VarPtr(bi),Len(bi))
bi.hwndOwner=0
bi.lpszTitle="フォルダを選択してください"
bi.ulFlags=BIF_RETURNONLYFSDIRS
pidl=SHBrowseForFolder(bi)
If pidl Then
SHGetPathFromIDList(pidl,buf)
CoTaskMemFree(pidl)
GetFolderPath=1
MessageBox(0,buf,"選択したパス",0)
Else
GetFolderPath=0
End If
End Function
これでも、「pidl=SHBrowseForFolder(bi)」の部分でまだアクセス違反が起こります...。(泣)
> Function GetFolderPath() As Long
> Dim bi As BROWSEINFO
> Dim pidl As Long
> Dim buf[MAX_PATH] As byte
>
> ZeroMemory(VarPtr(bi),Len(bi))
> bi.hwndOwner=0
> bi.lpszTitle="フォルダを選択してください"
> bi.ulFlags=BIF_RETURNONLYFSDIRS
>
> pidl=SHBrowseForFolder(bi)
>
> If pidl Then
> SHGetPathFromIDList(pidl,buf)
> CoTaskMemFree(pidl)
> GetFolderPath=1
> MessageBox(0,buf,"選択したパス",0)
> Else
> GetFolderPath=0
> End If
> End Function
以上のソースを以下のようにした。
Function GetFolderPath() As Long
Dim bi As BROWSEINFO
Dim pidl As Long
Dim buf[MAX_PATH] As byte
ZeroMemory(VarPtr(bi),Len(bi))
bi.hwndOwner=0
bi.lpszTitle="フォルダを選択してください"
bi.ulFlags=BIF_RETURNONLYFSDIRS
pidl=SHBrowseForFolder(bi)
If pidl Then
SHGetPathFromIDList(pidl,buf)
CoTaskMemFree(pidl)
GetFolderPath=1
MessageBox(0,buf,"選択したパス",0)
Else
GetFolderPath=0
End If
End Function
これでも、「pidl=SHBrowseForFolder(bi)」の部分でまだアクセス違反が起こります...。(泣)