Call 64bit dll's function from 32 bit delphi code on 64 bit OS

Is there any way or trick to call a function in 64 bit DLL from Delphi code? 

Any hardware manufacturer must compile their device drivers into 64bit code for 64 bit OS. So  for example, graphic driver from NVidia is compiled to 64bit code for 64bit OS. Question is how to load 64 bit dll from 32 bit delphi code and call such function?

I hope somebody has already dealing with that. 

Thanks
0
srdjan
11/5/2009 8:30:54 PM
embarcadero.delphi.non-tech 5933 articles. 1 followers. Follow

22 Replies
2807 Views

Similar Articles

[PageSpeed] 39

> is how to load 64 bit dll from 32 bit delphi code and call such function?

http://msdn.microsoft.com/en-us/library/aa384249(VS.85).aspx
http://blogs.msdn.com/oldnewthing/archive/2008/10/20/9006720.aspx

That's why someone needs a 64 bit Delphi....
0
Luigi
11/5/2009 9:06:24 PM
Hi Luigi,
 
> That's why someone needs a 64 bit Delphi....

I AGREE!!!!!!

Best Regards

Claudio 

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4577 (20091105) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
0
Claudio
11/5/2009 9:35:39 PM
<srdjan crnjanski> wrote in message news:180390@forums.codegear.com...

> Is there any way or trick to call a function in 64 bit DLL from Delphi 
> code?

No.  Delphi only produces 32-bit executables, and a 32-bit process cannot 
load a 64-bit DLL at all, let alone call into it.

> Any hardware manufacturer must compile their device drivers into 64bit
> code for 64 bit OS.

Devices drivers are loaded by the OS itself, so yes, a 64-bit OS needs 
64-bit drivers.

> Question is how to load 64 bit dll from 32 bit delphi code and call such 
> function?

You can't.

-- 
Remy Lebeau (TeamB)
0
Remy
11/5/2009 10:14:02 PM
Remy Lebeau (TeamB) wrote:

> <srdjan crnjanski> wrote in message news:180390@forums.codegear.com...
> 
> > Is there any way or trick to call a function in 64 bit DLL from
> > Delphi  code?
> 
> No.  Delphi only produces 32-bit executables, and a 32-bit process
> cannot load a 64-bit DLL at all, let alone call into it.
> 
> > Any hardware manufacturer must compile their device drivers into
> > 64bit code for 64 bit OS.
> 
> Devices drivers are loaded by the OS itself, so yes, a 64-bit OS
> needs 64-bit drivers.
> 
> > Question is how to load 64 bit dll from 32 bit delphi code and call
> > such  function?
> 
> You can't.

But can a 32 bit program pass messages to 64 bit programs? If so, one
could write a simple 64 bit thunk program that calls the DLL, and
control that program using messages. It's a bit convoluted, but that is
what I did when interfacing 16 and 32 bit code.

-- 
Rudy Velthuis (TeamB)        http://www.teamb.com

"When great changes occur in history, when great principles are
 involved, as a rule the majority are wrong."
 -- Eugene V. Debs
0
Rudy
11/5/2009 10:54:56 PM
Rudy Velthuis <newsgroups@rvelthuis.de> wrote in message 
<180469@forums.codegear.com>
> But can a 32 bit program pass messages to 64 bit programs? If so, one
> could write a simple 64 bit thunk program that calls the DLL, and
> control that program using messages. It's a bit convoluted, but that is
> what I did when interfacing 16 and 32 bit code.

It seems that one could write a ready-made framework to do this, using RTTI on 
the Delphi side, some kind of IDL over a communication protocol like TCP/IP, 
and a 64-bit service that knows how to translate those RPC's into and from 
64-bit calls.

marc hoffman, are you reading this? If so, is this something that RemObjects 
already can do? Maybe there is some money to be made marketing a 64-bit 
thunking layer for Delphi?

-- 
***Free Your Mind***

Posted with JSNewsreader Preview 0.9.7.4990
0
John
11/5/2009 11:16:54 PM
Rudy Velthuis (TeamB) <newsgroups@rvelthuis.de> wrote:

>But can a 32 bit program pass messages to 64 bit programs? If so, one
>could write a simple 64 bit thunk program that calls the DLL, and
>control that program using messages. It's a bit convoluted, but that is


