INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Networking

How can I "NET SEND" from VFP? by wgcs
Posted: 7 Nov 02 (Edited 26 Mar 04)

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.


Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close