예제 #1
0
파일: settingspage.cpp 프로젝트: acml/cvsnt
void CSettingsPage::OnChangetemp()
{
	TCHAR fn[MAX_PATH];
	LPITEMIDLIST idl,idlroot;
	IMalloc *mal;

	SHGetSpecialFolderLocation(m_hWnd, CSIDL_DRIVES, &idlroot);
	SHGetMalloc(&mal);
	BROWSEINFO bi = { m_hWnd, idlroot, fn, _T("Select folder for CVS temporary files.  This folder must be writeable by all users that wish to use CVS."), BIF_NEWDIALOGSTYLE|BIF_RETURNONLYFSDIRS|BIF_RETURNFSANCESTORS, BrowseValid };
	idl = SHBrowseForFolder(&bi);

	mal->Free(idlroot);
	if(!idl)
	{
		mal->Release();
		return;
	}

	SHGetPathFromIDList(idl,fn);

	mal->Free(idl);
	mal->Release();

	m_edTempDir.SetWindowText(fn);

	SetModified();
}
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;
}
예제 #3
0
파일: util2.cpp 프로젝트: cmjonze/ncftp
extern "C" void
GetSpecialDir(char *dst, size_t size, int whichDir)
{
    LPITEMIDLIST idl;
    LPMALLOC shl;
    char path[MAX_PATH + 1];
    HRESULT hResult;

    memset(dst, 0, size);
    hResult = SHGetMalloc(&shl);
    if (SUCCEEDED(hResult)) {
        hResult = SHGetSpecialFolderLocation(
                      NULL,
                      whichDir,
                      &idl
                  );

        if (SUCCEEDED(hResult)) {
            if(SHGetPathFromIDList(idl, path)) {
                (void) strncpy(dst, path, size - 1);
                dst[size - 1] = '\0';
            }
            shl->Free(idl);
        }
        shl->Release();
    }
}	// GetSpecialDir
예제 #4
0
void CScanModelPaperDlg::OnBnClickedBtnBrowse()
{
	USES_CONVERSION;

	LPITEMIDLIST pidlRoot = NULL;
	SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidlRoot);
	BROWSEINFO	bi;
	TCHAR		szPath[MAX_PATH];
	TCHAR		szFolderPath[MAX_PATH];
	ZeroMemory(&bi, sizeof(LPBROWSEINFO));
	bi.pidlRoot = pidlRoot;
	bi.lpszTitle = _T("选择试卷文件夹路径");
	bi.lParam = NULL;
	bi.pszDisplayName = szPath;
	bi.ulFlags = BIF_RETURNONLYFSDIRS;
	bi.lpfn = NULL;
	LPITEMIDLIST lpIDList = SHBrowseForFolder(&bi);
	if (!lpIDList)
	{
		return;
	}
	SHGetPathFromIDList(lpIDList, szFolderPath);

	m_strSavePath = szFolderPath;
	UpdateData(FALSE);
}
예제 #5
0
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;
}
예제 #6
0
AnsiString PathUtil::GetUserDirectory() {
	AnsiString userDir = "./";

#ifdef __WIN32__
	char buffer[MAX_PATH];
	buffer[0] = '\0';
	LPITEMIDLIST pidl = NULL;
	LPMALLOC pMalloc;
	if (SUCCEEDED(SHGetMalloc(&pMalloc))) {
		SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl);
		if (pidl) {
			SHGetPathFromIDList(pidl, buffer);
		}
		pMalloc->Free(pidl);
		userDir = AnsiString(buffer);
	}
#elif __MACOSX__
	FSRef fileRef;
	OSStatus error = FSFindFolder(kUserDomain, kApplicationSupportFolderType, true, &fileRef);
	if (error == noErr) {
		char buffer[MAX_PATH];
		error = FSRefMakePath(&fileRef, (UInt8 *)buffer, sizeof(buffer));
		if (error == noErr)
			userDir = buffer;

	}
#elif __IPHONEOS__
	char path[MAX_PATH];
	IOS_GetDataDir(path);
	userDir = AnsiString(path);
