Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am trying to execute the saveAll command from C++ code using DTE object. I have written a sample C++ (Win32 Console application).

 HRESULT hret=CoInitialize(NULL);

 CLSID clsid;
 hret = CLSIDFromProgID(L"VisualStudio.DTE.8.0",&clsid);
 assert(SUCCEEDED(hret));

 // Get IUnknown Interface
 IUnknown *pUnknown=0;
 hret = GetActiveObject(clsid,NULL,&pUnknown)    ;
 assert(SUCCEEDED(hret));

 EnvDTE80::DTE2Ptr pDTE2 = pUnknown;


 hret = pDTE2->ExecuteCommand(_T("File.NewFile"),_T(""));
 if(SUCCEEDED(hret))
 {
     MessageBox(NULL,L"Execute Command Success",L"TEST3",MB_OK);
 }

CoUninitialize();


But everytime ExecuteCommand returns E_FAIL. Any help will be appreciated!
Posted
Updated 13-May-10 14:56pm
v3

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900