Hi.. A another less documented API is MSDN is use of SHBrowseForFolder() in wince 6.0
Several people have trouble getting to use SHBrowseForFolder().
Here is the code snippet which will create a Folder selection dialog in Wince 6.0
1: TCHAR psz_result[MAX_PATH];
2: LPMALLOC p_malloc = 0; 3: LPITEMIDLIST pidl;
4: BROWSEINFO bi; 5:
6: #ifdef UNDER_CE 7: # define SHGetMalloc MySHGetMalloc
8: # define SHBrowseForFolder MySHBrowseForFolder
9: # define SHGetPathFromIDList MySHGetPathFromIDList
10:
11:
12: HMODULE ceshell_dll = LoadLibrary( _T("ceshell") );13: if( !ceshell_dll ) return;
14:
15: HRESULT (WINAPI *SHGetMalloc)(LPMALLOC *) =
16: (HRESULT (WINAPI *)(LPMALLOC *))
17: GetProcAddress( ceshell_dll, _T("SHGetMalloc") );
18: LPITEMIDLIST (WINAPI *SHBrowseForFolder)(LPBROWSEINFO) =
19: (LPITEMIDLIST (WINAPI *)(LPBROWSEINFO))
20: GetProcAddress( ceshell_dll, _T("SHBrowseForFolder") );
21: BOOL (WINAPI *SHGetPathFromIDList)(LPCITEMIDLIST, LPTSTR) =
22: (BOOL (WINAPI *)(LPCITEMIDLIST, LPTSTR))
23: GetProcAddress( ceshell_dll, _T("SHGetPathFromIDList") );
24:
25: if( !SHGetMalloc || !SHBrowseForFolder || !SHGetPathFromIDList )
26: {
27: _tprintf( _T( "couldn't load SHBrowseForFolder API") );
28: FreeLibrary( ceshell_dll );
29: return;
30: }
31: #endif
32:
33: if( !SUCCEEDED( SHGetMalloc(&p_malloc) ) ) goto error;
34:
35: memset( &bi, 0, sizeof(BROWSEINFO) );36: bi.hwndOwner = NULL;
37: bi.lpszTitle = L"Select Folder to backup.";
38: bi.pszDisplayName = psz_result;
39: bi.ulFlags = BIF_EDITBOX;
40: #ifndef UNDER_CE
41: bi.ulFlags |= BIF_USENEWUI;
42: #endif 43:
44: if( (pidl = SHBrowseForFolder( &bi ) ) )
45: {
46: SHGetPathFromIDList( pidl, psz_result );
47:
48: p_malloc->Free( pidl ); 49: }
50: _tprintf( _T( "%s"),psz_result );
51: error:
52:
53:
54:
55:
56: #ifdef UNDER_CE 57: FreeLibrary( ceshell_dll );
58: #endif
No comments:
Post a Comment