|
|
Comments and Discussions
|
|
 |

|
Thanks for Sharing. Very Good Article.
|
|
|
|

|
Hallo,
could anyone give some instruction for beginners of how to call a visual basic dll from visual c++ in Visual Studio 2010.
thanks...
|
|
|
|

|
Thanks for sharing this article.
I have a situation in which I am trying to access a third party DLL. I followed the instruction in this article, but at the end process, I get a compilation error C2027: use of undefined type 'type'. The IDL file of my DLL looks something like this:
library XAPI
{
interface IXField;
[
uuid(A6B99FCD-4D31-411A-A735-E7DC17AC1123),
helpstring("XField Object")
]
coclass XField {
[default] interface IXField;
};
[
odl,
uuid(19DE3CA1-CD87-4A89-B323-CE37EA23E1FB),
helpstring("Dispatch interface for IXField Object"),
dual,
oleautomation
]
interface IXField : IDispatch {
[id(0x000000c9), propget]
HRESULT Tag([out, retval] long* Value);
}
}
It has an interface IXField and a class XField.
The corresponding .h file created by midl:
typedef interface IXField IXField;
typedef class XField XField;
EXTERN_C const IID IID_IXField;
MIDL_INTERFACE("19DE3CA1-CD87-4A89-B323-CE37EA23E1FB")
IXField : public IDispatch
{
public:
virtual HRESULT STDMETHODCALLTYPE get_Tag(
long __RPC_FAR *Value) = 0;
};
EXTERN_C const CLSID CLSID_IXField;
class DECLSPEC_UUID("CB29D47C-A1FE-4803-A30C-68CA10058EC6")
XField;
My C++ code (TestXAPI.cpp) after including the header file:
HRESULT hr;
IXField * mXField = NULL;
hr = CoInitialize(0);
hr = CoCreateInstance(CLSID_IXField,NULL,CLSCTX_INPROC_SERVER,IID_IXFixField,(void**) &mXField);
long value = 0;
mXField->get_Tag(&value);
During compilation, the following error message occurred:
TestXAPI.cpp(101) : error C2027: use of undefined type 'IXField'
The error happens when I try to access the get_Tag() method.
I can see that the problem is because the class XField is declared without any implementation. My question is: wouldn't the actual code be implemented inside the DLL? And somehow I need to be able to link the DLL and the declaration?
I wonder if someone has a solution to this.
Thanks.
|
|
|
|

|
Thanks for the great articles it really helps someone new like me.
|
|
|
|

|
I have done the "Calling a VB ActiveX DLL from a MFC Client" exercise successfully.
I have a requirement that, adding a new Public function (eg fncDLL2())in VB DLL and make dll.
Now without building the vc++ application replace the dll in the current folder and run the exe. When i did the same i am getting "Creation Failed" error.
Please try to give the solution to my problem
|
|
|
|

|
I have created an activeX DLL. It contains a class as shown below
-----------------------------------------
Option Explicit
Public Type T
i As Integer
d As Double
l As Long
s As String
End Type
Public Function TypeValue() As Long
Dim a As T
a.i = 10
TypeValue = a.i
End Function
---------------------------------------------------
I can able to make dll but, when i try to compile .idl file using MIDL it's giving an error the error message is as follows
"midl\oleaut32.dll : warning MIDL2368 : error generating type library, ignored : Could not set UUID :
tagT"
|
|
|
|

|
Checked the PATH, INCLUDE, LIB env. Variables Tried on both Visual Studio Professional , Enterprise, Visual Studio.net2003 on a fresh installation after removing previous installations & deleting all LIB, INCLUDE, PATH , registry entries (using regedit), & did fresh installations. In command prompt, ran midl with & without executing VCVARS32.bat Copied the file vbTestCOM.idl in all LIB , INCLUDE, bin Dir checked with TestvbCOM.idl, vbTestCOM.idl still...NO EFFECT Still the Same ERROR :: MIDL1003 persists // OUTPUT same by both IDE & command prompt: Processing .\vbTestCOM.idl %CL% fatal error C1083: Cannot open source file: '%CL%': No such file or directory vbTestCOM.idl midl : command line error MIDL1003 : error returned by the C preprocessor (2) PLEASE HELP
|
|
|
|

