a question about DllImportAttribute

D

dgk

I'm not sure what the difference is between using the attribute and
just declaring a function in a dll. For that matter, what this code is
doing is also a question (from one of the 101 examples from
Microsoft):

' Specifying Unicode
Public Declare Unicode Function UnicodeBeep Lib "kernel32" Alias
"Beep" _
(ByVal dwFreq As Integer, ByVal dwDuration As Integer) As
Integer

' Specifying Ansi
Public Declare Ansi Function ANSIBeep Lib "kernel32" Alias "Beep"
_
(ByVal dwFreq As Integer, ByVal dwDuration As Integer) As
Integer

' Specifying Auto
Public Declare Auto Function AutoBeep Lib "kernel32" Alias "Beep"
_
(ByVal dwFreq As Integer, ByVal dwDuration As Integer) As
Integer

Any hints appreciated.
 
M

Mattias Sjögren

I'm not sure what the difference is between using the attribute and
just declaring a function in a dll.

See http://www.dotnetinterop.com/faq/?q=DeclareDllImport

For that matter, what this code is
doing is also a question (from one of the 101 examples from
Microsoft):

Good question, I don't know why anyone would write code like that. For
functions that don't take any string or character parameters (such as
Beep), it's irrelevant whether you use a Ansi/Auto/Unicode modifier in
the Declare statement.



Mattias
 

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