Searching desparately for createmailslot example in VB.NET (MSDN universal Subscriber)

D

DirkMS

Hi,


Declare Function CreateMailslot Lib "kernel32.dll" _
Alias "CreateMailslotA" ( _
ByVal lpName As String, _
ByVal nMaxMessageSize As Long, _
ByVal lReadTimeout As Long, _
ByVal lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As
Long) As Long

'
 
H

Herfried K. Wagner [MVP]

DirkMS said:
Declare Function CreateMailslot Lib "kernel32.dll" _
Alias "CreateMailslotA" ( _
ByVal lpName As String, _
ByVal nMaxMessageSize As Long, _
ByVal lReadTimeout As Long, _
ByVal lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As
Long) As Long

Your declarations are wrong. Use these instead:

\\\
Private Declare Auto Function CreateMailslot Lib "kernel32.dll" ( _
ByVal lpName As String, _
ByVal nMaxMessageSize As Int32, _
ByVal lReadTimeout As Int32, _
ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES _
) As IntPtr

Private Declare Function CloseHandle Lib "kernel32.dll" ( _
ByVal hObject As IntPtr _
) As Boolean
///
 
D

DirkMS

Your declarations are wrong. Use these instead:

\\\
Private Declare Auto Function CreateMailslot Lib "kernel32.dll" ( _
ByVal lpName As String, _
ByVal nMaxMessageSize As Int32, _
ByVal lReadTimeout As Int32, _
ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES _
) As IntPtr

Private Declare Function CloseHandle Lib "kernel32.dll" ( _
ByVal hObject As IntPtr _
) As Boolean
///


Hi Herfried,

thank you very much, i will try it as soon I'm back in office.
I found 5 or more variants of declarations (but not this one). Is there a
good source or book for correct API declarations in VB.NET?
Do you know a link to further informations about using mailslots in VB.NET?
Thanks and have a nice weekend.
DirkMS
 
H

Herfried K. Wagner [MVP]

DirkMS said:
I found 5 or more variants of declarations (but not this one). Is there a
good source or book for correct API declarations in VB.NET?

Unfortunately I do not know a good source for API declarations I could
recommend. The declaration I have posted has been created by manually
translating the C function prototype to VB.

Note that there are many differences between API declarations for VB6 and
VB.NET. Converting the declarations is not a straightforward process.
Instead it's often necessary to completely rewrite the declarations because
VB.NET provides some additional features to access API functions which VB6
does not provide.
Do you know a link to further informations about using mailslots in
VB.NET?

Unfortunately no, but if you need additional function declarations
translated to VB.NET, feel free to ask. There's nothing worse than code
which uses invalid function declarations.
 
D

DirkMS

Your declarations are wrong. Use these instead:

\\\
Private Declare Auto Function CreateMailslot Lib "kernel32.dll" ( _
ByVal lpName As String, _
ByVal nMaxMessageSize As Int32, _
ByVal lReadTimeout As Int32, _
ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES _
) As IntPtr

Private Declare Function CloseHandle Lib "kernel32.dll" ( _
ByVal hObject As IntPtr _
) As Boolean
///

Hi Herfried,

thank you, with IntPtr it works!
 

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

Similar Threads


Top