#endif

	return userDir;
}
예제 #7
0
파일: ImpSfx.cpp 프로젝트: wkoiking/xyzzy
bool DirectoryRefDialog(HWND hWnd,char *Result)
{
    bool r = false;
    LPMALLOC Memory;
    LPCSTR Buffer;
    LPITEMIDLIST Ret;
    LPITEMIDLIST Root;
    SHGetMalloc(&Memory);
    Buffer = (LPSTR)Memory->Alloc(1000);
    SHGetSpecialFolderLocation(hWnd,CSIDL_DESKTOP,&Root);
    ZeroMemory(&BI,sizeof(BROWSEINFO));
    BI.hwndOwner = hWnd;
    BI.pidlRoot = Root;
    BI.ulFlags = BIF_STATUSTEXT | BIF_RETURNONLYFSDIRS;
    BI.lpszTitle = "展開先を指定してください";
    BI.pszDisplayName = (LPSTR)Buffer;
    BI.lpfn = BrowseCallbackProc;
    Ret = SHBrowseForFolder(&BI);
    if (SHGetPathFromIDList(Ret,(LPSTR)Buffer))
    {
        lstrcpy(Result,Buffer);
        r = true;
    }
    Memory->Free(Ret);
    Memory->Free(Root);
    Memory->Free((void*)Buffer);
    return r;
}
예제 #8
0
파일: func.cpp 프로젝트: chris2511/xca
// The intent of this function is to return the proper location for
// user-controlled settings on the current platform
// i.e. PROFILE\Application Data\xca on windows, HOME/.xca on UNIX,
// ~/Library/Preferences/xca on Mac OS X
QString getUserSettingsDir()
{
	QString rv;
#if defined(Q_OS_WIN32)
	LPITEMIDLIST pidl = NULL;
	TCHAR buf[255] = "";
	if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl))) {
	SHGetPathFromIDList(pidl, buf);
	}
	rv = buf;
	rv += QDir::separator();
	rv += "xca";
#elif defined(Q_OS_MAC)
  #if QT_VERSION < 0x050000
	rv = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
	rv.insert(rv.count() - QCoreApplication::applicationName().count(),
		QCoreApplication::organizationName());
  #else
	rv = QStandardPaths::writableLocation(
			QStandardPaths::GenericDataLocation) + "/data/" +
		QCoreApplication::organizationName() + "/" +
		QCoreApplication::applicationName();
  #endif
#else
	rv = QDir::homePath();
	rv += QDir::separator();
	rv += ".xca";
#endif
	return rv;
}
예제 #9
0
/*
 * Code to figure out the user's home directory using shell32.dll
 */
WCHAR*
getHomeFromShell32()
{
    HRESULT rc;
    LPITEMIDLIST item_list = 0;
    WCHAR *p;
    WCHAR path[MAX_PATH+1];
    int size = MAX_PATH+1;

    rc = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOPDIRECTORY, &item_list);
    if (!SUCCEEDED(rc)) {
        // we can't find the shell folder.
        return NULL;
    }

    path[0] = 0;
    SHGetPathFromIDListW(item_list, (LPWSTR)path);

    /* Get the parent of Desktop directory */
    p = wcsrchr(path, L'\\');
    if (p) {
        *p = 0;
    }

    /*
     * We've been successful.  Note that we don't free the memory allocated
     * by ShGetSpecialFolderLocation.  We only ever come through here once,
     * and only if the registry lookup failed, so it's just not worth it.
     *
     * We also don't unload the SHELL32 DLL.  We've paid the hit for loading
     * it and we may need it again later.
     */
    return _wcsdup(path);
}
예제 #10
0
CString CShortcutNBookmark::GetSpecialFolderLocation(int nFolder)
{
	CString Result;
	
	LPITEMIDLIST pidl;
	HRESULT hr = SHGetSpecialFolderLocation(NULL, nFolder, &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))
		{
			Result = szPath;
		}
		else
		{
			ATLASSERT(FALSE);
		}
	}
	else
	{
		ATLASSERT(FALSE);
	}
	
	return Result;
}
예제 #11
0
파일: pageabout.c 프로젝트: Nikers/T-Clock
 //================================================================================================
