|
I think you may have your terms a little confused so I'm not exactly sure what you want.
There are basically three scenarios:
1. x.dll is a Dll and is used by calling LoadLibrary and GetProcAddress
2. x.dll is a Dll, x.lib is its import library. x.lib is linked into application y which is then implicitly linked to x.dll. x.dll get loaded by y.exe during the bootstrap phase and functions in x.dll can be called directly from y.exe code, No LoadLibrary, no GetProcAddress
3. x.lib is a static library which is linked as part of y.exe. The two are merged at compile time to produce y.exe. That's it, the functions all act as if they are in the same module because they are, no LoadLibrary, no GetProcAddress
Generally you'd use:
1 if the code in x.dll is shared and only used occassionaly by y.exe
2 if the code in x.dll is shared and used all the time by y.exe
3 if x.lib is really just a subdivision of y.exe and is not used by other applications.
I hope this helps.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
I think the 2) option does work for me.
i will clarify my doubt again, please confirm whether 2) option works or not.
I have some code x when built it gives x.dll and creates x.lib.
Currently i m loading x.dll by LoadLibray and calling function thro' GetProcAddress.
Now i want to call those same functions but want to avoid using LoadLibray and GetProcAddress.
How it could be done ??
Thanks a lot !!!!
|
|
|
|
|
Yashusid wrote: How it could be done ??
You link to the .lib file.
led mike
|
|
|
|
|
OK, you need to add x.lib to the Input files list for the Linker. I'd need to know what development environment you're using to be much more specific.
Your exe source files which call functions in the dll will need to include the relevant header file from the dll source e.g.
<br />
<br />
#include "mydll.h"<br />
<br />
int iResult = MyDllFunction( "SomeString" );<br />
<br />
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
I am using VS2005.
Thanks a lot Matthew
|
|
|
|
|
In which case, as you probably know, you'll find the Linker Input files by right clicking on your project (not the solution), selecting Properties and then choosing Configuration Properties\Linker\Input in the properties dialog. You can add the name of your x.lib file to the 'Additional Dependencies'
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Thanks ...
I have included this x.lib
Is it possible to call those function from the x.lib in y.exe application directly??
like if a function add(int,int) is implemented in x.lib ...can i call in y.exe as int n=add(2,3) ??
|
|
|
|
|
To complete what Matthew just said, if you are in scenario 2 (x.lib is the import libary of the dll), then you can't statically link to it to access the functions. The lib doesn't contain the code for the functions but only information about how to load the dll.
|
|
|
|
|
Yashusid wrote: its a static dll
impossible. DLL means DYNAMIC Link Library
|
|
|
|
|
I have create a small samle app which connects to an FTP servere and returns a list of file names and sizes in a specific folder.
The folder contains a 5+ GB file.
However the GetLength function of the CFtpFileFind class returns 0xFFFFFFFF as a size (approx 4GB). Note that I am using VS2008 and GetLength returns a ULONGLONG unlike the functions prior to MFC 7.
I created my own class using CFtpFileFind as a abse in order to see the actual WIN32_FIND_DATA used and indeed found thet the low order DWORD for the size was set to 0xFFFFFFFF and the high order DWORD was 0x00000000.
Can I deduce from this that the MFC FTP classes do not support >4GB file sizes?
|
|
|
|
|
Paul Deckers wrote: WIN32_FIND_DATA
I don't know, but if the MFC classes are causing this problem you can avoid it by using the WinInet library[^] directly. If the WinInet library is causing it then that won't help. If it is a limitation of the FTP server there is no way to solve the problem short of dividing the file into multiple files, which might not be a bad idea anyway. If the FTP Server supports it then you could find a different library or implement your own client using Sockets.
led mike
|
|
|
|
|
I have a std::list of strings which I need to pass to another function as an LPARAM, so I believe I need to create an array of char* and copy each string in but how do I create a char* array of the correct size (it says it requires a constant)? And how do I know the size of the array once they are passed to the second function? Or is there a better way to do this?
|
|
|
|
|
Something like (which might be overkill):
char **arr = new char*[l.size()];
int y = 0;
for (list<string>::iterator x = l.begin(); x != l.end(); x++)
{
string str = *x;
arr[y] = new char[str.length() + 1];
strcpy(arr[y], str.c_str());
y++;
} Now you can pass arr and l.size() as the arguments to your function.
You could also do something like:
void foo( LPARAM lParam )
{
list<string> *l = (list<string> *) lParam;
}
...
list<string> l;
foo((LPARAM) &l);
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thanks! That is very similar to what I had been working towards (apart from the fact it works!)
So now, in my callback I am using:
char **arr = (char**)lParam;
int count = sizeof(arr) / sizeof(*arr);
But this gives me 1 when it should be 2, what is the correct way to determine the size of the array?
|
|
|
|
|
__DanC__ wrote: But this gives me 1 when it should be 2...
Right, because a pointer is four bytes in size.
__DanC__ wrote: ...what is the correct way to determine the size of the array?
As a second argument to your function.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I do not have the option of a second argument to the function as it is a callback. All I can pass is the pointer as an LPARAM
|
|
|
|
|
So put the array and the count in a structure and pass the address of that structure.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Why don't you just pass the address of the std::list as the LPARAM? If you need a copy at the other end, copy the std::list and use the address of the copy.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
I didn't realise that was possible. How would I copy the list? I tried CopyMemory before I started down this route with no luck so decided the pointer array was probably the way to go.
|
|
|
|
|
It's a while since I've used std::list so you're probably best looking at the docs but I guess you could simply create a second std::list, then iterate through the first one, use CopyMemory or whatever for each item and then append it to the second list. I'm not sure if you can simply assign one list to another or pass the first list to a constructor of the second. I suspect it depends on what your list contains, simple POV type, complex types, pointers, etc.
Reminds me I need to look into the std containers once again. I've never really got on with them or used them on a regular basis.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Do you really need to copy the list? Why not something like this:
void IWantAList(LPARAM lp)
{
using namespace std;
list<string> *pList = reinterpret_cast<list<string>*>(lp);
}
void SendList()
{
using namespace std;
list<string> list;
IWantAList(reinterpret_cast<LPARAM>(&list));
}
Steve
|
|
|
|
|
I want to move an Object to a particular point if a condition is met. I use the variable "pWaypointNum1" to refer the position of the object and "mCharacter to refer the Object. Here's the code:
if(pWaypointNum1 < 6)
{
if((pWaypointNum1 > 1) && (pWaypointNum1 <= 3))
{
test1 = 6;
}
else
{
test1 = 3;
}
mCharacter1->GoToWaypoint(pWaypointNum1);
pWaypointNum1++;
}
My problem is:
I want to increment the variable pWaypointNum1 by 1 as the Object moves from one position to the next position. But it increments in a sudden. How to increment the pWaypointNum1 variable as the Object moves from one position to the next position?
|
|
|
|
|
T.RATHA KRISHNAN wrote: But it increments in a sudden.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Can you give us some more context?
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
|
|
|
|
|
I want to set the speed of the object to 6 if it's travelling between the 1st and 3rd positions. But it's 6 from start to end. How can I set the speed for in between positions(1st to 3rd)? Pls refer to the code above.
|
|
|
|