Calling a dll in C#??

  • Thread starter stanley stanley
  • Start date
S

stanley stanley

i am developing an application that communicate with a card
terminal(used in POS system), so i need to use the dll provided by the
terminal vender. The problem is , i dont know how use the dll in my
application.
I dont know the dll is develop by which language.
How can i know , what functions are defined in the dll?

(There is no API Specification provided to me!!)

Can anyone tell me what should i do??please help
 
D

danielshanyfelt

I would like to add an additional question to Stanley's post. For his
issue I believe the suggested action is to have the dll vendor produce
a pia. This is fine if the vendor will do this. In the past, because
I could not get a pia, I have made rcws using direct reference or
tlbimp and then occasionally wrapped the dll one more level providing
extra logic to the dll calls. The lack of a pia, however prevents
using the gac because I cannot assign a strong name. Is a pia the only
way to get a third party dll rcw into the gac? I am about to do this
again and I want to get opinions on what the best practices are.
Thanks,
Dan
 
B

Bob Powell [MVP]

As Ollie points out there is some discovery you can do to see what functions
the DLL exposes if it's to be used as an extension DLL.

If you're lucky it might be a COM component in the DLL. Try adding a
reference to it as a COM component. If it is one a PIA will be generated for
you.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
S

stork

(There is no API Specification provided to me!!)

If there is no API specification, then try to see if it is a vanilla
COM object first. You should be able to use OLE/COM object view to
look at it, or, the Active X control test container. You can also fire
up any MS tool that supports automation, such as Excel or Access or old
VB, and see if you can register the component.

If it is a COM object, then you use COM interop to look at it. If it
is not a COM object, then you can fire up your Visual Studio Command
prompt and type in

dumpbin /exports fullpathandname.dll

and get a list of functions in the DLL. Unfortunately, if it is a
"normal" C style DLL, then you will need to get at least a header file
from the vendor that allows you to figure out what the calling
signatures are. If you have at least that, then, you can the DllImport
attribute to declare the function and the dll with it. For example, for
a function in a Windows stock DLL, the declaration would like this:

[DllImport("User32.dll")]
private static extern int SendMessage(IntPtr hWnd,
int msg , int wParam , ref RECT lParam);
 
W

Willy Denoyette [MVP]

stanley stanley said:
i am developing an application that communicate with a card
terminal(used in POS system), so i need to use the dll provided by the
terminal vender. The problem is , i dont know how use the dll in my
application.
I dont know the dll is develop by which language.
How can i know , what functions are defined in the dll?

(There is no API Specification provided to me!!)

Well, don't use it, or call the vendor for the documentation.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top