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 20:12pm
Edited 11-Oct-11 22: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 Sergey Alexandrovich Kryukov 530
1 mhegazy94 460
2 Ravi Bhavnani 230
3 Kornfeld Eliyahu Peter 185
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 7,205
1 OriginalGriff 6,801
2 CPallini 5,350
3 George Jonsson 3,644
4 Gihan Liyanage 2,797


Advertise | Privacy | Mobile
Web02 | 2.8.140922.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