For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > December 2005 > Make library in Visual Basic









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Make library in Visual Basic
MadeleineP

2005-12-08, 6:55 pm

Hi All,

I have some function in Visual Basic and I want to call them from Visual C.
My question is: What do I have to do? Do I have to create a library (if yes,
can you show me how to create it and call from Visual C).

I already tried to create ActiveX Dll, it works fine. however, I have to
register the DLL (that is something that I don't want to do).

Please advice me.
MikeD

2005-12-08, 6:55 pm


"MadeleineP" <MadeleineP@discussions.microsoft.com> wrote in message
news:D8322234-489B-4738-9659-7502D475153E@microsoft.com...
> Hi All,
>
> I have some function in Visual Basic and I want to call them from Visual
> C.
> My question is: What do I have to do? Do I have to create a library (if
> yes,
> can you show me how to create it and call from Visual C).
>
> I already tried to create ActiveX Dll, it works fine. however, I have to
> register the DLL (that is something that I don't want to do).



ActiveX is the only kind of "library" that VB can create. If you're wanting
a standard DLL that exports functions, you'll have to use something other
than VB.

--
Mike
Microsoft MVP Visual Basic


MadeleineP

2005-12-08, 6:55 pm

Hi Mike,

If <<ActiveX is the only kind of "library" that VB can createto export
functions>>, Is it true that I have to register the DLL (regsev32
ddlname.dll) in each post before call it from Visual C? Do you have a better
solution for that ?

"MikeD" a écrit :

>
> "MadeleineP" <MadeleineP@discussions.microsoft.com> wrote in message
> news:D8322234-489B-4738-9659-7502D475153E@microsoft.com...
>
>
> ActiveX is the only kind of "library" that VB can create. If you're wanting
> a standard DLL that exports functions, you'll have to use something other
> than VB.
>
> --
> Mike
> Microsoft MVP Visual Basic
>
>
>

MadeleineP

2005-12-08, 6:55 pm

Also,,,when I declare the DLL <<#import "c:\Test\VBCreateRelation.dll
no_namespace>> in Visual C application, I have to specify the path. Can I
configure the DLL path in this settings pannel?

"MadeleineP" a écrit :
[color=darkred]
> Hi Mike,
>
> If <<ActiveX is the only kind of "library" that VB can createto export
> functions>>, Is it true that I have to register the DLL (regsev32
> ddlname.dll) in each post before call it from Visual C? Do you have a better
> solution for that ?
>
> "MikeD" a écrit :
>
Saga

2005-12-08, 6:55 pm


To use the DLL, regardless of language, you do ned to register it,
but only once. Once registered, it can be used the the language that
supports ActiveX (COM).

Saga

"MadeleineP" <MadeleineP@discussions.microsoft.com> wrote in message
news:EAFD5494-FB93-41E6-A249-C18844DE4F6C@microsoft.com...[color=darkred]
> Hi Mike,
>
> If <<ActiveX is the only kind of "library" that VB can createto export
> functions>>, Is it true that I have to register the DLL (regsev32
> ddlname.dll) in each post before call it from Visual C? Do you have a
> better
> solution for that ?
>
> "MikeD" a écrit :
>


Saga

2005-12-08, 6:55 pm


This does not sound right for an ActiveX component. We'll
see what others have to say. :-)

Saga

"MadeleineP" <MadeleineP@discussions.microsoft.com> wrote in message
news:071EC4BB-4632-40B4-BE30-2858FDF93C5C@microsoft.com...[color=darkred]
> Also,,,when I declare the DLL <<#import "c:\Test\VBCreateRelation.dll
> no_namespace>> in Visual C application, I have to specify the path.
> Can I
> configure the DLL path in this settings pannel?
>
> "MadeleineP" a écrit :
>


Karl E. Peterson

2005-12-08, 6:55 pm

MadeleineP wrote:
> If <<ActiveX is the only kind of "library" that VB can createto export
> functions>>, Is it true that I have to register the DLL (regsev32
> ddlname.dll) in each post before call it from Visual C? Do you have a
> better solution for that ?


Regsvr32 is really just a convenience for users. You can register the DLL
manually, if you find it hasn't been done yet, by calling its exported
DllRegisterServer function directly. To do this from a VB app, it's rather
convoluted:

http://www.ftponline.com/Archives/p...0200/mc0200.asp

I'm sure you'll have an easier time of it with VC.
--
Working without a .NET?
http://classicvb.org/


Ken Halter

2005-12-08, 9:55 pm

"MadeleineP" <MadeleineP@discussions.microsoft.com> wrote in message
news:D8322234-489B-4738-9659-7502D475153E@microsoft.com...
> Hi All,
>
> I have some function in Visual Basic and I want to call them from Visual
> C.
> My question is: What do I have to do? Do I have to create a library (if
> yes,
> can you show me how to create it and call from Visual C).
>
> I already tried to create ActiveX Dll, it works fine. however, I have to
> register the DLL (that is something that I don't want to do).
>
> Please advice me.


Adding to other replies, here's a list of KB articles that may come in
handy.

The last link points to an add-in that will "help" VB generate "Standard
DLLs that export functions".

HOWTO: Pass Array of UDTs with Variable Length Strings to C/C++
http://support.microsoft.com/defaul...kb;en-us;194609

INFO: Visual Basic Requirements for Exported DLL Functions
http://support.microsoft.com/defaul...kb;en-us;142840

How to Pass a String or String Arrays Between VB and a C DLL
http://support.microsoft.com/defaul...kb;en-us;118643

HOWTO: Pass a String Between Visual Basic and Your C DLL
http://support.microsoft.com/defaul...kb;en-us;187912

HOWTO: Write C DLLs and Call Them from Visual Basic
http://support.microsoft.com/defaul...kb;en-us;106553

How to Pass Numeric Variables to a C DLL
http://support.microsoft.com/defaul...=kb;en-us;94960

How to Pass & Return Unsigned Integers to DLLs from VB
http://support.microsoft.com/defaul...kb;en-us;112673

vbAdvance
"Standard DLLs that export functions"
http://www.vbadvance.com/


--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm


MadeleineP

2005-12-15, 6:55 pm

Dear All,

I already create the ActiveX DLL and try to call it in my Visual C. My
problem is the calling function does not work in some of my computers. I will
write out some steps that I did:

1) I go to regedit and type : regsvr32 dllname.dll
2) Here is the calling function in Visual C
BOOLEAN rv = TRUE;
char buf[BUFSIZ];
HRESULT hresult;
CLSID clsid;
_clsVBCreateRelation *ptr = NULL;

