Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: problem with including .dll into current cpp program

Reply
Thread Tools

Re: problem with including .dll into current cpp program

 
 
Alex Jin
Guest
Posts: n/a
 
      07-02-2003
Actually, there are two methods for linking dll file.
1. static.
when linking dll file statically, windows system will be charge of
loading and unloading dll file. and the location of dll file should be
windows system folder or the one same as the *.exe file. as your dll file is
on remote machine, this method can't help you.

2. dynamic.
With this method, you will handle loading and unloading dll. it's more
flexiable than statically linking.

Suppose the following function in your dll file:
void dllFoo( char *pStr );

Please refer to the following for how to use this function:
/* file: use_dll.cpp */
#include <stdio.h>
#include <windows.h>

typedef void (*Typ_dllFoo)( char *pStr );

int main()
{
HMODULE hDll =
::LoadLibrary("\\\\atoc\\admin\\luebeck\\header\\d ebug\\bccld.dll");
if ( hDll == 0 )
{
printf("load dll fail\n");
exit(1);
}

Typ_dllFoo pFoo = (Typ_dllFoo)::GetProcAddress( hDll, "dllFoo");
if ( pFoo == 0 )
{
::FreeLibrary( hDll );
printf("get function address failed\n");
exit(1);
}

pFoo( "hello! that's ok!!" );
pFoo = 0;

::FreeLibrary( hDll );
return 0;
}

That's all !
Alex Jin.



"Bharath" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hallo,
> I am having problem with including .dll file into current cpp
> program.Actually i have .dll file in our company server.
> example..the file is in this location ..
> //atoc/admin/luebeck/header/debug/bccld.dll
>
> then my problem is how i have to include this into the current cpp
> program and i should call some header file ,like dynamictable.h, in
> that dll.so please help me how to solve this problem.
>
> thankiny you,
> Bharath Kumar



 
Reply With Quote
 
 
 
 
Jack Klein
Guest
Posts: n/a
 
      07-02-2003
On Wed, 2 Jul 2003 17:14:26 +0800, "Alex Jin" <(E-Mail Removed)>
wrote in comp.lang.c++:

Please don't top post. Material you add goes after quoted material
you are responding to.

> Actually, there are two methods for linking dll file.


Please don't pollute comp.lang.c++ with off-topic answers.

Please cite the sections from the C++ language standard that define
these two methods for linking "dll" file. Or that specify linking or
"dll" at all.

If you can't, the appropriate response is to direct the OP to a proper
compiler-specific support group.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with including .h and .cpp files none C++ 3 03-09-2010 05:19 AM
Free online test in C, CPP / Placement papers / CPP,C Interview Questions www.hitechskill.com C++ 0 04-09-2006 10:53 AM
when i compile the cpp file(cmdargs.cpp) int main(int argc, wchar_t* argv[]) Vinu C++ 9 05-05-2005 04:11 AM
Method inlined in source1.cpp and called in source2.cpp Alex Vinokur C++ 7 11-15-2004 09:14 PM
What is better /standard for creating files. a cpp file with header or cpp and seperate file for header DrUg13 C++ 1 02-10-2004 09:20 AM



Advertisments