|
I have a problem when i access the VB activeX DLL fuction which inturn call the regular DLL fuction from my VB application.I am using the late binding to access the ActiveX DLL from my VB application . Can you help me regarding this. You can suggest any other idea to resolve.
Thank you,
Regards,
KSMH
|
|
|
|

|
Anybody know to dynamically link the vb activex dll with vc?
Jothi Murugeswaran.S
|
|
|
|
|

|
is very old, but I liked it.
But I think with VS2005 and the .net technology there are easier ways. That could be interesting!
Greetings from Germany
|
|
|
|

|
Instead of using a pointer by using
_clsVBTestClass *IVBTestClass = NULL;
would it be better to use a CComPtr instead or a
CComQIPtr maybe?
E.g.
HRESULT hr;
CComPtr<_clsVBTestClass> IVBTestClass;
or
HRESULT hr;
CComQIPtr<_clsVBTestClass> IVBTestClass;
Just a thought
Tom
|
|
|
|

|
Hello,
Does any body know how to return a string-variable back to the C++ program; the article only shows it with a long-variable.
I followed the same steps with an extra VB-function that returns a string, but I can't get the VC++ program to work.
VC++ :
_bstr_t RetStrValue;
hr = IVBTestClass->DoString(bstrValue, &RetStrValue);
cout << "The returnstring is: " << RetStrValue << endl;
The C++ compiler says :
error C2664: 'DoString' : cannot convert parameter 2 from 'class _bstr_t *' to 'unsigned short ** '
VB-function :
Public Function DoString(ByVal strValue As String) As String
If strValue = vbNullString Then
DoString = ""
Else
DoString = "RETURN" & strValue * "RETURNNNN"
End If
End Function
|
|
|
|

|
hi
pls clear my doubt
the error are follow by the time of generating build Dll in vc++
this for using vb dll in vc++
fatal error C1010: unexpected end of file while looking for precompiled header directive
help me to know the result
Thanks
sridhar
|
|
|
|

|
For some reason if I include "stdafx.h" in my project, when I move the inclusion for "vbTestCOM.h" to *before* stdafx it is completely ignored, and if I include it *after* stdafx I get this error saying it doesn't even exist! What is going on here?
D:\backup\projects\Server\IOCP\srv\worker.cpp(11) : fatal error C1083: Cannot open include file: 'vbTestCOM.h': No such file or directory
|
|
|
|

|
hi,
I tried to do everything you explained above but when I tried to invoke the midl compiler E:\VCSource\TestVBCOM\TestVBCOM\midl vbTestCOM.idl /h vbTestCOM.h
it gave the following error
device is not ready..
do you know what might cause this?
thanks...
gül
|
|
|
|

|
Hello,
in this Article are a lot of errors:
:\Temp\TestVBCOM\TestVBCOM.cpp(9) : error C2065: '_clsVBTestClass' : undeclared identifier
C:\Temp\TestVBCOM\TestVBCOM.cpp(9) : error C2065: 'IVBTestClass' : undeclared identifier
C:\Temp\TestVBCOM\TestVBCOM.cpp(9) : warning C4552: '*' : operator has no effect; expected operator with side-effect
C:\Temp\TestVBCOM\TestVBCOM.cpp(18) : error C2065: 'CLSID_clsVBTestClass' : undeclared identifier
C:\Temp\TestVBCOM\TestVBCOM.cpp(21) : error C2065: 'IID__clsVBTestClass' : undeclared identifier
C:\Temp\TestVBCOM\TestVBCOM.cpp(32) : error C2227: left of '->CountStringLength' must point to class/struct/union
C:\Temp\TestVBCOM\TestVBCOM.cpp(35) : error C2001: newline in constant
C:\Temp\TestVBCOM\TestVBCOM.cpp(36) : error C2146: syntax error : missing ';' before identifier 'length'
C:\Temp\TestVBCOM\TestVBCOM.cpp(36) : error C2065: 'length' : undeclared identifier
C:\Temp\TestVBCOM\TestVBCOM.cpp(36) : error C2001: newline in constant
C:\Temp\TestVBCOM\TestVBCOM.cpp(36) : error C2059: syntax error : 'string'
C:\Temp\TestVBCOM\TestVBCOM.cpp(43) : error C2228: left of '.cout' must have class/struct/union type
C:\Temp\TestVBCOM\TestVBCOM.cpp(43) : error C2297: '<<' : illegal, right operand has type 'char [25]'
Error executing cl.exe.
TestVBCOM.exe - 12 error(s), 1 warning(s)
Sometimes you write "_clsVBTestClass", on other locations "_clsTestClass", or the projectname is sometimes "TestVBCom", sometimes "vbTestCOM". The Sourcecode in the article and in the zip are also not equal.
I can fix the errors for myself. But it is annoyed to fix so much errors in a so little project. --> Review this articel.
Peter
|
|
|
|