CoInitialize(NULL); //initialize COM library
hresult=CLSIDFromProgID(OLESTR("VBCreateRelation.clsVBCreateRelation"),
&clsid); //retrieve CLSID of component

hresult=CoCreateInstance(clsid,NULL,CLSC
TX_INPROC_SERVER,__uuidof(_clsVBCreateRe
lation),(LPVOID *) &ptr);
if(FAILED(hresult))
xvt_dm_post_note("Create cascade update for tables LIM and LIM_POINTS
relation failed");
else if (ptr)
{
sprintf(buf, "%s.mdb", x->connect.filename);
rv = ptr->VBCreateLimPoints((_bstr_t)buf);
if(!rv)
xvt_dm_post_note("Create cascade update for tables LIM and
LIM_POINTS relation failed");
ptr->Release(); //call method
}
CoUninitialize(); //Unintialize the COM library


Please help me,,,Thank


"Ken Halter" a écrit :

> "MadeleineP" <MadeleineP@discussions.microsoft.com> wrote in message
> news:D8322234-489B-4738-9659-7502D475153E@microsoft.com...
>
> Adding to other replies, here's a list of KB articles that may come in
> handy.
>
> The last link points to an add-in that will "help" VB generate "Standard
> DLLs that export functions".
>
> HOWTO: Pass Array of UDTs with Variable Length Strings to C/C++
> http://support.microsoft.com/defaul...kb;en-us;194609
>
> INFO: Visual Basic Requirements for Exported DLL Functions
> http://support.microsoft.com/defaul...kb;en-us;142840
>
> How to Pass a String or String Arrays Between VB and a C DLL
> http://support.microsoft.com/defaul...kb;en-us;118643
>
> HOWTO: Pass a String Between Visual Basic and Your C DLL
> http://support.microsoft.com/defaul...kb;en-us;187912
>
> HOWTO: Write C DLLs and Call Them from Visual Basic
> http://support.microsoft.com/defaul...kb;en-us;106553
>
> How to Pass Numeric Variables to a C DLL
> http://support.microsoft.com/defaul...=kb;en-us;94960
>
> How to Pass & Return Unsigned Integers to DLLs from VB
> http://support.microsoft.com/defaul...kb;en-us;112673
>
> vbAdvance
> "Standard DLLs that export functions"
> http://www.vbadvance.com/
>
>
> --
> Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
> DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
> Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm
>
>
>

MadeleineP

2005-12-15, 6:55 pm

I forget to mention in the previous message that the faillure message is from
the function CoCreateInstance

"MadeleineP" a écrit :
[color=darkred]
> Dear All,
>
> I already create the ActiveX DLL and try to call it in my Visual C. My
> problem is the calling function does not work in some of my computers. I will
> write out some steps that I did:
>
> 1) I go to regedit and type : regsvr32 dllname.dll
> 2) Here is the calling function in Visual C
> BOOLEAN rv = TRUE;
> char buf[BUFSIZ];
> HRESULT hresult;
> CLSID clsid;
> _clsVBCreateRelation *ptr = NULL;
>
> CoInitialize(NULL); //initialize COM library
> hresult=CLSIDFromProgID(OLESTR("VBCreateRelation.clsVBCreateRelation"),
> &clsid); //retrieve CLSID of component
>
> hresult=CoCreateInstance(clsid,NULL,CLSC
TX_INPROC_SERVER,__uuidof(_clsVBCreateRe
lation),(LPVOID *) &ptr);
> if(FAILED(hresult))
> xvt_dm_post_note("Create cascade update for tables LIM and LIM_POINTS
> relation failed");
> else if (ptr)
> {
> sprintf(buf, "%s.mdb", x->connect.filename);
> rv = ptr->VBCreateLimPoints((_bstr_t)buf);
> if(!rv)
> xvt_dm_post_note("Create cascade update for tables LIM and
> LIM_POINTS relation failed");
> ptr->Release(); //call method
> }
> CoUninitialize(); //Unintialize the COM library
>
>
> Please help me,,,Thank
>
>
> "Ken Halter" a écrit :
>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com