//----------------------------------------+++--> Remove Launch T-Clock on Windows Startup ShortCut:
void RemoveStartup(HWND hDlg) { //----------------------------------------------------------+++-->
	LPITEMIDLIST pidl;
	char dstpath[MAX_PATH], path[MAX_PATH], path2[MAX_PATH];
	char *lpStr1, *lpStr2;
	int	retval;	

  if(!FileExists(hDlg)) return;

  if(SHGetSpecialFolderLocation(hDlg, CSIDL_STARTUP, &pidl) == NOERROR && SHGetPathFromIDList(pidl, dstpath) == TRUE);
  else return;

  if(MyMessageBox(hDlg, "Remove Shortcut From the Startup Folder.\nAre You Sure?", CONF_START, MB_YESNO, MB_ICONQUESTION) != IDYES) return;

  strcpy(path, dstpath);
  strcat(path, "\\");
  strcat(path, CONF_START);
  strcat(path, ".lnk");
  lpStr1 = path;
  retval = DeleteFile(lpStr1);
  if(retval == 1) return;
  else{
	strcpy(path2, dstpath);
	strcat(path2, "\\");
	strcat(path2, CONF_START);
    strcat(path2, ".lnk");
	lpStr2 = path2;
	retval = DeleteFile(lpStr2);
	if(retval == 1) return;
  }
 return;
}
BOOL CMyUtils::GetSpecialFolder(int nFolder, TCHAR strFolder[MAX_PATH])
{
	TCHAR	*p = NULL;
	
	LPITEMIDLIST	pidl = NULL;
	IMalloc	*pMalloc = NULL;
	BOOL	bRet = FALSE;
	
	if (SUCCEEDED(SHGetMalloc(&pMalloc)))
	{
		pMalloc->AddRef();
		SHGetSpecialFolderLocation(NULL, nFolder, &pidl);
		
		if (pidl)
        {                      
			bRet = SHGetPathFromIDList(pidl, strFolder);
            // Free the PIDL returned by SHGetSpecialFolderLocation.
           pMalloc->Free(pidl);
        }

        // Release the IMalloc interface.
        pMalloc->Release();
    }

	return bRet;
}
예제 #13
0
void CRecBinViewer::Properties (CSelRowArray &ar)
{	
	CShellContextMenu scm;
	IShellFolder*psfRecycle = NULL;
	
	IShellFolder* psfDesktop = NULL;
	SHGetDesktopFolder (&psfDesktop);	
	LPITEMIDLIST pidl = NULL;
	SHGetSpecialFolderLocation (NULL, CSIDL_BITBUCKET, &pidl);
	
	psfDesktop->BindToObject(pidl, NULL, IID_IShellFolder, (LPVOID *)&psfRecycle);

	LPITEMIDLIST *pidlArray = (LPITEMIDLIST *) malloc (ar.size () * sizeof (LPITEMIDLIST));


	for (int i = 0 ; i < static_cast<int>(ar.size()) ; i++)				
		pidlArray[i] = m_List[ar[i].m_nRow-1].m_PIDL;		
	
	scm.SetObjects (psfRecycle, pidlArray, ar.size ());
	free (pidlArray);
	psfDesktop->Release ();

	scm.InvokeCommand (_T("properties"));	
	if (psfRecycle)
		psfRecycle->Release ();
}
예제 #14
0
CString CFileServerDlg::GetLastFileDialogPath()
{
	try
	{
		char lpszDefaultDir[MAX_PATH];
		::GetCurrentDirectory(MAX_PATH, lpszDefaultDir);

		char szDocument[MAX_PATH]={0};   
		memset(lpszDefaultDir,0,_MAX_PATH);   

		LPITEMIDLIST pidl = NULL;   
		SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &pidl);   
		if (pidl && SHGetPathFromIDList(pidl, szDocument))   
		{   
			//GetShortPathName(szDocument, lpszDefaultDir, _MAX_PATH);   
			lstrcpy(lpszDefaultDir, szDocument);
		}

		char lpszPath[MAX_PATH];
		ProgramConfig pConfig;
		pConfig.SetConfigFileName("FileSetting.ini");
		pConfig.ReadStringConfigParameter("File Setting", "LastFileDialogPath", lpszPath, lpszDefaultDir);

		CString strPath;
		strPath = lpszPath;
		return strPath;
	}
	catch(...)
	{
		if (gl_pLogger) gl_pLogger->log_error("CFileServerDlg::GetLastFileDialogPath unknown exception");
	}
	return "";
}
예제 #15
0
void CRecBinViewer::ContextMenu (CView* pView, CSelRowArray &ar, CPoint &pt) 
{
	CShellContextMenu scm;
	IShellFolder*psfRecycle = NULL;
	
	IShellFolder* psfDesktop = NULL;
	SHGetDesktopFolder (&psfDesktop);	
	LPITEMIDLIST pidl = NULL;
	SHGetSpecialFolderLocation (NULL, CSIDL_BITBUCKET, &pidl);
	
	psfDesktop->BindToObject(pidl, NULL, IID_IShellFolder, (LPVOID *)&psfRecycle);

	LPITEMIDLIST *pidlArray = (LPITEMIDLIST *) malloc (ar.size () * sizeof (LPITEMIDLIST));

	
	for (unsigned int i = 0 ; i < ar.size () ; i++)				
		pidlArray[i] = m_List[ar[i].m_nRow-1].m_PIDL;		
	
	scm.SetObjects (psfRecycle, pidlArray, ar.size ());
	free (pidlArray);
	psfDesktop->Release ();

	scm.ShowContextMenu (pView, pt);
	if (psfRecycle)
		psfRecycle->Release ();
	
}
예제 #16
0
static char *win_special_path (int folder)
{
    TCHAR dpath[MAX_PATH];
    LPITEMIDLIST id_list;
    DWORD result;
    LPMALLOC allocator;
    char *ret = NULL;

    if (SHGetSpecialFolderLocation(NULL, folder | CSIDL_FLAG_CREATE, 
				   &id_list) != S_OK) {
	return NULL;
    }

    result = SHGetPathFromIDList(id_list, dpath);

    if (result) {
	ret = gretl_strdup(dpath);
    }

    if (SHGetMalloc(&allocator) == S_OK) {
	allocator->lpVtbl->Free(allocator, id_list);
	allocator->lpVtbl->Release(allocator);
    }

    return ret;
}
//----------------------------------------------------------------------------------------
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
예제 #18
0
파일: pageabout.c 프로젝트: Nikers/T-Clock
 //================================================================================================
