Click here to Skip to main content
16,005,682 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Create HBITMAP from HDC Pin
Hamid_RT29-Apr-08 1:47
Hamid_RT29-Apr-08 1:47 
Questioncloror masking of image Pin
trioum28-Apr-08 0:55
trioum28-Apr-08 0:55 
GeneralRe: cloror masking of image Pin
Rajkumar R28-Apr-08 1:01
Rajkumar R28-Apr-08 1:01 
QuestionHow to write this code using IFileOperation in Vista Pin
Mustanseer M S28-Apr-08 0:29
Mustanseer M S28-Apr-08 0:29 
QuestionRe: How to write this code using IFileOperation in Vista Pin
David Crow28-Apr-08 4:26
David Crow28-Apr-08 4:26 
GeneralRe: How to write this code using IFileOperation in Vista Pin
Mustanseer M S28-Apr-08 17:55
Mustanseer M S28-Apr-08 17:55 
QuestionRe: How to write this code using IFileOperation in Vista Pin
David Crow29-Apr-08 3:29
David Crow29-Apr-08 3:29 
GeneralRe: How to write this code using IFileOperation in Vista Pin
Mustanseer M S29-Apr-08 3:39
Mustanseer M S29-Apr-08 3:39 
Hi David,

I got this code from a MSDN newsgroup


<a href="http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.vc.mfc&amp;mid=eccb8144-68e3-4cc8-8457-73725d857019">http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.vc.mfc&amp;mid=eccb8144-68e3-4cc8-8457-73725d857019</a>[<a href="http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.vc.mfc&amp;mid=eccb8144-68e3-4cc8-8457-73725d857019" target="_blank" title="New Window">^</a>]


<code>//=======================================================================
//
// Deletes a file given its name (with full path).
//
// Uses new Vista IFileOperation COM interface
// (works in both ANSI/MBCS and Unicode builds, thanks to internal
// string conversion).
//
// Check HRESULT return value to see if operation was successful
// (SUCCEEDED( DeleteFile(...) )).
//
//=======================================================================
HRESULT DeleteFileWithIFO( LPCTSTR szFilename )
{
//
// Check input parameter
//
ASSERT( szFilename != NULL );
if ( szFilename == NULL )
return E_POINTER;


//
// Convert from TCHAR to wchar_t
// because IFileOperation::DeleteItem works only
// with Unicode UTF-16 strings.
//
CT2W wszFileToDelete( szFilename );


//
// Initialize COM engine
//
HRESULT hr = CoInitializeEx(NULL,
COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);

if (SUCCEEDED(hr))
{
//
// Create COM instance of IFileOperation
//
IFileOperation *pfo = NULL;
hr = CoCreateInstance(CLSID_FileOperation, NULL,
CLSCTX_ALL, IID_PPV_ARGS(&amp;pfo));

if (SUCCEEDED(hr))
{
//
// Set parameters for current operation
//
hr = pfo-&gt;SetOperationFlags(
FOF_SILENT | // do not display progress dialog-box
FOF_NOERRORUI // do not display error message to the user
);

if (SUCCEEDED(hr))
{
//
// Create IShellItem instance associated to file to delete
//
IShellItem *psiFileToDelete = NULL;
hr = SHCreateItemFromParsingName(
wszFileToDelete, NULL,
IID_PPV_ARGS(&amp;psiFileToDelete));

if (SUCCEEDED(hr))
{
//
// Declare this shell item (file) to be deleted
//
hr = pfo-&gt;DeleteItem( psiFileToDelete, NULL );
}

// Cleanup file-to-delete shell item
psiFileToDelete-&gt;Release();
psiFileToDelete = NULL;

}

if (SUCCEEDED(hr))
{
//
// Perform the deleting operation
//
hr = pfo-&gt;PerformOperations();
}
}

// Cleanup file operation object
pfo-&gt;Release();
pfo = NULL;
}

//
// Cleanup COM
//
CoUninitialize();


//
// Return operation result
//
return hr;
}</code>
GeneralRe: How to write this code using IFileOperation in Vista Pin
Ștefan-Mihai MOGA2-Dec-11 2:39
professionalȘtefan-Mihai MOGA2-Dec-11 2:39 
GeneralCMenu DeleteMenu() Pin
RockyJames28-Apr-08 0:29
RockyJames28-Apr-08 0:29 
QuestionRe: CMenu DeleteMenu() Pin
CPallini28-Apr-08 0:40
mveCPallini28-Apr-08 0:40 
GeneralFile in Append Mode Pin
john563228-Apr-08 0:11
john563228-Apr-08 0:11 
GeneralRe: File in Append Mode Pin
Jhony george28-Apr-08 0:21
Jhony george28-Apr-08 0:21 
GeneralRe: File in Append Mode Pin
CPallini28-Apr-08 0:24
mveCPallini28-Apr-08 0:24 
GeneralRe: File in Append Mode Pin
Hamid_RT29-Apr-08 1:47
Hamid_RT29-Apr-08 1:47 
JokeRe: File in Append Mode Pin
Nelek29-Apr-08 4:24
protectorNelek29-Apr-08 4:24 
GeneralRe: File in Append Mode Pin
Hamid_RT29-Apr-08 5:40
Hamid_RT29-Apr-08 5:40 
GeneralRe: File in Append Mode Pin
Nelek7-May-08 11:46
protectorNelek7-May-08 11:46 
GeneralRe: File in Append Mode Pin
Hamid_RT7-May-08 18:20
Hamid_RT7-May-08 18:20 
GeneralRe: File in Append Mode Pin
Nelek8-May-08 12:35
protectorNelek8-May-08 12:35 
Generalmessage handling for a popup window Pin
misha_grewal27-Apr-08 23:56
misha_grewal27-Apr-08 23:56 
GeneralRe: message handling for a popup window [modified] Pin
Rajkumar R28-Apr-08 4:00
Rajkumar R28-Apr-08 4:00 
GeneralRe: message handling for a popup window Pin
misha_grewal28-Apr-08 19:12
misha_grewal28-Apr-08 19:12 
GeneralRe: message handling for a popup window [modified] Pin
Rajkumar R28-Apr-08 20:10
Rajkumar R28-Apr-08 20:10 
Questioncan anybody tell me where a static variable get stored in memory Pin
Deepu Antony27-Apr-08 23:36
Deepu Antony27-Apr-08 23:36 

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.