本文整理汇总了C++中LPMALLOC::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ LPMALLOC::Release方法的具体用法?C++ LPMALLOC::Release怎么用?C++ LPMALLOC::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPMALLOC
的用法示例。
在下文中一共展示了LPMALLOC::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetOLDDefaultDBName
CString GetOLDDefaultDBName()
{
CString csDefaultPath;
LPMALLOC pMalloc;
if(SUCCEEDED(::SHGetMalloc(&pMalloc)))
{
LPITEMIDLIST pidlPrograms;
SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidlPrograms);
TCHAR string[MAX_PATH];
SHGetPathFromIDList(pidlPrograms, string);
pMalloc->Free(pidlPrograms);
pMalloc->Release();
csDefaultPath = string;
csDefaultPath += "\\Ditto\\";
csDefaultPath += "DittoDB.mdb";
}
return csDefaultPath;
}
示例2: GetWindowsFolder
//----------------------------------------------------------------------------------------
static void GetWindowsFolder(int folder, nsFileSpec& outDirectory)
//----------------------------------------------------------------------------------------
{
if (gGetSpecialPathProc) {
TCHAR path[MAX_PATH];
HRESULT result = gGetSpecialPathProc(NULL, path, folder, true);
if (!SUCCEEDED(result))
return;
// Append the trailing slash
int len = PL_strlen(path);
if (len>1 && path[len-1] != '\\')
{
path[len] = '\\';
path[len + 1] = '\0';
}
outDirectory = path;
return;
}
LPMALLOC pMalloc = NULL;
LPSTR pBuffer = NULL;
LPITEMIDLIST pItemIDList = NULL;
int len;
// Get the shell's allocator.
if (!SUCCEEDED(SHGetMalloc(&pMalloc)))
return;
// Allocate a buffer
if ((pBuffer = (LPSTR) pMalloc->Alloc(MAX_PATH + 2)) == NULL)
return;
// Get the PIDL for the folder.
if (!SUCCEEDED(SHGetSpecialFolderLocation(
NULL, folder, &pItemIDList)))
goto Clean;
if (!SUCCEEDED(SHGetPathFromIDList(pItemIDList, pBuffer)))
goto Clean;
// Append the trailing slash
len = PL_strlen(pBuffer);
pBuffer[len] = '\\';
pBuffer[len + 1] = '\0';
// Assign the directory
outDirectory = pBuffer;
Clean:
// Clean up.
if (pItemIDList)
pMalloc->Free(pItemIDList);
if (pBuffer)
pMalloc->Free(pBuffer);
pMalloc->Release();
} // GetWindowsFolder
示例3: PopFolderDlg
bool CComDialog::PopFolderDlg(OUT char* path, IN char* title, IN BFFCALLBACK cb)
{
BROWSEINFO bi;
ZeroMemory(&bi, sizeof(BROWSEINFO));
//初始化入口参数bi开始****************************
bi.hwndOwner = _hwnd;//::AfxGetMainWnd()->GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = path;//此参数如为NULL则不能显示对话框
bi.lpszTitle = title;
bi.ulFlags = 0;
bi.lpfn = cb;
/* bi.iImage= IDR_MAINFRAME;*/
//初始化入口参数bi结束*****************************
LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);//调用显示选择对话框
if (pIDList)
{
SHGetPathFromIDList(pIDList, path);
//取得文件夹路径到Buffer里
LPMALLOC lpMalloc;
if (FAILED(SHGetMalloc(&lpMalloc)))
return false;
//释放内存
lpMalloc->Free(pIDList);
lpMalloc->Release();
return true;
}
else
{
return false;
}
}
示例4: SHGetSpecialFolderLocation
BOOL GetSpecialFolder(UINT SpecialFolder, CString &SpecialFolderString)
{
HRESULT hr;
LPITEMIDLIST pidl;
hr = SHGetSpecialFolderLocation(NULL, SpecialFolder, &pidl);
if(SUCCEEDED(hr))
{
// Convert the item ID list's binary representation into a file system path
char szPath[_MAX_PATH];
if(SHGetPathFromIDList(pidl, szPath))
{
// Allocate a pointer to an IMalloc interface
LPMALLOC pMalloc;
// Get the address of our task allocator's IMalloc interface
hr = SHGetMalloc(&pMalloc);
// Free the item ID list allocated by SHGetSpecialFolderLocation
pMalloc->Free(pidl);
// Free our task allocator
pMalloc->Release();
// Work with the special folder's path (contained in szPath)
SpecialFolderString = szPath; SpecialFolderString += "\\";
return TRUE;
}
}
return FALSE;
}
示例5: GetFolder
bool plBrowseFolder::GetFolder(char *path, const char *startPath, const char *title, HWND hwndOwner)
{
BROWSEINFO bi;
memset(&bi, 0, sizeof(bi));
bi.hwndOwner = hwndOwner;
bi.lpszTitle = title;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM) startPath;
ITEMIDLIST *iil = SHBrowseForFolder(&bi);
// Browse failed, or cancel was selected
if (!iil)
return false;
// Browse succeded. Get the path.
else
SHGetPathFromIDList(iil, path);
// Free the memory allocated by SHBrowseForFolder
LPMALLOC pMalloc;
SHGetMalloc(&pMalloc);
pMalloc->Free(iil);
pMalloc->Release();
return true;
}
示例6: DoModal
int CFolderDialog::DoModal()
{
int nReturn = IDOK;
// initialize the result to the starting folder value
m_strFinalFolderName = m_strInitialFolderName;
ITEMIDLIST* piid = NULL;
// call the shell function
piid = ::SHBrowseForFolder(&m_bi);
// process the result
if (piid && ::SHGetPathFromIDList(piid, m_szPath)) {
m_strFinalFolderName = m_szPath;
nReturn = IDOK;
} else {
nReturn = IDCANCEL;
}
// Release the ITEMIDLIST if we got one
if (piid) {
LPMALLOC lpMalloc;
VERIFY(::SHGetMalloc(&lpMalloc) == NOERROR);
lpMalloc->Free(piid);
lpMalloc->Release();
}
return nReturn;
}
示例7: GetSpecialFolderPath
/*! 特殊フォルダのパスを取得する
SHGetSpecialFolderPath API(shell32.dll version 4.71以上が必要)と同等の処理をする
@param [in] nFolder CSIDL (constant special item ID list)
@param [out] pszPath 特殊フォルダのパス
@author ryoji
@date 2007.05.19 新規
@date 2017.06.24 novice SHGetFolderLocation()に変更
@note SHGetFolderLocation()は、shell32.dll version 5.00以上が必要
*/
BOOL GetSpecialFolderPath( int nFolder, LPTSTR pszPath )
{
BOOL bRet = FALSE;
HRESULT hres;
LPITEMIDLIST pidl = NULL;
#if (WINVER >= _WIN32_WINNT_WIN2K)
hres = ::SHGetFolderLocation( NULL, nFolder, NULL, 0, &pidl );
if( SUCCEEDED( hres ) ){
bRet = ::SHGetPathFromIDList( pidl, pszPath );
::CoTaskMemFree( pidl );
}
#else
LPMALLOC pMalloc;
hres = ::SHGetMalloc( &pMalloc );
if( FAILED( hres ) )
return FALSE;
hres = ::SHGetSpecialFolderLocation( NULL, nFolder, &pidl );
if( SUCCEEDED( hres ) ){
bRet = ::SHGetPathFromIDList( pidl, pszPath );
pMalloc->Free( (void*)pidl );
}
pMalloc->Release();
#endif
return bRet;
}
示例8: GetFolder
plFileName plBrowseFolder::GetFolder(const plFileName &startPath, const ST::string &title, HWND hwndOwner)
{
BROWSEINFOW bi;
memset(&bi, 0, sizeof(bi));
ST::wchar_buffer titleW = title.to_wchar();
ST::wchar_buffer startPathW = startPath.WideString();
bi.hwndOwner = hwndOwner;
bi.lpszTitle = titleW.data();
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM) startPathW.data();
LPITEMIDLIST iil = SHBrowseForFolderW(&bi);
plFileName path;
if (!iil) {
// Browse failed, or cancel was selected
path = ST::null;
} else {
// Browse succeded. Get the path.
wchar_t buffer[MAX_PATH];
SHGetPathFromIDListW(iil, buffer);
path = ST::string::from_wchar(buffer);
}
// Free the memory allocated by SHBrowseForFolder
LPMALLOC pMalloc;
SHGetMalloc(&pMalloc);
pMalloc->Free(iil);
pMalloc->Release();
return path;
}
示例9: SelectFolder
BOOL Util::SelectFolder(HWND hWnd, LPSTR lpszFolder, LPCSTR lpszTitle,
UINT ulFlag) {
BROWSEINFO bi;
ITEMIDLIST *pidl;
memset(&bi, 0, sizeof(bi));
bi.hwndOwner = hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = lpszFolder;
bi.lpszTitle = lpszTitle;
// bi.ulFlags = BIF_RETURNONLYFSDIRS;BIF_NEWDIALOGSTYLE
bi.ulFlags = ulFlag;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
pidl = SHBrowseForFolder(&bi);
if (pidl) {
SHGetPathFromIDList(pidl, lpszFolder);
LPMALLOC lpMalloc;
if (SUCCEEDED(SHGetMalloc(&lpMalloc))) {
lpMalloc->Free(pidl);
lpMalloc->Release();
}
return TRUE;
}
return FALSE;
}
示例10: SHBrowseForFolder
void CPage1::OnBnClickedButton8()
{
// TODO: 在此添加控件通知处理程序代码
BROWSEINFO bi;
WCHAR Buffer[MAX_PATH];
//初始化入口参数bi开始
bi.hwndOwner = NULL;
bi.pidlRoot = NULL;
bi.pszDisplayName = Buffer;//此参数如为NULL则不能显示对话框
bi.lpszTitle = L"请选择文件夹";
bi.ulFlags = 0;
bi.lpfn = NULL;
//初始化入口参数bi结束
LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);//调用显示选择对话框
bool hadGet = false;
if(pIDList)
{
hadGet = (bool)SHGetPathFromIDList(pIDList,Buffer);
//取得文件夹路径到Buffer里
// m_ctrbrowse.SetWindowText(Buffer);//将路径保存在一个CString对象里
}
//MessageBox((LPCTSTR)Buffer, L"f");
if(hadGet)
GetDlgItem(IDC_EDIT3)->SetWindowTextW(Buffer);
LPMALLOC lpMalloc;
if(FAILED(SHGetMalloc(&lpMalloc))) return;
//释放内存
lpMalloc->Free(pIDList);
lpMalloc->Release();
}
示例11: OnBrowseCache
void COptHTTP::OnBrowseCache()
{
BROWSEINFO brw;
LPMALLOC pMalloc;
LPITEMIDLIST ret;
char dir[MAX_PATH];
if (NOERROR == ::SHGetMalloc(&pMalloc) ) {
m_CacheDir.GetWindowText(szCacheDir, MAX_PATH);
memset(&brw, 0, sizeof(BROWSEINFO));
brw.hwndOwner = this->GetSafeHwnd();
brw.pszDisplayName = dir;
brw.lpszTitle = "Select HTTP Cache Directory...";
brw.ulFlags = 0L;
brw.lpfn = LocCbck;
ret = SHBrowseForFolder(&brw);
if (ret != NULL) {
if (::SHGetPathFromIDList(ret, dir)) {
m_CacheDir.SetWindowText(dir);
}
pMalloc->Free(ret);
}
pMalloc->Release();
}
}
示例12: GetSpecialFolder
wxString CLocalTreeView::GetSpecialFolder(int folder, int &iconIndex, int &openIconIndex)
{
LPITEMIDLIST list;
if (SHGetSpecialFolderLocation((HWND)GetHandle(), folder, &list) != S_OK)
return _T("");
SHFILEINFO shFinfo;
if (!SHGetFileInfo((LPCTSTR)list, 0, &shFinfo, sizeof(shFinfo), SHGFI_PIDL | SHGFI_ICON | SHGFI_SMALLICON))
return _T("");
DestroyIcon(shFinfo.hIcon);
iconIndex = shFinfo.iIcon;
if (!SHGetFileInfo((LPCTSTR)list, 0, &shFinfo, sizeof(shFinfo), SHGFI_PIDL | SHGFI_ICON | SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_DISPLAYNAME))
return _T("");
DestroyIcon(shFinfo.hIcon);
openIconIndex = shFinfo.iIcon;
wxString name = shFinfo.szDisplayName;
LPMALLOC pMalloc;
SHGetMalloc(&pMalloc);
if (pMalloc)
{
pMalloc->Free(list);
pMalloc->Release();
}
else
wxLogLastError(wxT("SHGetMalloc"));
return name;
}
示例13: add_folder
BOOL CSoliDire::add_folder()
{
BROWSEINFO bi;
ZeroMemory(&bi,sizeof(BROWSEINFO));
LPMALLOC pMalloc;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
TCHAR * pth = new TCHAR[MAX_PATH];
if(pidl != NULL)
{
SHGetPathFromIDList(pidl,pth);
if(SUCCEEDED(SHGetMalloc(&pMalloc)))//pidl指向的对象用完应该释放,之前忽略了
{
pMalloc->Free(pidl);
pMalloc->Release();
}
CString path(pth);
if (path != "")
{
build_dir_tree(path);
SetModifiedFlag(TRUE);
printf("Folder %s successfully added.\n", path);
return TRUE;
}
}
return FALSE;
}
示例14: DoModal
BOOL CFolderDialog::DoModal(HWND hWnd, LPCTSTR lpszTitle, LPTSTR pDir)
{
BROWSEINFO bi = {};
bi.hwndOwner = hWnd;
bi.lpfn = reinterpret_cast<BFFCALLBACK>(BrowseCallBackProc);
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI;
bi.lParam = reinterpret_cast<LPARAM>(pDir);
bi.lpszTitle = lpszTitle;
LPITEMIDLIST pItemID = SHBrowseForFolder(&bi);
if (pItemID == nullptr)
return FALSE;
LPMALLOC pMalloc = nullptr;
if (SHGetMalloc(&pMalloc) == E_FAIL)
{
CError error;
error.Message(hWnd, _T("SHGetMalloc Error"));
return FALSE;
}
SHGetPathFromIDList(pItemID, pDir);
pMalloc->Free(pItemID);
pMalloc->Release();
return TRUE;
}
示例15: DirectorySelectDlg
std::string DirectorySelectDlg( HWND hParent, const TCHAR* title, const TCHAR* old )
{
std::string result;
LPMALLOC pMalloc;
if( ::SHGetMalloc( &pMalloc ) == NOERROR )
{
BROWSEINFO bi = {0};
bi.hwndOwner = hParent;
bi.lpszTitle = title;
bi.ulFlags = 0;
bi.lpfn = DirectorySelect_Callback;
bi.lParam = ( LPARAM )old;
TCHAR pszBuffer[MAX_PATH];
if( LPITEMIDLIST pidl =::SHBrowseForFolder( &bi ) )
{
if( ::SHGetPathFromIDList( pidl, pszBuffer ) )
{
result = pszBuffer;
}
pMalloc->Free( pidl );
}
pMalloc->Release();
}
return result;
}