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 can I "NET SEND" from VFP?

Networking

How can I "NET SEND" from VFP?

by  wgcs  Posted    (Edited  )
Simple... once you see how...

Just use the API call (this doesn't support the group sending or wild card that NET.EXE does for you):

( In testing recently, it seems to work exactly every-other-time. Why, I'm not sure. )

Code:
*******************************************************
* Procedure: NetSend
*    Author: William GC Steinford
*      Date: Nov 7, 2002
*   Purpose: Simple VFP Wrapper for command line
*              NET SEND username message 
*******************************************************
PROCEDURE NetSend
LPARAMETERS pcUser, pcMessage

DECLARE INTEGER NetMessageBufferSend IN netapi32 ;
  STRING @ servername, STRING @ UserName, STRING @ fromname, ;
  STRING @ MessageBuf, INTEGER buflen
  
LOCAL lnLen, lcFrom, lcMsgName, lcUser, lcMsg
* Convert all strings to UNICODE
lcUser    = strconv( StrConv(pcUser,1), 5)
lcMsg     = strconv( StrConv(pcMessage,1), 5)
lcFrom    = strconv( Strconv(Sys(0),1), 5)
lnLen     = len(pcMessage)*2+2
* Revised March 26, 2004. 
*  For some reason, specifying the From name sometimes
*    causes the send to not go through.
* res=NetMessageBufferSend( 0, lcUser, lcFrom, lcMsg, lnLen )
res=NetMessageBufferSend( 0, lcUser, 0, lcMsg, lnLen )
RETURN res


Or, you could run the NET.EXE command and let it take care of the details for you.

Code:
RUN net send UserName Message Text

The disadvantages of doing it this way are:
o The RUN command starts a command shell first which usually is visible as a black-background window that flashes on the screen for a moment. Whether it's visible or can be difficult to control (it's controlled by FOXRUN.PIF so you have to modify that file appropriately, and distribute it with your application).
o RUN is significantly slower than DLL function calls.
o The RUN command requires the user to have execute rights on COMMAND.COM or CMD.EXE, which, in a locked down computer environment, are probably taken away.

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top