|
i followed all the steps but i couldnt compile .idl file..
when i type midl it says bad command or file name.
Do i have to install MIDL compiler ?
|
|
|
|

|
eg:
#import "test.dll" no_namespace
I's a better way to do that.
|
|
|
|

|
My task is to call a VB activeX DLL function from a C++ DLL. After following the article by C. Lung on "Calling Visual Basic ActiveX DLLs from Visual C++", I am receiving the output "CoCreateInstance failed" with a return code of -2147467262.
Does anybody have any ideas why this would happen, or how to fix it? The VB DLL I am trying to call is registered on the server. The C++ wrapper DLL I created resides in the same folder as the VB DLL. I can provide more detailed info and code if necessary.
Thank you..
|
|
|
|

|
Hi All
I am trying to return Recordset from my VB Dll Function
. I am using ADO 2.5 library while compliling vbCOMTest.idl
it is giving error in this statement
library vbTestCOM
{
// TLib : // TLib : Microsoft ActiveX Data Objects 2.5 Library : {00000205-0000-0010-8000-00AA006D2EA4}
importlib("msado25.tlb");
// TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
Error Description
D:\MFC\VBFromVC\TestVBCOM\vbCOMTEST.idl(12) : warning MIDL2015 : importlib not found : msado25.tlb
|
|
|
|

|
I have test this example and it works very good but I can't call an ActveX Control ( myctl.ocx written by Visual Basic) from Visual C++ ( Win32 Console App). Please help me do
Thanhyou very much !
(When I do similar with an ActiveX Control(myctl.oxc written by Visual Basic) an Error occur at runtime(run debug): Unhandled exception in TestVBCOM.exe(MSVBVM60.DLL): 0xC0000005: Access Violation )
|
|
|
|

|
I have test this example and it works very good but I can't call an ActveX Control ( myctl.ocx written by Visual Basic) from Visual C++ ( Win32 Console App). Please help me do
Thanhyou very much !
(When I do similar with an ActiveX Control(myctl.oxc written by Visual Basic) an Error occur at runtime(run debug): Unhandled exception in TestVBCOM.exe(MSVBVM60.DLL): 0xC0000005: Access Violation )
|
|
|
|

|
I have been test this example and it works very good . But I can't calling an ActiveX Control ( myctrl.ocx) . please help me calling with an ActiveX Control
Thanhyou vey much !
|
|
|
|

|
Can somebody provide me with an example of how to pass arrays from a VB created ActiveX DLL to a VC++ app using the SAFEARRAY
|
|
|
|

|
#1, why does it seem that any project, other than console, is built with the knowledge of .idl files built in? Try it, just do a normal win32 app and add an idl file, it'll automatically compile without a custom build.
#2, when I tried compiling the idl from dos, I got an error about not finding oaidl.idl, even though it's in my path. But, when using the custom build settings, it worked fine, why?
|
|
|
|

|
I am running VC++, Version 5 and VB Version 5 under Windows NT, Version 4.
I want to call an ActiveX DLL written in VB 5 from a VC5 Client application. My ActiveX DLL returns a string. In order to understand how to do this I have written a simple test ActiveX DLL in VB 5:
Public Function LeftThree(strString As String) As String
LeftThree = Left(strString, 3)
End Function
The MIDL compiler produces a .h file in which the significant sections of code defining the interface to LeftThree seem to be:
virtual /* [id] */ HRESULT __stdcall LeftThree(
/* [out][in] */ BSTR strString,
/* [retval][out] */ BSTR __RPC_FAR *__MIDL_0015) = 0;
and
/* [id] */ HRESULT ( __stdcall __RPC_FAR *LeftThree )(
_clsTestCOM __RPC_FAR * This,
/* [out][in] */ BSTR __RPC_FAR *strString,
/* [retval][out] */ BSTR __RPC_FAR *__MIDL_0015);
What I would like to know is how to call LeftThree from the VC++ application. Could anybody help me on this? I would be very grateful for any advice and in particular for some sample code.
Regards,
David Hann
|
|
|
|

|
HI, I have been trying to pass a picture from the picture box in VB to VC win32 dll , for some processing and then pass the same back to Picture Box.. Can any one help me out how should I declare a function in VC and the equivalent in VB thanx in advance Sreekant
|
|
|
|

|
How can i access the data sent as variant array from vb application in my vc++ atl com dll. I thank them now itself for the timly help rendered to me
|
|
|
|

|
Hi I have done everything in this tutorial, and all works great on my PC. When I move the code to another PC, however, I keep getting DLL not registered. Even in OLE Viewer. This is after I have run regsvr32 mydll.dll.
Please help.
|
|
|
|

|
Hy,
My question is the opposite of your article!
How can I make a COM with VC++, what can call from VB.
Any special interface?
Special data types?
I made a simple COM, with only one function void (void) and the VB can't call it?
Zoltan
|
|
|
|

|
Everybody says creation of dll in vc++ and accessing from VB.
Please tell me how to create dll in VC++ and Access from VC++ only.
I tried one sample program:
step-1: open new project and select win32 dyanamic link library type project.
step-2: i wrote a sample program in c++ file
#include
__declspec(dllexport) void print();
void print()
{
printf("Hello WORLD");
}
step-3: then i compiled ang got the .dll and .lib file successfully;
step-4: i kept the .dll file in system32 folder of windows
step-5: i create one more project using new project and select win32 console application.
step-6: in c++ file i wrote
#include
_declspec(dllimport) void __stdcall print();
void main()
{
print();
}
step 7: In project setting i gave the .lib file path name.
step 8: When i compiled this i got the error
What is this error
ompiling...
main.cpp
d:\dll\main\main.cpp(4) : warning C4518: '__declspec(dllimport ) ' : storage-class or type specifier(s) unexpected here; ignored
d:\dll\main\main.cpp(4) : warning C4230: anachronism used : modifiers/qualifiers interspersed, qualifier ignored
Linking...
main.obj : error LNK2001: unresolved external symbol "void __stdcall print(void)" (?print@@YGXXZ)
Debug/main.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
main.exe - 2 error(s), 2 warning(s)
|
|
|
|

|
hi friends,
how to call activex dll through c++ dll.
thanks in advance.
|
|
|
|

|
I Know i can use structures in COM object, for example i have the following one:
typedef struct _DataCar
{
float Passo[2];
float SetBack[2];
float Conv[4];
float Camber[4];
float StearingMax[2];
// ...
unsigned fCarStatus;
}
DataCar;
Is it correct to define a method as follow?
STDMETHOD(GetCarData)(/*[out]*/DataCar* pData);
Compilation got me a warning!
But now how can i retrieve the structure in VB?
i performed the following code in VB, but connection with my COM object fails:
Public Type DataCar 'I defined a structure to recieve the data
Passo(2) As Single
SetBack(2) As Single
Conv(4) As Single
Camber(4) As Single
StearingMax(2) As Single
fCarStatus As Single
End Type
Dim myCarData As DataCar
Set conn = New ISConnection 'Perfomes connection to my COM object
conn.GetCarData myDataCar 'trying to receive data
Thanx
|
|
|
|

|
What if your VB class returns another VB object and not a primitive?
|
|
|
|

|
The CoCreateInstance function keeps failing!!!
I made Class_Initialize and Class_Terminate functions which pop up message boxes. When I run the VC program, both of these functions are called because the two message boxes appear, which indicates that the VB DLL is being accessed, but they immediatly follow eachother, indicating that when the class given an instance, it is immediatly released. When I download the code example, the CoCreateInstance function still fails. Am I missing something???
|
|
|
|

|
Is it possible to invoke a method, using the same approach defined in this excellent article, that shows a Form defined in the ActiveX Dll?
In other words, if I have an ActiveX Dll that has a form and in its class is defined a public method that shows that form (with a Form.Show statement) ... can I call that method from a VC program (using the appropriate Interface) and see the Dialog?
I tried but I was not able to do it.
Thanks a lot.
Marco A.
|
|
|
|

|
Let's say we have a DLL written on VB that has been registered and included into MTS on a server computer. How would you then write a C++ client that instantiates that component?
Thanks,
Julian
|
|
|
|

|
I can return a VB TYPE "long" from the VB dll,but when I return a string it can't work.......
Can someone help me???
Please help me. I have been stuck with this problem for tooooo long now. Thanks.
|
|
|
|

|
How do i return a string from vc++ to the vb dll. eg
function blah() as string
blah = date
end function
Please help me if you can!
|
|
|
|

|
I was given a project to make a function in a Visual Basic ActiveX DLL available to our application which is currently written in C using the Borland command line tools. With the help of this article I managed to get the project up and running in next to no time.
The VB function retrieves prices and availability from a supplier using http. Imagine having to code that lot up using just the Win32 API!
|
|
|
|

|
I am using this function in vb:
Sub connect_to_channel(ByVal what_channel As String)
TheChannel = what_channel
frmStatus.tcp.SendData "JOIN #" & what_channel
MsgBox get_channel_topic
End Sub
----------------------------------------------------
and i am using this from c++:
void connect_channel(_bstr_t what_channel)
{
irc_clientClass->connect_to_channel(what_channel);
}
--------------------------------------------------------
connect_channel("globalwarfare");
--------------------------------------------------------
It seems if the string is getting lost. and it wont connect to the channel. can any one help.
|
|
|
|

|
this is not working for me please help!
|
|
|
|

|
What about passing a structure? Is that possible between VC and VB? e.g. something that contains a) a string and b) an array of floats
|
|
|
|

