?
Solved

Help!

Posted on 1998-02-17
17
Medium Priority
?
247 Views
Last Modified: 2010-08-05
I am currently using the ShellExecute command to run applications from within my application.  Like this...

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

Well I need to tell my program where the other program (which is being launched form my app) is located.  I have been thinking and feal that using a reg key (which will be filed out when my setup application runs) tell it the directory that the file will be in.  How would I do that??  The reg key that will be used is...
HKEY_CURRENT_USER\High Voltage R&D\webmaster\install_dir

thanks
0
Comment
Question by:4099aol
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 8
17 Comments
 
LVL 3

Accepted Solution

by:
q2guo earned 80 total points
ID: 1182430
What you should do is create a text file with extension .reg containing the two lines below

REGEDIT4
HKEY_CURRENT_USER\High Voltage R&D\webmaster\install_dir

and inside you program call 'regedit file.reg'

0
 
LVL 32

Expert Comment

by:jhance
ID: 1182431
I'd suggest that you use the RegCreateKeyEx and RegQueryValueEx() API functions instead.
0
 

Author Comment

by:4099aol
ID: 1182432
do not understand your answer and do not uderstand your comment.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:q2guo
ID: 1182433
Ok, you can either do what I suggested.  Or go with jhance.

Call RegCreateKeyEx
here is how to call it

PHKEY pkey;
LPDWORD lpdword;
RegCreateKeyEx(HKEY_CURRENT_USER, NULL, 0,
               "High Voltage R\&D\\webmaster\\install_dir" ,
               REG_OPTION_NON_VOLATILE,
               KEY_ALL_ACCESS, &pkey, &lpdword);

0
 

Author Comment

by:4099aol
ID: 1182434
ok this

PHKEY pkey;
LPDWORD lpdword;
RegCreateKeyEx(HKEY_CURRENT_USER, NULL, 0, "High Voltage R\&D\\webmaster\\install_dir" , REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, &pkey, &lpdword);

would tell me what the value of the key is?? or will it run the application???
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182435
RegCreateKeyEx will create a key with no value
You call RegSetValue to set the value of the key

PHKEY pkey;
LPDWORD lpdword;
Char *keyvalue[] = "what ever";
RegCreateKeyEx(HKEY_CURRENT_USER, NULL, 0, "High Voltage R\&D\\webmaster\\install_dir" ,                       REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, &pkey, &lpdword);
RegOpenKey(HKEY_CURRENT_USER, NULL, &pkey);
RegSetValue(HKEY_CURRENT_USER, NULL, REG_SZ, keyvalue, 10);

the value 10 comes from the size in byte of the string - keyvalue.

0
 

Author Comment

by:4099aol
ID: 1182436
so this will create a blank reg key correct??

PHKEY pkey;
LPDWORD lpdword;
RegCreateKeyEx(HKEY_CURRENT_USER, NULL, 0, "High Voltage R\&D\\webmaster\\install_dir" , REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, &pkey, &lpdword);

and this will give it the value of "what ever"??

PHKEY pkey;
LPDWORD lpdword;
Char *keyvalue[] = "what ever";
RegCreateKeyEx(HKEY_CURRENT_USER, NULL, 0, "High Voltage
R\&D\\webmaster\\install_dir" , REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, &pkey, &lpdword);
RegOpenKey(HKEY_CURRENT_USER, NULL, &pkey);RegSetValue(HKEY_CURRENT_USER, NULL, REG_SZ, keyvalue, 10);
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182437
Ok, you got the create a blank key part correct

but, to give a key a value

you don't need the line RegCreateKeyEx(....)

Other than this, you got it
0
 

Author Comment

by:4099aol
ID: 1182438
so this will create the key and put the value in it?

PHKEY pkey;
LPDWORD lpdword;
Char *keyvalue[] = "what ever";
RegCreateKeyEx(HKEY_CURRENT_USER, NULL, 0, "High Voltage R\&D\\webmaster\\install_dir" , REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, &pkey, &lpdword); RegOpenKey(HKEY_CURRENT_USER, NULL, &pkey);RegSetValue(HKEY_CURRENT_USER, NULL, REG_SZ, keyvalue,10);
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182439
yeap
0
 

Author Comment

by:4099aol
ID: 1182440
please check the codes (which I just posted) I am reciving about 25-40 error messages.  I am using Borland C++ Builder v1.0
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182441
Can you put in above code line by line?
for example, put in
PHKEY pkey;
then compile, if it compiles fine
then put in the next line in

The codes works fine under visual C++

0
 

Author Comment

by:4099aol
ID: 1182442
Ok a { needs to be put somewhere in the third line...
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182443
oh, the third line should be
char keyvalue[] = "what ever";

* should not be in front of keyvalue
0
 

Author Comment

by:4099aol
ID: 1182444
There are a ton of errors!!! Starting with line four...
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182445
Probably Borland builder does not have the command
RegCreateKeyEx
why don't you reject my answer, so that this question is open again.
0
 

Author Comment

by:4099aol
ID: 1182446
I will give u the credit for all of this time you spent.  I also need to change the question around a bit.


0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question