Click here to Skip to main content
15,898,817 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Where to specify "domain" besides "username" and "password" using WinInet API? Pin
chairman nirvana25-Oct-06 20:24
chairman nirvana25-Oct-06 20:24 
QuestionCFileFind Pin
locoone25-Oct-06 14:39
locoone25-Oct-06 14:39 
AnswerRe: CFileFind Pin
Stephen Hewitt25-Oct-06 18:37
Stephen Hewitt25-Oct-06 18:37 
AnswerRe: CFileFind Pin
Hamid_RT25-Oct-06 19:38
Hamid_RT25-Oct-06 19:38 
AnswerRe: CFileFind Pin
Mila02525-Oct-06 19:43
Mila02525-Oct-06 19:43 
QuestionRe: CFileFind Pin
David Crow26-Oct-06 3:56
David Crow26-Oct-06 3:56 
AnswerRe: CFileFind Pin
locoone27-Oct-06 10:49
locoone27-Oct-06 10:49 
AnswerRe: CFileFind [modified] Pin
Stephen Hewitt26-Oct-06 18:09
Stephen Hewitt26-Oct-06 18:09 
Here's some code which shows how to use the shell interfaces to enumerate the contents of a folder, in this case the Desktop. Note that "My Computer" and the like appears but wouldn't if you used FindFirstFile and company. It's a console app using ATL smart pointers. I edited the "StdAfx.h" to just include <iostream>
and <atlbase.h>.
--------------------------------------------------------------------------------

// VDir.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <shlobj.h>
#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib")

void Go()
{
using namespace std;

HRESULT hr;

CComPtr<IMalloc> spAlloc;
hr = SHGetMalloc(&spAlloc);
if (FAILED(hr))
{
cerr << "SHGetMalloc failed!" << endl;
return;
}

CComPtr<IShellFolder> spDesktop;
hr = SHGetDesktopFolder(&spDesktop);
if (FAILED(hr))
{
cerr << "SHGetDesktopFolder failed!" << endl;
return;
}

CComPtr<IEnumIDList> spEnum;
hr = spDesktop->EnumObjects(
NULL,
SHCONTF_FOLDERS|SHCONTF_NONFOLDERS|SHCONTF_INCLUDEHIDDEN,
&spEnum
);
if (FAILED(hr))
{
cerr << "IShellFolder::EnumObjects failed!" << endl;
return;
}

LPITEMIDLIST pPIDL;
while ( (hr=spEnum->Next(1, &pPIDL, NULL))==S_OK )
{
STRRET Name;
hr = spDesktop->GetDisplayNameOf(pPIDL, SHGDN_NORMAL, &Name);
if (SUCCEEDED(hr))
{
LPWSTR pDisplayName;
hr = StrRetToStrW(&Name, pPIDL, &pDisplayName);
if (SUCCEEDED(hr))
{
USES_CONVERSION;
cout << W2CA(pDisplayName) << endl;
spAlloc->Free(pDisplayName);
}
}

spAlloc->Free(pPIDL);
}
}

int main(int argc, char* argv[])
{
OleInitialize(NULL);
Go();
OleUninitialize();

return 0;
}


Steve
GeneralRe: CFileFind Pin
locoone27-Oct-06 10:46
locoone27-Oct-06 10:46 
GeneralRe: CFileFind Pin
Stephen Hewitt29-Oct-06 12:14
Stephen Hewitt29-Oct-06 12:14 
GeneralRe: CFileFind Pin
locoone29-Oct-06 13:17
locoone29-Oct-06 13:17 
GeneralRe: CFileFind Pin
Stephen Hewitt29-Oct-06 13:29
Stephen Hewitt29-Oct-06 13:29 
GeneralRe: CFileFind Pin
locoone29-Oct-06 14:05
locoone29-Oct-06 14:05 
GeneralRe: CFileFind Pin
Stephen Hewitt29-Oct-06 14:16
Stephen Hewitt29-Oct-06 14:16 
GeneralRe: CFileFind Pin
locoone30-Oct-06 13:12
locoone30-Oct-06 13:12 
GeneralRe: CFileFind Pin
Stephen Hewitt30-Oct-06 13:37
Stephen Hewitt30-Oct-06 13:37 
GeneralRe: CFileFind Pin
locoone30-Oct-06 13:47
locoone30-Oct-06 13:47 
GeneralRe: CFileFind Pin
Stephen Hewitt30-Oct-06 13:59
Stephen Hewitt30-Oct-06 13:59 
GeneralRe: CFileFind Pin
locoone30-Oct-06 14:07
locoone30-Oct-06 14:07 
GeneralRe: CFileFind Pin
Stephen Hewitt30-Oct-06 14:19
Stephen Hewitt30-Oct-06 14:19 
GeneralRe: CFileFind Pin
Stephen Hewitt30-Oct-06 14:26
Stephen Hewitt30-Oct-06 14:26 
QuestionExcel Page Pin
roadme25-Oct-06 11:26
roadme25-Oct-06 11:26 
AnswerRe: Excel Page Pin
freeman86825-Oct-06 16:59
freeman86825-Oct-06 16:59 
GeneralRe: Excel Page [modified] Pin
freeman86825-Oct-06 17:01
freeman86825-Oct-06 17:01 
GeneralRe: Excel Page Pin
roadme27-Oct-06 8:42
roadme27-Oct-06 8:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.