|
-
October 18th, 2001, 02:04 AM
#1
VC++ dll and VB
Can I export class from VC++ and use it in VB ?
-
October 18th, 2001, 03:00 AM
#2
Re: VC++ dll and VB
If you write an ActiveX dll in C++ you can, yes. That is what ActiveX is good at...
HTH,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
-
October 19th, 2001, 01:49 AM
#3
Re: VC++ dll and VB
Once writting a VC++ dll, register the dll file. Now, move into your VB program and from Project->Properties option add a reference to the new created dll entry. Now, when you will create a variable you will find the class name in the autolist drop-down.
-
October 19th, 2001, 04:52 PM
#4
Re: VC++ dll and VB
If it is raw C++(not MFC or ATL COM), no.
Software is like sex, it's better when it's free - Linus Torvalds
Software is like sex, it's better when I get paid for it. - me
-
October 20th, 2001, 12:04 AM
#5
Re: VC++ dll and VB
You can sort out this in two ways.
If the dll is derived from automation class (IClassFactory) and if it has the necessary functions to register you can use it after registering. (regsvr32 …..)
The Necessary function to register the dll's are
1. RegisterServer
2. UnRegisterServer
The second way is if you developed the dll without
any automations and register functions
then you have to explicitly export the functions
for Example
int add(int a,int b) to export this function
you have to write it like this
extern "C" __declspec(dllexport) int __stdcall add(int a,int b)
place the dll in the local directory where vb
application resides or to the system directory.
In the VB you have to declare the function like this
Public Declare function Add lib "YourlibraryName" Alias "_add@8"(byval a as integer,byval b as integer)as integer
here Yourlibraryname is the name of .lib file which
will be created along with the Dll.
And alias is the Alias name of the function
To find the Alias name of the function
Goto
Microsoft Visual Studio6.0->Microsoft Visual Studio6.0 Tools->Depends
it will open an application where you have to open your dll.
But you have to do some manipulations to pass string-based arguments
for further clarifications mail to me
-
January 27th, 2002, 03:22 AM
#6
Re: VC++ dll and VB
I have written Com obj to pass struct arrays from VC to VB.
here is the code
IDL looks like this....
typedef struct tagUSERPARAMETERS
{
[string] BSTR bstrUserName;
[string] BSTR bstrPassword;
} UPARAM;
[
object,
uuid(ABF81033-3F0E-48A5-9AEB-9364E689FD32),
dual,
helpstring("ISSystem Interface"),
pointer_default(unique)
]
interface ISSystem : IDispatch
{
[id(1), helpstring("method Func")] HRESULT Func([in,out] UPARAM *stUParam, [out,retval] int *nErrVal);
[id(2), helpstring("method Func2")] HRESULT Func2([in]long Id, [in,out]SAFEARRAY(UPARAM) *psaUserParam);
};
and the VB code is this to call the above Func2....
option Explicit
Dim a as new SSYSLib.SSystem
Dim st(2) as SSYSLib.tagUSERPARAMETERS
private Sub Command1_Click()
a.Func2 1, st
MsgBox st(0).bstrPassword + st(0).bstrUserName
End Sub
this works fine, But my q'tion is....
1). Above works fine when it is a early binded obj (as included in the Project References..).
how can i pass struct array to a late binded obj. That is the above obj created thru CreateObject,
and not included in the reference in the 'Project references'.
2) Also How can pass above struct array from a VC client thru 'DISPPARAMS' to 'Invoke' method, without including the header files ?. Or how can i pass structs dynamicaly ?
Please i need ur help
Thanks in advance
by
Ramanan
(I will not hesitate to rate your answers.)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|