Click here to Skip to main content
11,486,023 members (76,200 online)
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 Sergey Alexandrovich Kryukov 8,819
1 OriginalGriff 8,047
2 Sascha Lefèvre 3,199
3 Maciej Los 2,886
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 12 Oct 2011
Copyright © CodeProject, 1999-2015
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