Jump to content
Fivewin Brasil

Procurar uma pasta no xHarbour


kapiaba

Recommended Posts

// Procurar uma pasta no xHarbour



#Include "FiveWin.ch"
#Include "\xHarbour\contrib\what32\include\commdlg.ch" // For BIF_USENEWUI

FUNCTION Main()

LOCAL cPath

cPath := ShBrowseForFolder(NIL , "This is text in the"+Chr(13)+"header of the file", BIF_USENEWUI )

RETURN cPath

#pragma BEGINDUMP
#include "windows.h" /* in bcc55/include folder */
#include "shlobj.h" /* in bcc55/include folder */

HB_FUNC( SHBROWSEFORFOLDER )
{
HWND hwnd = ISNIL (1) ? GetActiveWindow() : (HWND) hb_parnl(1);
BROWSEINFO BrowseInfo;
char *lpBuffer = (char*) hb_xgrab( MAX_PATH + 1 );
LPITEMIDLIST pidlBrowse;

SHGetSpecialFolderLocation(hwnd, ISNIL(4) ? CSIDL_DRIVES :
hb_parni(4), &pidlBrowse) ;
BrowseInfo.hwndOwner = hwnd;
BrowseInfo.pidlRoot = pidlBrowse;
BrowseInfo.pszDisplayName = lpBuffer;
BrowseInfo.lpszTitle = ISNIL (2) ? "Select a Folder" : hb_parcx(2);
BrowseInfo.ulFlags = hb_parni(3);
BrowseInfo.lpfn = NULL;
BrowseInfo.lParam = 1;
BrowseInfo.iImage = 0;
pidlBrowse = SHBrowseForFolder(&BrowseInfo);

if ( pidlBrowse )
{
SHGetPathFromIDList(pidlBrowse,lpBuffer);
hb_retc( lpBuffer );
}
else
{
hb_retc( "" );
}
hb_xfree( lpBuffer);
}

#pragma ENDDUMP


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...