Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run NET SEND from FOX PRO ?

Status
Not open for further replies.

thomascd

Programmer
Mar 20, 2002
29
0
0
GB
Hi guys,
I want to send a message to other computers on the network, I saw from previous post that I can use dos NET SEND, but I can't manage to make it work from foxpro.

Moreover, is it only working with win2000 ?
 
Yes, it only works with NT/2k/+ ... it requires the "Messenger" service to be running in service manager.

Here's the programmatic way to initiate a NET SEND in VFP, though I haven't gotten it to work yet... I always get error 123 if the network name exists, and 53 if it doesn't... these aren't in the documented return values, which is kinda annoying:
Code:
PROCEDURE NetSend
LPARAMETERS pcServer, pcMessage

DECLARE INTEGER NetMessageBufferSend IN netapi32 ;
  STRING servername, STRING msgname, STRING fromname, ;
  STRING MessageBuf, INTEGER buflen
  
LOCAL lnLen, lcFrom, lcMsgName
lcMsgName = "VFP Message"
lcFrom = Sys(0)
lnLen  = len(pcMessage)
res=NetMessageBufferSend( pcServer, lcMsgName, lcFrom, pcMessage, lnLen )
RETURN res

Return Values:
5 = ERROR_ACCESS_DENIED The user does not have access to the requested information.
87 = ERROR_INVALID_PARAMETER The specified parameter is invalid.
50 = ERROR_NOT_SUPPORTED This network request is not supported.
2100+173 = NERR_NameNotFound The user name could not be found.
2100+36 = NERR_NetworkError A general failure occurred in the network hardware.


NET_API_STATUS NetMessageBufferSend(
LPCWSTR servername,
LPCWSTR msgname,
LPCWSTR fromname,
LPBYTE buf,
DWORD buflen
);



( This info was gleaned from )
 
Progress: I notice the parameters have to be UNICODE... this gets me a "good" error message (error 2100+173=NameNotFound)

Code:
LPARAMETERS pcServer, pcMessage

DECLARE INTEGER NetMessageBufferSend IN netapi32 ;
  STRING servername, STRING msgname, STRING fromname, ;
  STRING MessageBuf, INTEGER buflen
  
LOCAL lnLen, lcFrom, lcMsgName, lcServ, lcMsg
lcServ    = strconv( StrConv(pcServer,1), 5)
lcMsg     = strconv( StrConv(pcMessage,1), 5)
lcMsgName = strconv( strConv("VFP Message",1), 5)
lcFrom    = strconv( Strconv(Sys(0),1), 5)
lnLen     = len(pcMessage)*2+2
res=NetMessageBufferSend( lcServ, lcMsgName, lcFrom, lcMsg, lnLen )
RETURN res
 
Success! I misunderstood a couple parameters:
Code:
LPARAMETERS pcUser, pcMessage

DECLARE INTEGER NetMessageBufferSend IN netapi32 ;
  STRING servername, STRING UserName, STRING fromname, ;
  STRING MessageBuf, INTEGER buflen
  
LOCAL lnLen, lcFrom, lcMsgName, lcUser, lcMsg
lcUser    = strconv( StrConv(pcUser,1), 5)
lcMsg     = strconv( StrConv(pcMessage,1), 5)
lcFrom    = strconv( Strconv(Sys(0),1), 5)
lnLen     = len(pcMessage)*2+2
res=NetMessageBufferSend( 0, lcUser, lcFrom, lcMsg, lnLen )
RETURN res
 
wgcs

I have seen the Net Send question come up once in while. You may consider writting an FAQ. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top