I’m using Delphi 7 and can’t predict the target version of Windows.
I need to create a database (probably MySql, but might be something else) and define some table structures. I do not need to populate any data. Unfortunately, all of the ADO components seem to expect that a database already exists and they will then allow you to manipulate it.
So, since it’s only a few simple commands, I thought that I might as well use ShellExectute().
Agree? Disagree?
Can anyone give me a sample code which will attempt to run “MySql –version” and let me check the result? After that I should be able to figure it out for myself. Thanks.
[edit]
No offence intended, but I do know how to google. It’s just that I don’t find useful results. It’s my own fault for not being explicit in this question, so please accept my apology – what I need is a code example, not just the name of a component.
Sorry (and thanks for the replies so far (all of which are +1))
[edit]
The links which Robert gives do the job (procedure RunDosInMemo() does the trick) … B U T you Must remember to include an .exe extension (so, ‘notepad.exe’, not just ‘notepad’, and to ge a full path if your command is not on the path.
Here is an article that explains it detail
Capture the output from a DOS (command/console) Window
But in short you need to Create two pipes to read and write the output. Then you need to set StdInput and StdOutput in the TStartUpInfo structure, then pass this structure to the CreateProcess() call.
Here is another article that shows how to Wait for the process to finish.