 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Rudolf Heider Guest
|
Posted: Wed Sep 10, 2003 7:17 am Post subject: How to use Delphi and Visual C together? |
|
|
Hellow!
Sometimes I use Delphi to make simple front-ends for various tools, writed
on c++ , and I have two questions:
1. How to link a DLL to a Delphi unit correctly?
For example, I had define the function as:
--------------------
extern "C"{
__declspec(dllexport) DWORD WINAPI OpenSourceFile(const char *fileName,
const char *destPath)
--------------------
, but the Delphi application cannot find this function in the DLL, until I
define the function as follows:
--------------------
interface
function OpenSourceFile(Name: PChar; Dest: PChar): Integer; stdcall;
{$EXTERNALSYM OpenSourceFile}
implementation
function OpenSourceFile; external CoreName name '_OpenSourceFile@8';
--------------------
Where I'm wrong?
2. I found that Delphi 6 doesn't unlock the dll after first run or debug the
program, so I need to restart Delphi to compile the dll in Visual C. Is any
way to avoid this?
Excuse for me bad English,
WBR,
Rudolf Heider.
|
|
| Back to top |
|
 |
Brian Cook Guest
|
Posted: Wed Sep 10, 2003 8:12 am Post subject: Re: How to use Delphi and Visual C together? |
|
|
Greetings.
| Quote: | Sometimes I use Delphi to make simple front-ends for various tools, writed
on c++ , and I have two questions:
1. How to link a DLL to a Delphi unit correctly?
For example, I had define the function as:
--------------------
extern "C"{
__declspec(dllexport) DWORD WINAPI OpenSourceFile(const char *fileName,
const char *destPath)
--------------------
, but the Delphi application cannot find this function in the DLL, until I
define the function as follows:
--------------------
interface
function OpenSourceFile(Name: PChar; Dest: PChar): Integer; stdcall;
{$EXTERNALSYM OpenSourceFile}
implementation
function OpenSourceFile; external CoreName name '_OpenSourceFile@8';
--------------------
Where I'm wrong?
|
You aren't wrong. Older versions of Visual C export functions with the
underscore and the "parameter bytes" decorator; the "@8" part. I
believe newer versions also include the decorator if you don't use a
"DEF" file. I may have that backwards.
It was original a standard published by Microsoft to help ensure the
correct number of bytes (parameters) are passed into a DLL. Why they
stopped doing it is a mystery to me. Probably something to do with the
transition to 64 bit operating systems. I've also wondered why they
adorned the name with the number of bytes rather than the number of
parameters.
| Quote: | 2. I found that Delphi 6 doesn't unlock the dll after first run or debug the
program, so I need to restart Delphi to compile the dll in Visual C. Is any
way to avoid this?
|
That's odd. I've always had very good luck with Delphi 6 and working
with DLLs. What operating system are you using?
| Quote: | Excuse for me bad English,
|
No need to apologize. Whoopi Goldberg quipped on her TV show that the
President of the United States is incapable of properly pronouncing the
word "nuclear". If our President has difficulties with English we
certainly can't fault you!
- Brian
|
|
| Back to top |
|
 |
Rudolf Heider Guest
|
Posted: Wed Sep 10, 2003 11:00 am Post subject: Re: How to use Delphi and Visual C together? |
|
|
Hellow!
"Brian Cook" wrote
| Quote: | You aren't wrong. Older versions of Visual C export functions with the
underscore and the "parameter bytes" decorator; the "@8" part. I
believe newer versions also include the decorator if you don't use a
"DEF" file. I may have that backwards.
|
Thank You for advice!
| Quote: | 2. I found that Delphi 6 doesn't unlock the dll after first run or debug
the
program, so I need to restart Delphi to compile the dll in Visual C. Is
any
way to avoid this?
That's odd. I've always had very good luck with Delphi 6 and working
with DLLs. What operating system are you using?
|
I use Windows XP with service pack and Delphi 6.
However, I use Visual C with Intel compiler, so MS linker replaced with
Intel ilink.exe.
Probably, this problem related to the Intel linker, I will check it.
More symptoms of the problem are:
- I can delete the dll after running or debugging the program when I use
Delphi only.
- When I made attempt to compile dll after running the program from Delphi,
the linker writes the message:
-----------------------
Linking...
xilink6: executing 'C:PROGRA~1MICROS~3VC98Binlink.exe'
LINK : fatal error LNK1105: cannot close file "ft_core.dll"
Error executing xilink6.exe.
-----------------------
After this, I cannot delete the dll from the OS.
| Quote: | No need to apologize.
|
Thank You too.
WBR,
Rudolf Heider.
|
|
| Back to top |
|
 |
Rudolf Heider Guest
|
Posted: Wed Sep 10, 2003 11:37 am Post subject: Re: How to use Delphi and Visual C together? |
|
|
"Brian Cook" wrote
| Quote: | I believe newer versions also include the decorator if you don't use a
"DEF" file. I may have that backwards.
|
Thank You again, with the DEF-file the name's decoration in the DLL became
absolutely correct!
WBR,
Rudolf Heider.
|
|
| Back to top |
|
 |
Brian Cook Guest
|
Posted: Wed Sep 10, 2003 4:43 pm Post subject: Re: How to use Delphi and Visual C together? |
|
|
Greetings.
| Quote: | You aren't wrong. Older versions of Visual C export functions with the
underscore and the "parameter bytes" decorator; the "@8" part. I
believe newer versions also include the decorator if you don't use a
"DEF" file. I may have that backwards.
Thank You for advice!
|
My pleasure.
| Quote: | 2. I found that Delphi 6 doesn't unlock the dll after first run or debug
the
program, so I need to restart Delphi to compile the dll in Visual C. Is
any
way to avoid this?
That's odd. I've always had very good luck with Delphi 6 and working
with DLLs. What operating system are you using?
I use Windows XP with service pack and Delphi 6.
However, I use Visual C with Intel compiler, so MS linker replaced with
Intel ilink.exe.
Probably, this problem related to the Intel linker, I will check it.
More symptoms of the problem are:
- I can delete the dll after running or debugging the program when I use
Delphi only.
- When I made attempt to compile dll after running the program from Delphi,
the linker writes the message:
-----------------------
Linking...
xilink6: executing 'C:PROGRA~1MICROS~3VC98Binlink.exe'
LINK : fatal error LNK1105: cannot close file "ft_core.dll"
Error executing xilink6.exe.
-----------------------
After this, I cannot delete the dll from the OS.
|
What about if you go through these steps...
1. Run your application under the Delphi debugger
2. Shutdown your application
3. Try do delete the DLL
Does that work? Do you get an "access denied" or "file locked" error?
- Brian
|
|
| Back to top |
|
 |
Victor Usoltsev Guest
|
Posted: Thu Sep 11, 2003 2:06 pm Post subject: Re: How to use Delphi and Visual C together? |
|
|
| Quote: | 1. How to link a DLL to a Delphi unit correctly?
For example, I had define the function as:
--------------------
extern "C"{
__declspec(dllexport) DWORD WINAPI OpenSourceFile(const char *fileName,
const char *destPath)
--------------------
, but the Delphi application cannot find this function in the DLL, until I
define the function as follows:
--------------------
interface
function OpenSourceFile(Name: PChar; Dest: PChar): Integer; stdcall;
{$EXTERNALSYM OpenSourceFile}
implementation
function OpenSourceFile; external CoreName name '_OpenSourceFile@8';
--------------------
|
Try to delete the WINAPI directive in C-project and replace stdcall with
cdecl in Delphi project.
|
|
| Back to top |
|
 |
Rudolf Heider Guest
|
Posted: Wed Oct 08, 2003 2:15 pm Post subject: Re: How to use Delphi and Visual C together? |
|
|
Hellow!
"Rudolf Heider" wrote
| Quote: | Soon I will move from Delphi 6 to Delphi 7, may be the problem will
disappear... |
Yes, Delphi 7 haven't this bug.
WBR,
Rudolf Heider
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|