Open a program??

Hi I want to be able to run a program a from within my C++ application, I plan to use the following codes...

ShellExecute(NULL, "open", "FILE_NAME.exe",NULL, NULL, SW_SHOWNORMAL);

but I noticed that not everyone will have the FILE_NAME.exe in the folder that I think that have it in.  How do I setup some way of saving the path to the file in a RegEdit value?? Then use the RegEdit value to run the program. Do you understand???  Also in case you need to know I will using Borland C++ Builder.
LVL 1
stevenc317Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LlandrCommented:
My initial response is to strip the application path from them argv[0] argument in the argument line. this way you have the application path and i suppose you can append this to the FILE_NAME.

0
stevenc317Author Commented:
I don't think you understand me.. Here let me try again.

I want to be able to run Netscape Communicator from within my program.  But not everyone will install Netscape in the default directory (C:\Program Files\Netscape\Communicator\Program\netscape.exe).  How can I ask the user to locate the file (that part I can do) and save the path (and exe file name) to a registory value, that way whenever the user wants to load the program the info is right there in the reg for my app to run it.
0
galkinCommented:
If you want to open file of specified type first use FindExecutable to locate executable associated with this file type and then call ShellExecute. If you want to launch specific executable( i.e. netscape.exe) you must perform global or restricted search with FindFirstFile(Ex)
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

stevenc317Author Commented:
ok, but how do I save the path to a registory value?  The user is not going to want to keep typing the path to the app every time he/she wants to run it!!
0
galkinCommented:
FindNextFile(Ex) used to locate executable takes as the second parameter reference WIN32_FIND_DATA, which if function succeded in locating file on return contains all file attributes including path to file.
0
LlandrCommented:
If you look in the registry you find that the value in
HKEY_USER\.Default\Software\Netscape\Netscape navigator\Main
contains a key named Install Directory. It should be sufficient to find the executable.
0
stevenc317Author Commented:
Llandr..

thanks!  But how do I get my app to look at that value and run it???
0
LlandrCommented:
You hav to use the Registry API to access this.
First open the key using RegOpenKeyEx then get the value using RegQueryValueEx.
You can find the documentation of RegOpenKeyEx and RegQueryValueEx in the help-files.

0
galkinCommented:
When you use ShellExecute this function locates executable either by full path you provide or if you specify only file name it looks into registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths. This key has subkeys, each subley is file name and its default value is full path to this file. Most program create their subkey during installation so you don't need to specify path to lauch them either using ShellExecute or from Windows Run dialog. If your application doesn't do this you can once locate it with FindExecutable and then create subkey in registry. Next time you( and anyone else) can launch this executable without providing executable path but only file name with extension.
By the way I sure nescape has already such a key so you can launch it without providing path.
0
stevenc317Author Commented:
thanks, I will do that.  But I still need to know how to save information into the reg and view info.  I just finished a Options section, when enters data in to text blank and clicks on the Update button I want the infor to be saved in a reg key, how????
0
galkinCommented:
I don't understand what you want to save. I told you if application has already created key under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths and specified there its full path you don't need any path just provide file name with exetension to pass to ShellExecute. If application doesn't create this subkey or you have move executable to another folder, so shellExecute fails you can use FindExecutable to locate it and create necessary register key yourself or change default value of existing key to correct path so next time you will not need to provide path.
0
LlandrCommented:
Just a comment. ShellExecute doesn't allow you to access Netscape Navigator, it allows you to access the extension associated with ".htm" (example) if you have several browsers it will not automatically find netsacep, just the one assoicated with ".htm".
If you wanät to save your data look at the other Reg-functions
0
stevenc317Author Commented:
Ok, I understand that Netscape has a key and I can just use that key to run the program.  What I am talking about now, is how do I save information into the registory??  For example username, version # of software, etc.

0
LlandrCommented:
Use the save use RegOpenKeyEx or RegCreateKeyEx to find/create the entry and then use RegSetValueEx to create your own value.
I suggest that you use the path:
HKEY_USER\.Default\Software\<Your program here>
0
stevenc317Author Commented:
thanks, but could you make me a little snipplet of codes??  I want it to take whatever is in Edit1 and put it in HKEY_USER\.Default\Software\Voltage Software\webmaster\user name

Can you do that???  If you do I will give u the 15 points...
0
stevenc317Author Commented:
next person to send a blank answer will get the 15 points.  I want this off the server...
0
ozoCommented:
blank
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
stevenc317Author Commented:
thanks ozo
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.