Her er noe kode som jeg lastet ned fra en eller annen web-site for en tid
siden.
Private Declare Function NetMessageBufferSend Lib "NetApi32" _
(ByVal Reserved&, lpUserID As Byte, ByVal Reserved1&, _
lpMessage As Byte, ByVal MessageLen&) As Long
Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Enum cNetErrors
NERR_SUCCESS = 0
ERROR_ACCESS_DENIED = 5
ERROR_NOT_SUPPORTED = 50
ERROR_INVALID_PARAMETER = 87
NERR_NETWORKERROR = 2136
NERR_NAME_NOT_FOUND = 2273
End Enum
'
'
Public Function SendMessage(UserIDorPCName As Variant, Message As Variant)
As Variant
Dim lRes&
Dim lpUserID() As Byte
Dim lpMessage() As Byte
Dim sUser$, nSize&
Dim sMessageName$, sMessage$
sMessageName$ = UserIDorPCName
sMessage$ = Message
On Error Resume Next
If sMessageName$ = "" Then Exit Function
If sMessage$ = "" Then Exit Function
nSize& = 30
sUser$ = String(nSize& + 1, 0)
lRes& = GetUserName(sUser$, nSize&)
sUser$ = Left(sUser$, nSize& - 1)
sMessage$ = "Beskjed fra: " & UCase(sUser) & vbCrLf & vbCrLf & _
sMessage$
lpUserID() = sMessageName$ & Chr(0) & Chr(0)
lpMessage() = sMessage$ & Chr(0) & Chr(0)
lRes& = NetMessageBufferSend(0&, lpUserID(0), 0&, lpMessage(0),
Len(sMessage$) * 2)
SendMessage = lRes&
End Function
mvh
Bjørnar Nilsen
"Kristian Thomsen" <faurskov@person.dk> skrev i melding
news:9a01fo$ddn$1@news.inet.tele.dk...
> Hej
>
> Hvis man ønsker at sende en net send besked til alle brugere i en
workgroup
> eller et domain, hvordan gør man det hvis man anvender
NetMessageBufferSend
> API'et ?
>
> Kristian Thomsen
>
>
|