Groups | Blog | Home
all groups > dotnet interop > june 2004 >

dotnet interop : How to call a Win32 dll ?


Dotnetjunky
6/28/2004 1:37:02 AM
Hi experts,

Can anyone show me how to call a function defined in a normal Win32.dll ?

Thanks in advance

AlexS
6/28/2004 8:16:08 AM
Hi, Dotnetjunky - Kinh

You might want to check samples in
http://msdn.microsoft.com/library/default.asp?url=/msdnmag/issues/03/07/NET/toc.asp

HTH
Alex

[quoted text, click to view]

Ken Tucker [MVP]
6/28/2004 9:19:57 AM
Hi,

http://pinvoke.net/

Ken
-------------

[quoted text, click to view]

--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.6 - Release Date: 6/25/2004

Chua Wen Ching
7/2/2004 3:52:02 AM
Hi Dotnetjunky,

Platform Invocation is the right way to go. Normally people called it P/Invoke.

Keyword used: DllImport

1 short example calling a custom made C Dll:

// Entrypoint here means ordinal. To know the ordinal, use dependency walker to
// check. It is part of visual studio 6.0.
[DllImport("abc.dll", EntryPoint="#5", CharSet=CharSet.Unicode, ExactSpelling=true)]
private extern static int CallValue(ushort u16Port, ref ushort pHandle);

It will work with win32 dlls. Just you had to be careful what kind of data types of be used.

Hope it helps.
--
Regards,
Chua Wen Ching :)


[quoted text, click to view]
AddThis Social Bookmark Button