Oh why this..  99% will sove this with moving to Visual Studio and/or
to .NET.. Delphi is obsolete solution for 64-bit enviroment. 

We do more training today for old Delphi developers that are moving to
VS than teaching users to use new features on D2010. this will tell
where Delphi developers are going. These tweaks are the way. If you
need to use other toold to write 64bit thunk program then why not just
to all native 64-bit..

>what I did when interfacing 16 and 32 bit code.

Are you still coding with Delphi 1?? No thats why we have 32-bit
Delphi and now we need 64-bit. 

I can tell these numbers from my customer base from past 2 months. 
- 16 companies have told us that Delphi 2010 is last version that they
buy as now they upgrade current applications to windows 7. After that
those applications will go on maintenance mode. All new application
will be started on another tools. 
- In licenses that will mean 26 Enterprise and  8 professional user
lost from now on. 
- 9 companies have not upgrade as they have bougth Visual Studio and
Delphi applications are in maint mode. These might come back if there
is SOON a 64-bit Delphi

I have told this to Embaracadero many time. Still no new info or
announcement or roadmap details. I understand that Mac and Linux (aka
Delphi X) has nice story, but 64-bit is needed now as that will bring
deals and money faster to Embaracadero. For other I just see small
groupusing "delphi x" and have this kylix feeling again. 




Regards, Qapla'
                   Juha Piispa
0
Juha
11/6/2009 5:00:57 AM
srdjan,

> Is there any way or trick to call a function in 64 bit DLL from Delphi code?

no.
Maybe Prism is an alternative for you. It depends on your source code if 
you have to rewrite everything or only parts of your code.

-- 
Roman
0
Roman
11/6/2009 5:36:10 AM
John Jacobson wrote:
> It seems that one could write a ready-made framework to do this, using RTTI on 
> the Delphi side, some kind of IDL over a communication protocol like TCP/IP, 

Simple Windows messages should be enough, does anyone know if WM_COPYDATA works across the 32/64 barrier?

-- 
Regards
Jens
0
Utf
11/6/2009 8:59:18 AM
Jens,

> Simple Windows messages should be enough, does anyone know if WM_COPYDATA works across the 32/64 barrier?

It worked across the 16/32 barrier.

-- 
Roman
0
Roman
11/6/2009 9:07:45 AM
Roman Kassebaum wrote:
> Jens,
> 
>> Simple Windows messages should be enough, does anyone know if WM_COPYDATA works across the 32/64 barrier?
> 
> It worked across the 16/32 barrier.
> 

I just read that it should work, so the only thing that's left now is to write a library in Delphi 32-Bit and some proxy using a script interpreter on the 64-Bit side. 

-- 
Regards
Jens
0
Utf
11/6/2009 9:10:39 AM
> Devices drivers are loaded by the OS itself, so yes, a 64-bit OS needs
> 64-bit drivers.

So you can't access a driver (f.i display driver) that is loaded by the OS ?

Paul
0
Paul
11/6/2009 9:46:04 AM
> But can a 32 bit program pass messages to 64 bit programs? If so, one
How a 32bit app can communicate with a 64 bit app is written here:
http://msdn.microsoft.com/en-us/library/aa384203%28VS.85%29.aspx

kind regards
   Mike
0
Michael
11/6/2009 10:38:42 AM
Paul Blommaerts schrieb:
>> Devices drivers are loaded by the OS itself, so yes, a 64-bit OS needs
>> 64-bit drivers.
> 
> So you can't access a driver (f.i display driver) that is loaded by the OS ?
> 
> Paul

Depends on the driver. For the video driver e.g. you don't access it
normally as every normal thing will go through GDI/GDI+

Greetings

Markus
0
Markus
11/6/2009 12:38:25 PM
Rudy Velthuis (TeamB) wrote:

> 
> But can a 32 bit program pass messages to 64 bit programs? If so, one
> could write a simple 64 bit thunk program that calls the DLL, and
> control that program using messages. It's a bit convoluted, but that
> is what I did when interfacing 16 and 32 bit code.

Or you could write a 64 bit out of process COM server, and do it that
way.

Mike S.
0
Mike
11/6/2009 1:41:25 PM
Juha Piispa wrote:

> Oh why this..  99% will sove this with moving to Visual Studio and/or
> to .NET.. Delphi is obsolete solution for 64-bit enviroment.