|
What do i need to pass from VC++ so I can successfully execute a function from vb activex dll which is expecting an array of varient type. I would appreciate any help with this. Ton of thatnks.
|
|
|
|

|
give all details about the smart pointers
ramki
|
|
|
|

|
A parameter in VB dll is of String Type, which requires it to be accessed in the c++ sourcefile, it gives error while accessing in the c++ file as cannot convert char * to unsigned short ** how to solve it
|
|
|
|

|
I created a dll (ATL project) with VC++ that I can call from Visual Basic.
I designed a simple class with a few methods.
It works well when I call the methods of my class that have simple arguments (Byte, long ...) but I can't call methods that accept pointers (to pass an array) as parameters.
- What do I need to change in the VC++ code of my dll to use arrays as parameters in my methods?
- Do I have to specify the size of my array in the code of the DLL or can i just pass an array (via a pointer) as we can do in C++?
- Does anyone know some good ressources about using ATL DLL (written with VC++) under VB?
URGENT,
Many thanks :}
|
|
|
|

|
midl fails with error messages MIDL2088
[uuid]Format is incorrect.
i tried /c_ext / ms_ext ...but failed
midl uses com+ service type library and working in MTS
here's my midl content.....
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: dllGetTitleAuthor.dll
[
uuid(20CDAD36-DD73-46BC-B005-CFCE4CE07A61),
version(1.0)
]
library dllGetTitleAuthor
{
// TLib : // TLib : COM+ Services Type Library : {2A005C00-A5DE-11CF-9E66-00AA00A3F464}
importlib("COMSVCS.DLL");
// TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
interface _CGetTitleAuthor;
[
odl,
uuid(D962DEAC-A0C7-4AFB-B754-2B6960419A17),
version(1.0),
hidden,
dual,
nonextensible,
oleautomation
]
interface _CGetTitleAuthor : IDispatch {
[id(0x60030003)]
HRESULT GetTitleAuthor(
[in] BSTR cAuthID,
[out, retval] VARIANT* );
};
[
uuid(E31F5E9C-0ED4-491E-9CD4-B9700F92A938),
version(1.0),
custom({17093CC8-9BD2-11CF-AA4F-304BF89C0001}, "0")
]
coclass CGetTitleAuthor {
[default] interface _CGetTitleAuthor;
interface ObjectControl;
};
};
What should I do to get it workin
thanks......
|
|
|
|

|
I'm actually running windows 98 and when I try running midl from the dos prompt, I get a bad command or file name error. Can some one help
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
| Type | Article |
| Licence | |
| First Posted | 18 Nov 1999 |
| Views | 429,724 |
| Bookmarked | 99 times |
|
|