Solved

Shellexecute doesn't work

Posted on 2004-08-02
6
544 Views
Last Modified: 2010-04-04
I'm trying to execute
net send 10.10.10.10 Hi
and i tried

var stripmsg,Strcomando:String;

strcomando:=' send '+StrIPMsg+'XXX:ccc';
     ShellExecute(0,
     nil,
     PChar('net'),
     PChar(Strcomando),
     nil,
     SW_HIDE);

It doesn't work......
it just work like that...


ShellExecute(0,nil,PChar('net'),PChar(' send 10.1.1.24 la'),nil,SW_HIDE);

I mean....Am I not enabled to send a Strinf as a Pchar?
0
Comment
Question by:Iamme
6 Comments
 
LVL 7

Expert Comment

by:LRHGuy
ID: 11699454
This worked for me:

var
  stripmsg,Strcomando:String;
  Dir:array[0..144] of Char;
  Pgm:array[0..255] of char;
begin
  GetWindowsDirectory(Dir, 144);
  StrPCopy(Pgm,StrPas(Dir)+'\net.exe');

strcomando:='send '+StrIPMsg+'XXX:ccc';
{strcomando:='use i: \\computer-1\c';}
     ShellExecute(0,
     '',
     Pgm,
     PChar(Strcomando),
     nil,
     SW_HIDE);
end;

Although, "send" isn't a command the my "net" understands. It did process the "use" command fine though. Thr trick is telling shellexecute where to find the "net" command.

Hope that helps!
Larry
0
 
LVL 7

Expert Comment

by:LRHGuy
ID: 11699459
Sorry about the "typos" ... sometimes I type too fast!

Larry
0
 
LVL 6

Expert Comment

by:gwalkeriq
ID: 11699531
I think you will find that the problem in not ShellExecute, but the net send command itself.

For example, try this click event, and I think you should at least see the new view command flicker past quickly.

procedure TForm1.Button1Click(Sender: TObject);
var
  cmd: string;
begin
  cmd := 'view';
  ShellExecute(0, nil, pchar('net'), pchar(cmd), nil, sw_show);
end;

If you run the net send command by hand, I suspect you will see that it is failing.

For example, on my network:

C:>ping 192.168

Pinging 192.168.1.24 with 32 bytes of data:

Reply from 192.168.1.24: bytes=32 time<1ms TTL=128
Reply from 192.168.1.24: bytes=32 time<1ms TTL=128

--- But, attempt a message to the same address and it fails ----

C:\>net send 192.168.1.24 "Hello world"
An error occurred while sending a message to 192.168.1.24.

The message alias could not be found on the network.

I suspect you will find you have a similar problem.  Test from the C: prompt before you try to debug from within your program. Since you are using SW_HIDE, you can't even see a flicker with an error message.

0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 11700900
Hello

  Try to use NetMessageBufferSend API for the same

look at my comment in this Paq for the sample
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20647390.html
0
 
LVL 1

Expert Comment

by:dragontron3k
ID: 11701935
Hi.

I had this problem as well. Don't pass net as the program to execute, but as the first parameter. This modification of your code should work:

strcomando:=' send '+StrIPMsg+'XXX:ccc';
     ShellExecute(0,
     nil,
     PChar(''),
     PChar('net ' + Strcomando),
     nil,
     SW_HIDE);
0
 
LVL 1

Accepted Solution

by:
dragontron3k earned 100 total points
ID: 11702054
Or, if you copied your question text directly from your source code, the problem might be that you forgot a space.

Where StrIPMsg = '10.1.1.24'

' send '+StrIPMsg+'XXX:ccc' will result in ' send 10.1.1.24XXX:ccc' instead of ' send 10.1.1.24 XXX:ccc'

Hope this or the previous helps.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question