[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Help!

Posted on 1998-02-17
17
Medium Priority
?
255 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

650 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