We help IT Professionals succeed at work.
Get Started

Win32 dll into Delphi .Net

liljen_80 asked
Last Modified: 2010-04-16

I have a problem with gething Win32 dll into a Delphi .Net. (I'm using Borland 2006)

I have found in the help:
You can call unmanaged Win32 APIs (and other unmanaged code) by prefixing the function declaration with the DllImport custom attribute. This attribute resides in the System.Runtime.InteropServices namespace, as shown below:
function MessageBeep(uType : LongWord) : Boolean; external;

But I got the error:  Cannot have both a DLLImport attribute and an external or calling convention directive (E2293)

I haven't added other dll's, but I think it is somone that is there from the start. I have tryed with bouth .Net VCL Forms Application and .Net Windows Forms Application. But it is  .Net VCL Forms Application I want too use.

A bit more describing of the error:
The compiler emits DLLImport attributes internally for external function declarations. This error is raised if you declare your own DLLImport attribute on a function and use the external name clause on the function.

I have also tryed to use "ADD REFERANCE"; but I got the error: "user32.dll is not a valid assembly, type library, or COM object."

Anybody know how too solve this problem, pleace?
Watch Question
This problem has been solved!
Unlock 2 Answers and 28 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE