Board index » cppbuilder » convert static dll function load to dynamic load

convert static dll function load to dynamic load


2005-03-22 09:01:54 AM
cppbuilder92
hi,
i found a dll (www.zip-dll.de/download.htm) which may give my
application the possibility to extract zip files.
now i get this dll und use implib to create a lib file which i add to my
project. no i have this code:
extern "C" void __declspec(dllimport) IB_UnZipArchiveFile(const char*
szArchive);
void __fastcall TForm1::Button1Click(TObject *Sender)
{
String file = GetCurrentDir() + AnsiString("\\test.zip");
IB_UnZipArchiveFile(file.c_str());
}
when i compile, i get this error
[Linker Fehler] Unresolved external '_IB_UnZipArchiveFile' referenced from
C:\PROGRAMME\BORLAND\CBUILDER5\PROJECTS\ZIP\UNIT1.OBJ
what does this error mean. may the function works, when i load it dynamical
from the dll? how can i do this?
jens
 
 

Re:convert static dll function load to dynamic load

"Jens Harms" < XXXX@XXXXX.COM >wrote in message
Quote
extern "C" void __declspec(dllimport) IB_UnZipArchiveFile(const char*
szArchive);
That is not the correct declaration. You forgot the calling convention, and
have the wrong return value:
extern "C" __declspec(dllimport)
int __stdcall IB_UnZipArchiveFile(char* lpFiles);
Quote
String file = GetCurrentDir() + AnsiString("\\test.zip");
Use ExtractFileName(Application->ExeName) instead of GetCurrentDir(). The
process's current directory can be changed at runtime for any number of
reasons, such as from OS file-related dialogs, and also the Win3.1
components.
Quote
when i compile, i get this error
Since you did not declare the function correctly to begin with, the linker
is looking for the wrong thing.
Gambit
 

Re:convert static dll function load to dynamic load

Quote
That is not the correct declaration. You forgot the calling convention,
and
have the wrong return value:

extern "C" __declspec(dllimport)
int __stdcall IB_UnZipArchiveFile(char* lpFiles);
How did you find out the right declaration.
Now my projectz compile, but i get an other error, here again my source:
extern "C" __declspec(dllimport) int __stdcall IB_UnZipArchiveFile(char*
lpFiles);
//--------------------------------------------------------------------------
-
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::Button1Click(TObject *Sender)
{
String file = ExtractFileName(Application->ExeName) +
AnsiString("\\test.zip");
IB_UnZipArchiveFile(file.c_str());
}
//--------------------------------------------------------------------------
-
wenn i comment out the line IB_UnZipArchiveFile(file.c_str()); i can
compile without errors. otherwise i get the error (translated to englisch)
in a messagebox:
Title: project1.exe - component not found
text: the application could not run, because project1.dll was not found. a
new installation of the application could solve that problem.
i cant understand, because my dll i use ist called ib-zip.dll and i include
the lib file ib-zip.lib to my project.
why do i get this error?
jens
 

{smallsort}

Re:convert static dll function load to dynamic load

Jens Harms wrote:
Quote
text: the application could not run, because project1.dll was not found. a
new installation of the application could solve that problem.

i cant understand, because my dll i use ist called ib-zip.dll and i include
the lib file ib-zip.lib to my project.

why do i get this error?
Look at the stuff inside the lib file.
It lists the function names along with the DLL they are to be found
in. In this case, the DLL associated with every function is
"project1.dll" Rename ib-zip.dll to project1.dll, and it should work.
(It did say it was a demo version.)
 

Re:convert static dll function load to dynamic load

"Jens Harms" < XXXX@XXXXX.COM >wrote in message
Quote
How did you find out the right declaration.
The download for the DLL includes documentation.
Quote
String file = ExtractFileName(Application->ExeName) +
You should be using ExtractFilePath(), not ExtractFileName().
Quote
AnsiString("\\test.zip");
Get rid of the backslash. ExtractFilePath() will always include a trailing
backslash.
Quote
Title: project1.exe - component not found

text: the application could not run, because project1.dll was not found.
a new installation of the application could solve that problem.
You did not put the DLL in a folder on the hard drive where the OS could
find it. Look at the documentation for the LoadLibrary() function in the
Win32 API for details about where the OS looks for DLLs.
Gambit