//---------------------------+++--> Verify Existance of Launch T-Clock on Windows Startup ShortCut:
BOOL FileExists(HWND hDlg) { //-------------------------------------------------------------+++-->
	LPITEMIDLIST pidl;
	char dstpath[MAX_PATH], path[MAX_PATH], path2[MAX_PATH];
	char *lpStr1, *lpStr2;
	int	retval;	

  if(SHGetSpecialFolderLocation(hDlg, CSIDL_STARTUP, &pidl) == NOERROR 
						&& SHGetPathFromIDList(pidl, dstpath) == TRUE);
  else return FALSE;

  strcpy(path, dstpath);
  strcat(path, "\\");
  strcat(path, CONF_START);
  strcat(path, ".lnk");
  lpStr1 = path;
  retval = PathFileExists(lpStr1);
  if(retval == 1) return TRUE;
  else{
	strcpy(path2, dstpath);
	strcat(path2, "\\");
	strcat(path2, CONF_START);
    strcat(path2, ".lnk");
	lpStr2 = path2;
	retval = PathFileExists(lpStr2);
	if(retval == 1) return TRUE;
  }
 return FALSE;
}
예제 #19
0
파일: ttmlib.c 프로젝트: lifangbo/teraterm
int DoGetSpecialFolder(int CSIDL, PCHAR dest, int dest_len)
{
	OSVERSIONINFO osvi;
	char Path[MAX_PATH] = "";
	LPITEMIDLIST pidl;

	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&osvi);
	if ( (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion == 4) ||
	     (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) ) {
		switch (CSIDL) {
			case CSIDL_COMMON_DESKTOPDIRECTORY:
			case CSIDL_COMMON_STARTMENU:
			case CSIDL_COMMON_PROGRAMS:
			case CSIDL_COMMON_STARTUP:
				return 0;
		}
	}

	if (SHGetSpecialFolderLocation(NULL, CSIDL, &pidl) != S_OK) {
		return 0;
	}

	SHGetPathFromIDList(pidl, Path);
	CoTaskMemFree(pidl);

	strncpy_s(dest, dest_len, Path, _TRUNCATE);
	return 1;
}
예제 #20
0
static nsresult
GetShellFolderPath(int folder, nsAString& _retval)
{
  wchar_t* buf;
  uint32_t bufLength = _retval.GetMutableData(&buf, MAXPATHLEN + 3);
  NS_ENSURE_TRUE(bufLength >= (MAXPATHLEN + 3), NS_ERROR_OUT_OF_MEMORY);

  nsresult rv = NS_OK;

  LPITEMIDLIST pItemIDList = nullptr;

  if (SUCCEEDED(SHGetSpecialFolderLocation(nullptr, folder, &pItemIDList)) &&
      SHGetPathFromIDListW(pItemIDList, buf)) {
    // We're going to use wcslen (wcsnlen not available in msvc7.1) so make
    // sure to null terminate.
    buf[bufLength - 1] = L'\0';
    _retval.SetLength(wcslen(buf));
  } else {
    _retval.SetLength(0);
    rv = NS_ERROR_NOT_AVAILABLE;
  }

  CoTaskMemFree(pItemIDList);

  return rv;
}
예제 #21
0
bool Preferences::GetMyDocuments(CString* pPath)
{
    LPITEMIDLIST pidl = NULL;
    LPMALLOC lpMalloc = NULL;
    HRESULT hr;
    bool result = false;

    hr = ::SHGetMalloc(&lpMalloc);
    if (FAILED(hr))
       return NULL;

    hr = SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &pidl);
    if (FAILED(hr)) {
        LOGW("WARNING: unable to get CSIDL_PERSONAL");
        goto bail;
    }

    result = (Pidl::GetPath(pidl, pPath) != FALSE);
    if (!result) {
        LOGW("WARNING: unable to convert CSIDL_PERSONAL to path");
        /* fall through with "result" */
    }