No, not 99% will simply leave their entire code base behind and start
all over again, painfully porting their large projects to a different
and unknown language on a different and unknown platform. If there is a
need to call a 64 bit DLL for now, that may be a solution until there
is a 64 bit Delphi.
-- 
Rudy Velthuis (TeamB)        http://www.teamb.com

"Write injuries in sand, kindnesses in marble."
 -- French proverb
0
Rudy
11/6/2009 7:08:49 PM
Mike Swaim wrote:

> Rudy Velthuis (TeamB) wrote:
> 
> > 
> > But can a 32 bit program pass messages to 64 bit programs? If so,
> > one could write a simple 64 bit thunk program that calls the DLL,
> > and control that program using messages. It's a bit convoluted, but
> > that is what I did when interfacing 16 and 32 bit code.
> 
> Or you could write a 64 bit out of process COM server, and do it that
> way.

Agreed. That is probably a much better alternative than mine.

-- 
Rudy Velthuis (TeamB)        http://www.teamb.com

"A model is done when nothing else can be taken out." -- Dyson
0
Rudy
11/6/2009 7:09:46 PM
"Rudy Velthuis (TeamB)" <newsgroups@rvelthuis.de> wrote in message 
news:180469@forums.codegear.com...

> But can a 32 bit program pass messages to 64 bit programs?

Yes.  In fact, there is a IsWow64Message() function that allows a 64-bit 
process to determine if the last message retreived from its message queue 
was from a 32-bit process, so it can decide whether to interpret the message 
parameters as 32-bit or 64-bit:

    http://msdn.microsoft.com/en-us/library/ms684136.aspx

-- 
Remy Lebeau (TeamB)
0
Remy
11/6/2009 7:26:02 PM
"Roman Kassebaum" <roman@nospamremoveitkassebaum.eu> wrote in message 
news:180590@forums.codegear.com...

> It worked across the 16/32 barrier.

That is because 16-bit and 32-bit processes both operated in a 32-bit 
address space.  That is not the case between the 32/64 barrier, which is why 
normal thunking techniques don't work like they did through the 16/32 
barrier.

-- 
Remy Lebeau (TeamB)
0
Remy
11/6/2009 7:30:23 PM
"Juha Piispa" <juha.piispa@moonsoft.fi> wrote in message 
news:180554@forums.codegear.com...

> Oh why this..  99% will sove this with moving to Visual Studio and/or
> to .NET.. Delphi is obsolete solution for 64-bit enviroment.

Only because Delphi has not been updated to support 64-bit yet.  That is 
still on the development plan.  But when it does finally support 64-bit, I 
seriously doubt it will be an "obsolete" environment.

-- 
Remy Lebeau (TeamB)
0
Remy
11/6/2009 7:32:35 PM
Rudy Velthuis (TeamB) wrote:
> 
> But can a 32 bit program pass messages to 64 bit programs? If so, one
> could write a simple 64 bit thunk program that calls the DLL, and
> control that program using messages. It's a bit convoluted, but that is
> what I did when interfacing 16 and 32 bit code.
> 
Reminds me of the old PharLap DOS extenders which did some interesting 
tricks of this sort switching between Real and Protected Mode and 
copying memory between address spaces. I had a lot of fun using PharLap 
with Borland C++ back then.

The downside to what you are suggesting is that the DLL would be outside 
the address space of the application and all data passed in and out 
would need to be marshaled. As was the case with PharLap, it would not 
be possible to pass meaningful pointers between the two address spaces.

Anyone check to see what sort of interoperability exists with COM 
objects? I seems like MS would need to have worked out a solution for 
out of process COM servers since that is a core Windows technology.

-- 
David Taylor
eXtensia Technologies
http://www.extensiatech.com
0
david
11/7/2009 5:15:45 PM
david taylor wrote:

> Anyone check to see what sort of interoperability exists with COM 
> objects? I seems like MS would need to have worked out a solution for 
> out of process COM servers since that is a core Windows technology.

InProc is no go, since a 32 bit process can't host a 64 bit DLL (and
vice versa). Out of proc COM servers are supported.

Mike S.
0
Mike
11/9/2009 1:52:41 PM
John,

> It seems that one could write a ready-made framework to do this, using RTTI on
> the Delphi side, some kind of IDL over a communication protocol like TCP/IP,
> and a 64-bit service that knows how to translate those RPC's into and from
> 64-bit calls.
>
> marc hoffman, are you reading this? If so, is this something that RemObjects
> already can do? Maybe there is some money to be made marketing a 64-bit
> thunking layer for Delphi?

