Current archive: 2002.01.08;
WinExec or ShellExecute Find similar branches← →
PONTIY (2001-11-01 10:06) 
I wanted to print a text file (dos encoding) without any extra effort with a simple command in the shell: copy c: \ aa.txt \\ printsrv \ epson
I tried to do this with the ShellExecute function, like this:
ShellExecute (Handle, "print", "aa.txt", "D: \\ printsrv \ epson", nil, SW_HIDE);
Nothing worked, he opened notepad and printed out of it, as a result, the encoding of the text suffered. And despite the explicit indication of the parameter (device path), he always printed to the printer installed in the system by default. What else can be done far without departing from these functions?
Anatoly Podgoretsky (2001-11-01 15:41) 
If you want through the shell, then you must call the shell and pass the copy command to it as an argument
PONTIY (2001-11-02 06:19) 
And how to do this, can I show an example in the code?
Anatoly Podgoretsky (2001-11-02 09:44) 
Processor copy c: \ aa.txt \\ printsrv \ epson
Launch with ShellExecute
You recognize the processor name through system variables
PONTIY (2001-11-02 18:56) 
2 Anatoly Podgoretsky
Are you holding me completely for an idiot? :) show how to use this console command in ShellExecute. Like this ...
ShellExecute (Handle, "open", "cmd.exe", "copy c: \ aa.txt \\ printsrv \ epson
, nil, SW_HIDE);
Naturally, this code is incorrect, but how to write it correctly?
Anatoly Podgoretsky (2001-11-02 23:18) 
Well, you, all the information was given to you, all the same, everyone should write the programs himself.
And what doesn’t work for you? Does it work from the command line?
Well, I have neither "cmd.exe" to check the list of its keys (cmd /?), Nor NT to test, nor \\ printsrv \ epson, but for Win9x the code is approximately the following, for another command that I can verify:
ShellExecute (Handle, "open", "C: \ Command.com", "/ c dir C: \ / s", "C: \", SW_SHOWNORMAL);
Your code sins with the following errors:
The name of the shell must be obtained from environment variables,
The processor should start with the keys you need, I applied / c here, The default directory is not specified.
This is all unimportant, but it’s a mess.
PONTIY (2001-11-03 11:38) 
Yes, it really was necessary to start setting the parameter with the / C switch, everything works, thanks. Actually, it is unlikely that this project will ever work on Win9x operating systems, but still for the future, is there such a variable that indicates a command processor?
Anatoly Podgoretsky (2001-11-03 15:10) 
Run the SET command in the dos window, I have COMSPEC
The fact that it will not work on other OSs does not mean that the processor name in the particular OS will be cmd.exe or that the processor will be available without specifying the path.
And the / C key is optional, it just affects the behavior of the processor, as well as other keys
Pages: 1 whole branch
Current archive: 2002.01.08;
Memory: 0.57 MB
Time: 0.026 c