bail:
    lpMalloc->Free(pidl);
    lpMalloc->Release();
    return result;
}
예제 #22
0
// YOU must free the returned string
char * getSpecialFolder (int nFolder, HWND hWnd)
{
    LPMALLOC pMalloc;
    LPITEMIDLIST pidl;

    ArrayPtr<char> str = new char [MAX_PATH + 30];
    if (str == 0)
	throw AppException (WHERE, ERR_OUT_OF_MEMORY);

    if (FAILED (SHGetMalloc (&pMalloc)))
	return NULL;

    if (FAILED (SHGetSpecialFolderLocation (hWnd, nFolder, &pidl))) {
	pMalloc->Release ();
	return NULL;
    }

    if (SHGetPathFromIDList (pidl, str) != TRUE) {
	pMalloc->Free (pidl);
	pMalloc->Release ();
	return NULL;
    }

    pMalloc->Free (pidl);
    pMalloc->Release ();

    return str.detach ();
}
예제 #23
0
파일: misc.cpp 프로젝트: akavel/wed-editor
 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;
}
예제 #24
0
BOOL CRecBinViewer::GetFolder2 ()
{
	BOOL			bReturn			= FALSE;
	STRRET			strRet;
	LPSHELLFOLDER	pDesktop		= NULL;
	LPITEMIDLIST	pidlRecycleBin	= NULL;
	CString			dspName;

	
	if (NULL != m_pFolder2)
	{
		m_pFolder2->Release ();
		m_pFolder2 = NULL;
	}
	
	if ((SUCCEEDED (SHGetDesktopFolder(&pDesktop))) &&
		(SUCCEEDED (SHGetSpecialFolderLocation (m_hWnd, CSIDL_BITBUCKET, &pidlRecycleBin))))
	{
		if (SUCCEEDED (pDesktop->BindToObject(pidlRecycleBin, NULL, IID_IShellFolder2, (LPVOID *)&m_pFolder2)))
		{
			if (S_OK == pDesktop->GetDisplayNameOf (pidlRecycleBin, SHGDN_NORMAL, &strRet))			
				GetName (strRet, dspName);			
			bReturn = TRUE;
		}
	}
		
	CoTaskMemFree (pidlRecycleBin);
	
	if (NULL != pDesktop) pDesktop->Release();
	
	return bReturn;
}
예제 #25
0
AnsiString GetSystemPath(int nFolder)
{
    char StartPath[MAXPATH];
    LPITEMIDLIST pidl;
    SHGetSpecialFolderLocation(Application->Handle, nFolder , &pidl); //CSIDL_STARTUP, CSIDL_STARTMENU, CSIDL_PROGRAMS
    SHGetPathFromIDList(pidl, StartPath);
    return AnsiString(StartPath);
}
예제 #26
0
void RefreshFolderViews(UINT csidl)
{
    PIDLIST_ABSOLUTE pidl;
    if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, csidl, &pidl)))
    {
        SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST, pidl, 0);
        CoTaskMemFree(pidl);
    }
}
예제 #27
0
CString AfxGetDefaultDirectory(bool bForceNonEmpty /*= true*/,bool bNewProject /*= false*/)
{
	////////////////////////
	//Get default directory
	CString strPersonalDir;

	// - New Project?
	if (!bNewProject)
	{
		// - Get LastOpenedFolder
		strPersonalDir = CConfiguration::GetInstance()->m_strLastOpenedFolder;
		if (strPersonalDir.IsEmpty() || !CPathTool::Exists(strPersonalDir))
		{
			// - Project opened? ==> Working Dir is default
			CLaTeXProject* pLProject = theApp.GetProject();
			if (pLProject) strPersonalDir = pLProject->GetWorkingDirectory();
		}
	}

	// - No Project? ==> Try it with the default dir from the config
	if (strPersonalDir.IsEmpty())
	{
		strPersonalDir = CConfiguration::GetInstance()->m_strDefaultPath;
	}

	// - Still empty? ==> Get the system default for "My documents"
	if (strPersonalDir.IsEmpty())
	{
		LPITEMIDLIST lpidl;
		if (SHGetSpecialFolderLocation(AfxGetMainWnd()->m_hWnd,CSIDL_PERSONAL,&lpidl) == NOERROR)
		{
			SHGetPathFromIDList(lpidl,strPersonalDir.GetBuffer(MAX_PATH));
			strPersonalDir.ReleaseBuffer();

			// free memory
			LPMALLOC lpMalloc;
			SHGetMalloc(&lpMalloc);
			if (lpMalloc)
				lpMalloc->Free(lpidl);
		}
	}


	// - Still empty? ==> Hell, this is hard. Lets try this.
	if (bForceNonEmpty && strPersonalDir.IsEmpty())
	{
		strPersonalDir = theApp.GetWorkingDir();
	}

	// - Still empty? ==> Hell, this is hard. Lets try this.
	if (bForceNonEmpty && strPersonalDir.IsEmpty())
	{
		strPersonalDir = _T("C:\\");
	}

	return strPersonalDir;
}
BOOL CFileNavDlg::GetRecentDirectory(CString& strRecent)
{
	TCHAR lpszPath[MAX_PATH];
	LPITEMIDLIST pidl;
	SHGetSpecialFolderLocation(m_hWnd, CSIDL_RECENT, &pidl);
	SHGetPathFromIDList(pidl, lpszPath);
	strRecent = lpszPath;

	return TRUE;
}
예제 #29
0
파일: vmsFileUtil.cpp 프로젝트: naroya/fdm
void vmsFileUtil::GetAppDataPath(LPCSTR pszAppName, LPSTR szPath)
{
	LPITEMIDLIST pidl = NULL;
	SHGetSpecialFolderLocation (NULL, CSIDL_APPDATA, &pidl);
	SHGetPathFromIDList (pidl, szPath);
	
	vmsFileUtil::MakePathOK (szPath);
	lstrcat (szPath, pszAppName);
	lstrcat (szPath, "\\");
}
예제 #30
0
LPITEMIDLIST get_folder_pidl (const char *rawpath)
{
	if (NULL==rawpath) return NULL;

	char path [MAX_PATH];
	char temp [MAX_PATH];
	unquote(temp, rawpath);

	if (false == is_relative_path(temp))
	{
		if (is_alpha(temp[0]) && temp[1] == ':' && temp[2] == 0)
			temp[2] = '\\', temp[3] = 0;
		return sh_getpidl(NULL, temp);
	}

	const char *p = temp;
	int id = get_csidl(&p);
	if (NO_CSIDL == id || CSIDL_BLACKBOX == id || CSIDL_CURTHEME == id)
	{
		GetBlackboxPath(path, MAX_PATH);
		if (NO_CSIDL != id) path[strlen(path)-1] = 0;
		if (p) strcat(path, p);
		return sh_getpidl(NULL, path);
	}

	// special folders, like CONTROLS
	LPITEMIDLIST pID1, pID;

	if (NOERROR != SHGetSpecialFolderLocation(NULL, id, &pID1))
		return sh_getpidl(NULL, temp);

	if (NULL == p)
	{
		pID = duplicateIDlist(pID1);
	}
	else
	{
		pID = NULL;
		// a subdirectory is specified, like APPDATA\microsoft
		// so get its local pidl and append it
		IShellFolder*  pThisFolder = sh_get_folder_interface(pID1);
		if (pThisFolder)
		{
			LPITEMIDLIST pID2 = sh_getpidl(pThisFolder, p+1);
			if (pID2)
			{
				pID = joinIDlists(pID1, pID2);
				m_free(pID2);
			}
		}
	}

	SHMalloc_Free(pID1);
	return pID;
}