Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing the Calculator in any Windows Platform. 1

Status
Not open for further replies.

33216CLC

Programmer
Aug 17, 2000
173
BS
I get the "Invalid procedure call or argument" error when attempting to access the calculator from within my program. Here is the code I used:

retval = Shell(App.Path & "\calc.exe", vbNormalFocus)

I used the code below before, but of course, it only works with Windows 95, 98, ME, but not with NT or 2000.

retval = Shell("c:\windows\calc.exe", vbNormalFocus)

How can I access the calculator regardless of which Operating system, my users have?


Thanks
 
The path for system root\system(32) should be setup as default on any windows machine so you can just type

Shell "calc.exe", vbNormalFocus[\green]

Ciao
 
Well, App.Path & "\calc.exe" will only work if calc.exe is in your application path. Which I presume its not.

You say that on a 9x machine, calc.exe is in the windows directory. On my WinNT system here its in the system directory.

You could do it a quick and easy way by using the Environ("WinDir") and Environ("WinSysDir") to return the systems location for the windows and system directories. Then check if the file "calc.exe" exists in the windows directory. If it does then open it. If it doesn't then check to see if the file is in the system directory. If its in there then open it.

Thats a little bit messy so you could use a function to get the version of windows you are running and then choose your directory accordingly.

Or, if you are really worried that calc.exe may be somewhere quite unusual you could get your program to search your drives for clac.exe when it is first run and then store this path in the registry, INI file, property bag etc.

I'm sure there are lots of other ways to do it, some better than others, but theres three suggestions. I don't think theres a reg setting with the path to calc.exe.

elziko






 
phathi's solution look somewhat easier than mine doesn't it?

LOL

 
Thanks phathi & elziko.

Elziko,

The Calc.exe file is infact in the Application's directory. I have tried opening the calculator from the various directories many times before, but I often get,
"Calc.exe is not a valid win32 Application". It is only when I open it from Winnt/system32 that it works.

Thanks
 
phathi,

I tried your suggestion. It works.


Thanks again
 
Hi Phathi, Elziko,

I tried the code below. It works for the compiled version, but when I use the executable, I still get an error. Any ideas why?

retval = Shell("calc.exe", vbNormalFocus)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top