2 Visual C++ Questions

I thought I’d just lump them together so I don’t have 2 threads.

  1. Using Visual C++ 6.0 on Win 98, what is the syntax to making a shell call (like dir or whatnot)? What headers are needed for it? How can I have my program store the result of the shell call in a string or whatnot?

  2. Does anyone know of a good reference on how to use the command line tools for Visual C++ 6.0? I checked out msdn, but I don’t think they support anything non-ide. I need to batch together a couple hundred builds, so command line seems to be right for me (besides, writing a .bat file is easier for me than a VB script).

Thanks to all.

Why would you want to shell-out a ‘dir’, when you’ve got FindFirst and FindNext? Most shell commands can be done via calls to the operating system, though. Can’t think of any besides ‘copy’ off the top of my head which can’t be done in-program, and ‘copy’ just needs some simple code written.

If you really want to go that route, though, you can go pretty far by calling WinExec, and passing it the name of a batch file, in which you can do what you want, and dump the results into a nice text file (provided the commands/programs you run play nice with stdout), which your program can then read and interpret however you like.

Actually, now that I think about it, the program I’ve been working on at work does exactly this to map a network drive so my code can write files to another machine. I didn’t have much time, and couldn’t find a way to get the capabilities of the little command-line utility into my program, so I WinExec a batch file to do it for me. It also offers the added benefit of not having to recompile if I need to change the way the command is called. I do, however, ignore the results of the call - if the files fail to write, I assume there’s no network. No big deal.