View Single Post
  #35 (permalink)  
Old 07-30-2007, 06:03 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 299
Karpagarajan is on a distinguished road
Default Re: VC++ Tips & Tricks

Hi Guys,

Here this is a very useful tip.

This is to call the VB DLL function in Visual C++ module.

DO the following code
// Add the following code in the StdAfx.h

#import "TestVBdll.dll"
using namespace TestVBdll;
// Add the following code in where you want to call the VB dll function

HRESULT hresult;
CLSID clsid;

CoInitialize(NULL); //initialize COM library
hresult=CLSIDFromProgID(OLESTR("TestVBdll.clsdll") ,&clsid);

_clsdll *t;
hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_ SERVER,__uuidof(_clsdll),(LPVOID *) &t);
if(FAILED(hresult))
{
//AfxMessageBox("Creation Failed");
return "failed";
}

t->TestVBFunction();
t->Release(); //call method
CoUninitialize(); //Unintialize the COM library

// End of the code
.......
bye
thanks
__________________
Karpagarajan. R
Necessity is the mother of invention

Last edited by Booom : 08-09-2007 at 05:43 AM.
Reply With Quote