we have a solution that does this - its called RemObjects SDK ;)
0
marc
11/9/2009 2:06:00 PM
Reply:

Similar Artilces:

Createing 32 bit Delphi dll for Windows 64 OS
Hello, I develop a java application that uses a dll which is being written in delphi. I use a 32-bit jvm on a 64-bit windows 7 OS. When my java code calls the Delphi code, I get "unsetesfied link error". I have checked the dll dependencies and saw that the dll depends on windows dlls, which are located in C:\Windows\System32. The problem is (I think) that the dlls in that folder are 64-bit, and the jvm expects to recieve 32-bit dlls for the 32-bit application. I know that the windows dlls for 32-bit are located in C:\Windows\SysWow64. Does anyone have a solution for how to...

Are there any 32-bit or 64-bit ODBC drivers for ASA 9.0 for Windows OS's available for download?
Hi everyone, I'd like to create a dsn pointing to ASA 9.0 database on a remote server. The local PC does not have any Sybase / ASA product installed. 1. Is it possible to create the DSN on this local PC? 2. If so, where can I possibly get the drivers? 3. Any other information on this will be highly appreciated. Regards. might want to post this question to the sybase.public.sqlanywhere.general newsgroup. This is an ASE newsgroup. <ckmutunga@gmail.com> wrote in message news:7548f502-4963-4c66-8acd-121c443c59f5@k37g2000hsf.googlegroups.com... > Hi everyone, > ...

Excel 64-bit and Delphi 32-bit
Hi, Any known issues with using Excel 2010 64-bit with a Delphi 32-bit app (Delphi 2009) My app uses the ExcelXP TExcelApplication object and nothing real fancy. I basically opens Excel, gets a list of all the ranges, and then updates the cells. It works fine with Excel 2007 but I have one customer who is reporting problems and he has Excel 2010 64-bit. Also, is there a way for my app to determine if Excel is 32 or 64-bit so that I can log an appropriate message. -- Bob Small I think one the main points of the new Delphi 64-bit compiler was that it was required to be able...

32-bit clent or 64-bit client on 64-bit O/S
We currently have a 32-bit client running on AIX 4.3.3 32-bit. We're moving that client to an AIX 5.x 64-bit system. Is there any advantage to switching to the 64-bit Sybase client? I'm not sure if it matters but the ASE Server that the client uses is 12.5 64-bit running on a 64-bit O/S. TIA only if you client app needs the extra memory "Richard" <rmcgorman@gmail.com> wrote in message news:1170712581.822225.158160@h3g2000cwc.googlegroups.com... > We currently have a 32-bit client running on AIX 4.3.3 32-bit. We're > moving that > ...

