Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: COM VBA VC++
i am using msdev editor for my c++ programing..
 

i have one vb script.. But i want to do same operation using my c++ program..
 
if any one explain me how..
 

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("c:\dmmm\df\*")
 

 
how to write the same coding in c++
Posted 11-Oct-11 21:12pm
Edited 11-Oct-11 23:33pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can create it by creating a COM object.
 
Ex.
HRESULT hr;
CComPtr pDisp;
hr = pDisp.CoCreateInstance( L"Scripting.FileSystemObject" );//creates the object
ATLASSERT( SUCCEEDED(hr) );
CComDispatchDriver disDrv( pDisp );
CComVariant funcArg( LPCTSTR(_T("D:\\test.txt")) ), ret( false );
hr = disDrv.Invoke1(L"DeleteFile", &funcArg, &ret );//delete the file
ATLASSERT( SUCCEEDED(hr) );
 
You need to include for this
  Permalink  
v4
Comments
aimdharma at 12-Oct-11 8:04am
   
CComDispatchDriver disDrv( pDisp );
 
in that line CComDispatchDriver is undeclare..
 
what header file i want include
Richard MacCutchan at 12-Oct-11 8:25am
   
Please format your code blocks correctly, as shown above.
AnamikaBhattacharya at 12-Oct-11 8:42am
   
include atlbase.h for this
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Instead of creating such object, you may use SHFileOperation function[^] for the purpose.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,327
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,920


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 12 Oct 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100