Home All Groups Group Topic Archive Search About

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

Author
19 Oct 2006 2:50 PM
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

'

Author
19 Oct 2006 3:10 PM
Herfried K. Wagner [MVP]
"DirkMS" <m***@nowhere.com> schrieb:
> 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
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
20 Oct 2006 6:14 PM
DirkMS
Show quote Hide quote
> 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
> ///
>
> --
> M S   Herfried K. Wagner


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
Author
20 Oct 2006 9:36 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"DirkMS" <m*@nowhere.com> schrieb:
>> 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
>> ///
>>
>
> 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.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
2 Nov 2006 10:46 AM
DirkMS
Show quote Hide quote
>
> 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!