XML for Delphi XE6 32-bit/64-bit
I am looking for a straight-forward no frills XML library or component that allows me to easily form an XML file and to parse it easily as a means to transfer text (could be long and lengthy) information back and forth between applications. I would appreciate any recommendation of such a resource. Or maybe XML is not a good option for my application? Thanking you all in advance. Andy Andy wrote: > I am looking for a straight-forward no frills XML library or component > that allows me to easily form an XML file and to parse it easily as a > means to transfer text (co...

VmWare 7 on 64 bit Win7 U:installer says '32 bit OS'
Hello, I am trying to install the latest SUSE in a virtual machine created on 64 bit Windows 7 Ultimate. When the CD loads in the VM's console it says 'This is a 32 bit computer. You cannot use 64 bit software on it'. I am running the free VmWare Server 2.0. Windows 7 sys info clearly shows it as 64 bit OS, and it is running on i7-720 (definitely a quad core 64 bit proc). Any suggestions? Thanks. AK -- nov_suse ------------------------------------------------------------------------ Forgot to mention... I have clearly chosen the guest OS as SUSE L...

How to tell that my 32 bit code is running on a 64 bit OS?
I have various procedures to detect OS name, version, IE version, various DLL versions etc. Recently I have run it on 64bit Vista Ultimate, and based on the information I received, I would have never guessed that the OS was 64bit. IE was reported as 32 bit, The same with WinInet, Comctrl, etc. Even the system folder was reported as C:\Windows\system32. As I said, the "64bit" phrase was nowhere to be found. I understand that 32 bit code will use 32bit environment, but how can I tell that the OS version was 64 bit? Any ideas? Captain Mockba wrote: > how can I tell that...

Calling 16-bit functions (DLL) from 32-bit App?
I've migrated a 16-bit app to a 32-bit app recently. The one problem is that we purchased a communications DLL from a third party who has since gone out of business, so there's no chance at getting a 32-bit version. The DLL is 16-bit, and PowerBuilder (32-bit) has a problem opening the library. Is there anyway to call functions in a 16-bit DLL from a 32-bit application? Chris, Unfortunately not. Unless the DLL is 'thunkable', then it can't be accessed from PB. Who is/was the 3rd party vendor? hth, -- Anthony M. Perugini Principal Consultant CPDP,...

Delphi 32 bit application on 64bit OS
Problem running delphi application developed in 2010 on 64bit windows operating system. Application crashes suddenly. Access violations in system.pas related to string functions. Please give more information (like : error messages, access violations, etc...) > {quote:title=sandhya gondhi wrote:}{quote} > Problem running delphi application developed in 2010 on 64bit windows operating system. > Application crashes suddenly. > Access violations in system.pas related to string functions. ComSurrogate has stopped working. <Application> has stopped working. Access ...

Web app referencing 32-bit dll on 64-bit OS
I have a web app that I am trying to deploy on a Windows 2003 x64 OS on a dedicated server at 1 and 1. I am having trouble referencing one of the required 3rd party dlls. I get the following error: Retrieving the COM class factory for component with CLSID {DC28F64E-2B61-45C9-BA3F-26664BB9973F} failed due to the following error: 80040154  Everything I have read points to the fact that this is a 32-bit dll on a 64-bit server. I have set IIS to run in worker proces isolation mode and Enable32bitApponWin64 set to "true". What else do I need to do to get this to work? Any help wo...

32 bit Delphi Active X Control on 64 Bit machines
I'm using BDS 2006 and created a very simple Active X control ( COM ) ocx file that does nothing but return a string in a property. Placing the control on a .net application that contains a label reflecting the property builds and runs beautifully in 32 bit Windows Vista. Moving the application to Windows 7 64 bit fails. Debugging shows it doesn't even get to initialization. Is it possible to use COM through syswow64? <Steven Davis> wrote in message news:225825@forums.embarcadero.com... > I'm using BDS 2006 and created a very simple Active X control > ( COM ) ...

Probable Stupid Question: Using 64-bit Code on 64-bit Processors running 32-bit Windows...
Hi, Does anyone know if it is possible to do 64-bit processing (probably by writing some assembly language code) when running on a 64-bit CPU under 32-bit Windows? As near as I can tell, one has to develop all 64-bit code on a 64-bit machine running 64-bit windows and the target machines for 64-bit code have to be 64-bit machines running 64-bit windows. What might be useful, if it is possible, would be being able to detect a 64-bit processor when running 32-bit windows and take advantage of that to speed up some calculations. DanH ...

16-bit PBD's V 32-bit PBD's
Does anybody know if there's any difference between 16-bit and 32-bit PBD files? Obviously the .exe files will be different between a 16-bit and 32-bit compile, but I'm curious about the PBD's. When I tested it they seemed to be interchangeable, but I seem to recall reading somewhere that it's not a good idea to mix 'n match them. I'm reluctant to clutter up my installation disks with two sets of PBD files if only one is needed! Charles Butcher Since PBDs are interpreted at run time, you can use the same PBD in a 16-bit or a 32-bit applications (external...

Probable Stupid Question: Using 64-bit Code on 64-bit Processors running 32-bit Windows... #2
Hi, Does anyone know if it is possible to do 64-bit processing (probably by writing some assembly language code) when running on a 64-bit CPU under 32-bit Windows? As near as I can tell, one has to develop all 64-bit code on a 64-bit machine running 64-bit windows and the target machines for 64-bit code have to be 64-bit machines running 64-bit windows. What might be useful, if it is possible, would be being able to detect a 64-bit processor when running 32-bit windows and take advantage of that to speed up some calculations. DanH Dan Hale wrote: > Does anyone k...

Web resources about - Call 64bit dll's function from 32 bit delphi code on 64 bit OS - embarcadero.delphi.non-tech

Resources last updated: 1/8/2016 3:28:20 AM