The following code works for me in Map Basic.

I Haven't resolved stripping off Null Chars, but it seems to work OK anyway

include "mapbasic.def"

Define long integer

Type BrowseInfo
    hWndOwner As Long
    pIDLRoot As Long
    pszDisplayName As Long
    lpszTitle As Long
    ulFlags As Long
    lpfnCallback As Long
    lParam As Long
    iImage As Long
End Type

declare sub Main
Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, 
ByVal lpString2 As String) As Long
Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, lpBuffer As 
String) As Long

Global glogLayerState(1) as Logical     'Yes = Selectable, No = Not Selectable

'******************
Sub Main
        Dim iNull As Integer
        Dim lpIDList As Long
        Dim lResult As Long
        Dim sPath As String
        Dim udtBI As BrowseInfo
        Dim BIF_RETURNONLYFSDIRS as integer
        Dim MAX_PATH as integer

        BIF_RETURNONLYFSDIRS= 1
        MAX_PATH = 260

        'Set the owner window
        udtBI.hWndOwner = SystemInfo(SYS_INFO_APPLICATIONWND)
        'lstrcat appends the two strings and returns the memory address
        udtBI.lpszTitle = lstrcat("C:\", "")
        'Return only if the user selected a directory
        udtBI.ulFlags = BIF_RETURNONLYFSDIRS

    'Show the 'Browse for folder' dialog
    lpIDList = SHBrowseForFolder(udtBI)
    If lpIDList > 0 Then
        sPath = String$(MAX_PATH, "0")
        'Get the path from the IDList
        lResult = SHGetPathFromIDList (lpIDList, sPath)
        'free the block of memory
        call CoTaskMemFree( lpIDList)
        'iNull = InStr(1,sPath, vbNullChar)
        'If iNull Then
        '    sPath = Left$(sPath, iNull - 1)
        'End If

    End If

    note sPath

End Sub





********************************************************************************
Note: We are a Microsoft Office site.  Our base version is 4.3.  Please make sure
that files you send can be read in this format.

Any form of reproduction, dissemination, copying, disclosure,
modification, distribution and/or publication of this e-mail is strictly
prohibited save unless expressly authorised by the sender.

The information contained in this message is intended for the named
recipients only. It may contain privileged and confidential information and if you
are not the addressee or the person responsible for delivering this to the addressee,
you may not copy, distribute or take action in reliance on it.
If you have received this message in error, please notify the sender(s)
immediately by telephone. Please also destroy and delete as soon as possible
the message from your computer.
*****************************************************************************************************************************************************



_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.

Reply via email to