Read variables through EXE

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Sorry for the confusing topic, I wasn't sure how to word this exactily.

I have a program that needs to read a variable in from the outside.
Specifically, the program will be run like this:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Exec("myProgram.exe 123456")
end sub

myProgram.exe is a VC++ application
123456 is a variable I want to be able to read into this VC++ application.

Any advice on how to do this would be greatly appreciated. I tried looking
around for an answer but I could not find a decent reference
 
ashton said:
Sorry for the confusing topic, I wasn't sure how to word this exactily.

I have a program that needs to read a variable in from the outside.
Specifically, the program will be run like this:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Exec("myProgram.exe 123456")
end sub

myProgram.exe is a VC++ application
123456 is a variable I want to be able to read into this VC++ application.

Any advice on how to do this would be greatly appreciated. I tried looking
around for an answer but I could not find a decent reference

Perhaps this short article on an alternate form of the main() header will
help:

"In many example programs, the parameters to main are left off (they are
optional) and so you may have never been exposed to the complete use of
main().

The full syntax for main is:

int main(int argc, char* argv[]);

.....where argc is the "argument count" ("argument" applying to command-line
arguments) and argv is an array of argc elements, each a pointer to a
command line argument (as a string, of course). The first element is
always the program's own name.

For example, if you had a program called FOO.EXE that you had started by
entering...

FOO /a /b "my argument"

.....on the command-line, you could access the command-line arguments in
your code like so...

int main(int argc, char* argv[])
{
int iArgCount = argc; // equal to 4
char* pszProg = argv[0]; // points to something like "FOO.EXE"
char* pszArg1 = argv[1]; // points to "/a"
char* pszArg2 = argv[2]; // points to "/b"
char* pszArg3 = argv[3]; // points to "my argument"
 
Back
Top