Top.Mail.Ru Yandeks.Metrika
Forum: "WinAPI";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];


WinExec or ShellExecute Find similar branches

PONTIY   (2001-11-01 10:06) [0]

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) [1]

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) [2]

And how to do this, can I show an example in the code?

Anatoly Podgoretsky   (2001-11-02 09:44) [3]

Processor copy c: \ aa.txt \\ printsrv \ epson
Launch with ShellExecute
You recognize the processor name through system variables

PONTIY   (2001-11-02 18:56) [4]

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) [5]

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) [6]

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) [7]

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

Forum: "WinAPI";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];


Memory: 0.57 MB
Time: 0.026 c
1 - 22238
2001-12-16 07:29
Determine the menu item number

1 - 22052
2001-12-17 19:54
Drag and Drop Component

1 - 22019
2001-12-17 20:21
How to write a trainer!

3 - 21997
2001-12-05 11:46
How to create a user with permissions like sysdba

1 - 22256
walking questionnaire
2001-12-15 08:50
Reading values ​​from ini file

afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian Japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Spanish swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
English French German Italian Portuguese Russian Spanish