gApi.cpp
资源名称:MyUnRar.rar [点击查看]
上传用户:sz4588
上传日期:2022-05-26
资源大小:2253k
文件大小:1k
源码类别:
压缩解压
开发平台:
Visual C++
- #include "StdAfx.h"
- #include "gAPI.h"
- CString ApiGetFileName(CString FullPath)
- {
- int n=FullPath.ReverseFind('\');
- int nL=FullPath.GetLength();
- return FullPath.Right(nL-n-1);
- }
- CString ApiGetFolderName(CString FullPath)
- {
- int n=FullPath.ReverseFind('\');
- return FullPath.Left(n+1);
- }
- bool GetFolder(CString& folderpath, const char* szCaption, HWND hOwner)
- {
- bool retVal = false;
- BROWSEINFO bi; // The BROWSEINFO struct tells the shell
- memset(&bi, 0, sizeof(bi)); //how it should display the dialog.
- bi.ulFlags =NULL; //BIF_USENEWUI;
- bi.hwndOwner = hOwner;
- bi.lpszTitle = szCaption;
- ::OleInitialize(NULL); // must call this if using BIF_USENEWUI
- // Show the dialog and get the itemIDList for the
- LPITEMIDLIST pIDL = ::SHBrowseForFolder(&bi); // selected folder.
- if(pIDL != NULL)
- {
- // Create a buffer to store the path, then
- char buffer[_MAX_PATH] = {' '}; // get the path.
- if(::SHGetPathFromIDList(pIDL, buffer) != 0)
- {
- folderpath = buffer; // Set the string value.
- retVal = true;
- }
- CoTaskMemFree(pIDL); // free the item id list
- }
- ::OleUninitialize();
- return retVal;
- }
English
