vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
sevAniGif - als kostenlose Vollversion auf unserer vb@rchiv CD Vol.5  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Visual-Basic Einsteiger
Re: Net Send Anweisung 
Autor: Matthias
Datum: 13.03.02 21:45

Hallo,

also ich persönlich finde die Lösung mit Net Send nicht so toll... Also was man machen kann, ist die Nachricht über die eingebaute Pipe (Mailslot) von Windows zu versenden. Beispiel habe ich von www.vbcity.com und ein wenig ins Deutsche übersetzt ;))))

'Modulebene
'**************
Option Explicit

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

Private Declare Function WriteFile Lib _
"kernel32" (ByVal hFilename As Long, ByVal lpBuff As Any, _
ByVal nNrBytesToWrite As Long, _
lpNrOfBytesWritten As Long, _
ByVal lpOverlapped As Long) As Long

Private Declare Function CreateFile Lib _
"kernel32" Alias "CreateFileA" ( _
ByVal lpFileName As String, _
ByVal dwAccess As Long, _
ByVal dwShare As Long, _
ByVal lpSecurityAttrib As Long, _
ByVal dwCreationDisp As Long, _
ByVal dwAttributes As Long, _
ByVal hTemplateFile As Long) As Long

Private Const Open_Existing = 3
Private Const GENERIC_READ = &H80000000
Private Const GENERIC_WRITE = &H40000000
Private Const GENERIC_EXECUTE = &H20000000
Private Const GENERIC_ALL = &H10000000
Private Const INVALID_HANDLE_VALUE = -1
Private Const FILE_SHARE_READ = &H1
Private Const FILE_SHARE_WRITE = &H2
Private Const FILE_ATTRIBUTE_NORMAL = &H80

Function SendToWinPopUp(PopVon As String, _
PopZu As String, MsgText As String) As Long
'parms: PopVon: Benutzer oder Computer welchers
' die Message sendet (!!!! wird nicht überprüft da kann XYZ stehen )
' PopZu: PC welcher die Nachricht erhält
' MsgText: Nachrichtentext
Dim rc As Long
Dim msHandle As Long
Dim msgtxt As String
Dim byteswritten As Long
Dim mailslotname As String
' name of the mailslot
mailslotname = "\" + PopZu + _
"mailslotmessngr"
msgtxt = PopVon + Chr(0) + PopZu + Chr(0) + _
MsgText + Chr(0)
msHandle = CreateFile(mailslotname, _
GENERIC_WRITE, FILE_SHARE_READ, 0, _
Open_Existing, FILE_ATTRIBUTE_NORMAL, 0)
rc = WriteFile(msHandle, msgtxt, _
Len(msgtxt), byteswritten, 0)
rc = CloseHandle(msHandle)
End Function

Aufruf wie folgt:
****************
Private Sub Command1_Click()
SendToWinPopUp "vbArchiv", "MATTHIAS", "HALLO WELT "
End Sub

************************************************************************************************
Also das oben genannte Beispiel läuft bei mir einwandfrei auf einem Win9x System. Für ein NT System habe ich folgendes in einem Englischen Forum gefunden (NICHT GETESTET !!! vielleicht kann das mal ja einer unter NT testen und mir sagen ob es funktioniert ?!?)

Private Declare Function NetMessageBufferSend Lib _
"NETAPI32.DLL" (yServer As Any, yToName As Byte, _
yFromName As Any, yMsg As Byte, ByVal lSize As Long) As Long

Private Const NERR_Success As Long = 0&


Public Function BroadcastMessage(sToUser As String, _
sFromUser As String, sMessage As String) As Boolean

Dim yToName() As Byte
Dim yFromName() As Byte
Dim yMsg() As Byte
Dim l As Long

yToName = sToUser & vbNullChar
yFromName = sFromUser & vbNullChar
yMsg = sMessage & vbNullChar

If NetMessageBufferSend(ByVal 0&, yToName(0), ByVal 0&, _
yMsg(0), UBound(yMsg)) = NERR_Success Then

BroadcastMessage = True

End If

End Function

Aufruf:
*******
Private Sub Command1_Click()
Dim x As Boolean

x = BroadcastMessage(TxtTo.Text, TxtFrom.Text, TxtMsg.Text)
If x Then
MsgBox "Nachricht gesendet"
Else
MsgBox "Narchricht nicht gesendet"
End If
End Sub

Gruß
Matthias
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Net Send Anweisung57VB13.03.02 16:20
Re: Net Send Anweisung252ModeratorDieter13.03.02 17:54
Re: Net Send Anweisung39Matthias13.03.02 21:47
Re: Net Send Anweisung216ModeratorDieter13.03.02 21:51
Re: Net Send Anweisung44Matthias13.03.02 21:45

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel