How to import VB Dll into VC++ Program and How to use functions from VB dll??
-
Hi Sandip, I used like this but i am getting errors..I am writting like this: ::CoInitialize(NULL); //note this change after taking out the no_namespace macro //if there is no namespace then also the progid has to be __uuidof(VbDll::CVbDll) like this SampleDll::_FunctionClass sample; HRESULT hr=sample.CreateInstance(__uuidof(SampleDll::_FunctionClass)); //here the progid is VbDll::CVbDll) //not just CVbDll //sample.AddRef(); BSTR server,usr,pwd,Temp,Temp3; BOOL bstr; Temp=SysAllocString(L"21\8\2008"); str=Temp; MessageBox(str); Temp3=SysAllocString(L"21\7\2008"); str=Temp3; MessageBox(str); server=SysAllocString(L"savitri"); str=server; MessageBox(str); usr=SysAllocString(L"root"); str=usr; MessageBox(str); pwd=SysAllocString(L"base"); str=pwd; MessageBox(str); BOOL bstrMyString;//=TRUE; //check for the instance bstrMyString=sample.ProcessingInformation(&Temp,&Temp3,&server,&usr,&pwd); str.Format("%d\n", bstrMyString); MessageBox(str, "MyString aus VB", MB_OK); sample.Release(); ::CoUninitialize(); It is giving errors... 1. C:\Program Files\Microsoft Visual Studio\My Projects\UseVbDll\UseVbDllDlg.cpp(194) : error C2259: '_FunctionClass' : cannot instantiate abstract class due to following members: c:\program files\microsoft visual studio\my projects\usevbdll\debug\sampledll.tlh(34) : see declaration of '_FunctionClass' 2.C:\Program Files\Microsoft Visual Studio\My Projects\UseVbDll\UseVbDllDlg.cpp(194) : error C2259: '_FunctionClass' : cannot instantiate abstract class due to following members: c:\program files\microsoft visual studio\my projects\usevbdll\debug\sampledll.tlh(34) : see declaration of '_FunctionClass' 3.C:\Program Files\Microsoft Visual Studio\My Projects\UseVbDll\UseVbDllDlg.cpp(195) : error C2039: 'CreateInstance' : is not a member of '_FunctionClass' c:\program files\microsoft visual studio\my projects\usevbdll\debug\sampledll.tlh(34) : see declaration of '_FunctionClass' My Dll is like this // c:\program files\microsoft visual studio\my projects\usevbdll\debug\SampleDll.tlh // // C++ source equivalent of Win32 type library C:\Program Files\Microsoft Visual Studio\My Projects\BoolDate\SampleDll.dll // compiler-generated file created 08/22/08 at 17:31:22 - DO NOT EDIT! #pragma once #pragma pack(push, 8) #include namespace SampleDll { struct __declspec(uuid("a3105692-d6d7-41e0-8d8c-f4ab326fa2f4")) /* dual interface */ _FunctionClass; struct /*
savitri wrote:
HRESULT hr=sample.CreateInstance(__uuidof(SampleDll::_FunctionClass)); //here the progid is VbDll::CVbDll)
Dont pass _FunctinClass use SampleDll::FunctionClass. Also You are using SampleDll::_FunctionClass sample; Here you need use SampleDll::_FunctionClassPtr sample; Just check my post again. BTW Use Code block button below posting area for code blocks it is very difficult to read your code otherwise.
Regards, Sandip.
modified on Friday, August 22, 2008 8:17 AM
-
-
Hii.. I am doing as you told me in previous post.please check your mail once or check my reply to your post import.please tell me thanks, savitri
-
savitri wrote:
HRESULT hr=sample.CreateInstance(__uuidof(SampleDll::_FunctionClass)); //here the progid is VbDll::CVbDll)
Dont pass _FunctinClass use SampleDll::FunctionClass. Also You are using SampleDll::_FunctionClass sample; Here you need use SampleDll::_FunctionClassPtr sample; Just check my post again. BTW Use Code block button below posting area for code blocks it is very difficult to read your code otherwise.
Regards, Sandip.
modified on Friday, August 22, 2008 8:17 AM
-
Hii I did as u told but no change in it..i am fed of this dll.. thanks for response, savitri