Click here to Skip to main content
11,704,107 members (57,627 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 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 745
1 OriginalGriff 520
2 Maciej Los 475
3 Andy Lanng 284
4 CPallini 275
0 OriginalGriff 8,784
1 Sergey Alexandrovich Kryukov 7,843
2 CPallini 5,107
3 Maciej Los 4,726
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 2 Jul 2015
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